Example #1
0
        private static ISentenceHandlers LoadHandlers(IUnityContainer container)
        {
            var handlers = new SentenceHandlers
            {
                Handlers = new Dictionary <SentenceType, IHandler>()
                {
                    { SentenceType.Declarative, new DeclarativeSentenceHandler(container.Resolve <IExecutionContext>()) },
                    { SentenceType.Imperative, new ImperativeSentenceHandler(container.Resolve <IExecutionContext>(), container.Resolve <IConfiguration>(), container.Resolve <IValidator>()) },
                    { SentenceType.Invalid, new InvalidSentenceHandler(container.Resolve <IExecutionContext>()) },
                    { SentenceType.Interrogative, new InterrogativeSentenceHandler(container.Resolve <IExecutionContext>(), container.Resolve <IConfiguration>(), container.Resolve <IValidator>()) }
                }
            };

            return(handlers);
        }
        public static ISentenceHandlers LoadHandlers(IConfiguration configuration)
        {
            var validator = new Validator(Context, configuration);
            var handlers  = new SentenceHandlers
            {
                Handlers = new Dictionary <SentenceType, IHandler>()
                {
                    { SentenceType.Declarative, new DeclarativeSentenceHandler(Context) },
                    { SentenceType.Imperative, new ImperativeSentenceHandler(Context, configuration, validator) },
                    { SentenceType.Invalid, new InvalidSentenceHandler(Context) },
                    { SentenceType.Interrogative, new InterrogativeSentenceHandler(Context, configuration, validator) }
                }
            };

            return(handlers);
        }