You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.5 KiB
84 lines
2.5 KiB
using System; |
|
using System.Collections.Generic; |
|
using System.Linq; |
|
using System.Reflection; |
|
using System.Text; |
|
using System.Runtime.InteropServices; |
|
using System.Drawing; |
|
using System.Windows.Forms; |
|
using System.Windows.Forms.VisualStyles; |
|
using System.ComponentModel; |
|
using System.Drawing.Imaging; |
|
using System.Globalization; |
|
using static System.Net.Mime.MediaTypeNames; |
|
using System.Diagnostics; |
|
using System.Net.NetworkInformation; |
|
using System.Net; |
|
using System.Management; |
|
using System.IO.Ports; |
|
using System.IO; |
|
using System.Security.Cryptography; |
|
using System.Windows.Forms.Design; |
|
|
|
namespace UTIL |
|
{ |
|
#region Параметры командной строки |
|
public class ParParse |
|
{ |
|
private List<(bool, String, String, bool, String)> Pars = new List<(bool, string, string, bool, string)>(); |
|
private int _num = 0; |
|
private (bool, string, string, bool, string) nullitem = (false, null, null, false, null); |
|
public int NumofPar { get; } |
|
public (bool, string, string, bool, string) GetPar(UInt16 num) |
|
{ |
|
if (Pars[num].Item1) |
|
return Pars[num]; |
|
else |
|
return nullitem; |
|
} |
|
public (bool, string, string, bool, string) GetPar(String par) |
|
{ |
|
for (int j = 0; j < _num; j++) |
|
{ |
|
if ((par == Pars[j].Item2 || par == Pars[j].Item3) && Pars[j].Item1) |
|
return Pars[j]; |
|
} |
|
return nullitem; |
|
} |
|
public void AddPar(String shrt, String lng, Boolean key) |
|
{ |
|
Pars.Add((false, shrt, lng, key, "")); |
|
_num = Pars.Count; |
|
} |
|
public int Parse(String[] arg) |
|
{ |
|
int rez = 0; |
|
if (_num == 0) |
|
return -1; |
|
|
|
if (arg.Length == 0) |
|
return -1; |
|
|
|
for (int i = 0; i < arg.Length; i++) |
|
{ |
|
for (int j = 0; j < _num; j++) |
|
{ |
|
if (arg[i] == Pars[j].Item2 || arg[i] == Pars[j].Item3) |
|
{ |
|
(bool, string, string, bool, string) tmp = Pars[j]; |
|
if (Pars[j].Item4) |
|
{ |
|
tmp.Item5 = arg[i + 1]; |
|
} |
|
tmp.Item1 = true; |
|
Pars[j] = tmp; |
|
rez++; |
|
} |
|
} |
|
} |
|
return rez; |
|
} |
|
} |
|
#endregion |
|
|
|
}
|
|
|