Ejemplo n.º 1
0
        public void addRule()
        {
            Console.WriteLine("Set rule name: ");
            String   ruleName   = Console.ReadLine();
            Severity ruleSev    = 0;
            Boolean  ruleSevSet = false;

            while (!ruleSevSet)
            {
                Console.WriteLine("Set rule severity; Low(0), Medium(1), or High(2)?");
                String ruleSeverity = Console.ReadLine();
                try
                {
                    ruleSev = (Severity)Enum.Parse(typeof(Severity), ruleSeverity, true);
                    if (Enum.IsDefined(typeof(Severity), ruleSev))
                    {
                        Console.WriteLine("{0} rule severity is {1}", ruleName, ruleSev);
                        ruleSevSet = true;
                    }
                    else
                    {
                        Console.WriteLine("'{0}' is not a valid severity rating. Please enter 'Low', 'Medium', 'High;, '0', '1', or '2'", ruleSeverity);
                    }
                }
                catch (ArgumentException)
                {
                    Console.WriteLine("'{0}' is not a valid severity rating. Please enter 'Low', 'Medium', 'High;, '0', '1', or '2'", ruleSeverity);
                }
            }
            FileTransferRule rule = new FileTransferRule(ruleName, ruleSev);

            rule.target = this;
            rule.setConditions();
            rule.setRulePath();
            rules.Add(rule);
        }
Ejemplo n.º 2
0
 public void addRule()
 {
     Console.WriteLine("Set rule name: ");
     String ruleName = Console.ReadLine();
     Severity ruleSev = 0;
     Boolean ruleSevSet = false;
     while (!ruleSevSet)
     {
         Console.WriteLine("Set rule severity; Low(0), Medium(1), or High(2)?");
         String ruleSeverity = Console.ReadLine();
         try
         {
             ruleSev = (Severity)Enum.Parse(typeof(Severity), ruleSeverity, true);
             if (Enum.IsDefined(typeof(Severity), ruleSev))
             {
                 Console.WriteLine("{0} rule severity is {1}", ruleName, ruleSev);
                 ruleSevSet = true;
             }
             else
             {
                 Console.WriteLine("'{0}' is not a valid severity rating. Please enter 'Low', 'Medium', 'High;, '0', '1', or '2'", ruleSeverity);
             }
         }
         catch (ArgumentException)
         {
             Console.WriteLine("'{0}' is not a valid severity rating. Please enter 'Low', 'Medium', 'High;, '0', '1', or '2'", ruleSeverity);
         }
     }
     FileTransferRule rule = new FileTransferRule(ruleName, ruleSev);
     rule.target = this;
     rule.setConditions();
     rule.setRulePath();
     rules.Add(rule);
 }