示例#1
0
文件: Program.cs 项目: NeO1984/Exams
        static void Main(string[] args)
        {
            Console.WriteLine("Please enter a sentence");
            string input = Console.ReadLine();

            Action actionToCheckPalindrome = () =>
            {
                Container container = new Container();

                string palindromeStrategyValue = ConfigUtils.GetValueByKey("PalindromeStrategyType");
                PalindromeStrategyType palindromeStrategyType = StringUtils.ToEnum(palindromeStrategyValue, PalindromeStrategyType.Recursive);

                IPalindromeFactory  palindromeProcessor = container.GetInstance <IPalindromeFactory>();
                IPalindromeStrategy palindromeStrategy  = palindromeProcessor.GetPalindromeStrategy(palindromeStrategyType);
                bool isInputPalindrome = palindromeStrategy.CheckIfInputIsPalindrome(input);

                Console.WriteLine(string.Format("Your input is {0} Palindrome", (isInputPalindrome ? "a" : "not a")));
            };

            Action <Exception> actionToLogException = excpetion => Console.WriteLine(excpetion.Message);

            ExceptionHandler.TryCatch(actionToCheckPalindrome, actionToLogException);

            Console.ReadLine();
        }
示例#2
0
 public PalindromeController(IPalindromeFactory palindromeFactory)
 {
     _palindromefactory = palindromeFactory;
 }
示例#3
0
        public void GetInstanceByTypeIfTypeIsConfiguredInContainer()
        {
            IPalindromeFactory factory = container.GetInstance <IPalindromeFactory>();

            Assert.IsType <PalindromeFactory>(factory);
        }
 public PalindromesController(PalindromeContext context, IPalindromeFactory palindromeFactory)
 {
     _context           = context;
     _palindromeFactory = palindromeFactory;
 }