static void Main(string[] args)
        {
            InputProcessor input = new InputProcessor(); // new object of InputProcessor classs

            input.PreventSLetter();
            input.PreventEvenNumbers();
            input.SetResponceTo10CharsOfInput();
            input.Process();
        }
Example #2
0
 public static void SetResponceTo10CharsOfInput(this InputProcessor processor)
 {
     processor.Processors.Add(inputModel =>
     {
         if (inputModel.Input.Length > 10)
         {
             inputModel.Response = inputModel.Input.Substring(0, 10);
         }
     });
 }
Example #3
0
        public static void PreventSLetter(this InputProcessor processor)
        {
            processor.Processors.Add(inputModel =>
            {
                if (inputModel.Input.Contains('s'))
                {
                    inputModel.Response = "Letter s is not allowed blet";

                    processor.WriteResponse(inputModel);
                }
            });
        }
Example #4
0
        public static void PreventEvenNumbers(this InputProcessor processor)
        {
            processor.Processors.Add(inputModel =>
            {
                int a;
                if (int.TryParse(inputModel.Input, out a))
                {
                    if (a % 2 == 0)
                    {
                        inputModel.Response = "Even number not allowed";

                        processor.WriteResponse(inputModel);
                    }
                }
            });
        }