Esempio n. 1
0
        public static StringKeyValueCollection Parse(string[] lines)
        {
            StringKeyValueCollection properties = new StringKeyValueCollection();

            for (int i = 0; i < lines.Length; i++)
            {
                string line = lines[i];

                if (string.IsNullOrEmpty(line) || line.StartsWith("#"))
                {
                    continue;
                }

                line = line.Trim();


                var keyValue = line.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);

                if (keyValue.Length == 0)
                {
                    continue;
                }

                string propertyName  = keyValue[0].Trim();
                string propertyValue = null;

                if (keyValue.Length == 2)
                {
                    propertyValue = keyValue[1].Trim();
                }


                if (properties.Contains(propertyName))
                {
                    throw new ArgumentException(string.Format("Duplicate property name {0}", propertyName));
                }
                else
                {
                    properties.Add(new StringKeyValue(propertyName, propertyValue, i));
                }
            }

            return(properties);
        }
Esempio n. 2
0
 public CommandLineParametersParser(string[] parameters, string usageInfo)
 {
     _cliParams = StringKeyValueCollection.Parse(parameters);
     _usageInfo = usageInfo;
 }