Exemple #1
0
 public static void CheckRules(ArgumentDictionary arguments, CheckingRule[] rules)
 {
     for (int i = 0; i < rules.Length; i++)
     {
         CheckingRule checkingRule = rules[i];
         checkingRule.CheckRule(arguments);
     }
 }
Exemple #2
0
        public static string PrintHelp(CheckingRule[] rules, CommandSwitch[] switches, bool print)
        {
            StringBuilder stringBuilder = new StringBuilder("\nMore help on command-line options:\n\n");
            Hashtable     hashtable     = new Hashtable();

            for (int i = 0; i < rules.Length; i++)
            {
                CheckingRule checkingRule = rules[i];
                if (!hashtable.Contains(checkingRule.Cswitch))
                {
                    IList list = new ArrayList();
                    list.Add(checkingRule);
                    hashtable.Add(checkingRule.Cswitch, list);
                }
                else
                {
                    IList list2 = (IList)hashtable[checkingRule.Cswitch];
                    list2.Add(checkingRule);
                }
            }
            for (int j = 0; j < switches.Length; j++)
            {
                CommandSwitch commandSwitch  = switches[j];
                StringBuilder stringBuilder2 = new StringBuilder("/");
                stringBuilder2.Append(commandSwitch.Name);
                string value = string.Empty;
                if (commandSwitch.ValueName != string.Empty)
                {
                    value = ":<" + commandSwitch.ValueName + ">";
                    stringBuilder2.Append(value);
                }
                StringBuilder stringBuilder3 = new StringBuilder();
                if (commandSwitch.Name != commandSwitch.Abbreviation)
                {
                    stringBuilder3.Append(" [Short form: /");
                    stringBuilder3.Append(commandSwitch.Abbreviation);
                    stringBuilder3.Append(value);
                    stringBuilder3.Append(']');
                }
                string value2 = CommandParser.WrapLine(commandSwitch.Description, 80);
                char   value3 = (stringBuilder2.Length + stringBuilder3.Length + 1 > 80) ? '\n' : ' ';
                stringBuilder2.Append(value3);
                stringBuilder2.Append(stringBuilder3.ToString());
                stringBuilder2.Append('\n');
                stringBuilder2.Append(value2);
                stringBuilder2.Append('\n');
                stringBuilder.Append(stringBuilder2.ToString());
                stringBuilder.Append('\n');
            }
            if (print)
            {
                Console.WriteLine(stringBuilder.ToString());
            }
            return(stringBuilder.ToString());
        }