Ejemplo n.º 1
0
        // protected Methods

        protected override void ApplicationStartup(TinyIoCContainer nancy, IPipelines pipelines)
        {
            // Create Simple Injector container
            Container container = new Container();

            container.Options.DefaultScopedLifestyle = new ExecutionContextScopeLifestyle();

            var requestBroker = new RequestBroker();

            RegisterMethods(requestBroker);

            // Register application components here, e.g.:
            container.RegisterSingleton <RequestBroker>(requestBroker);

            // Register Nancy modules.
            foreach (var nancyModule in this.Modules)
            {
                container.Register(nancyModule.ModuleType);
            }

            // Cross-wire Nancy abstractions that application components require (if any). e.g.:
            //container.Register(nancy.Resolve<IModelValidator>);

            // Check the container.
            container.Verify();

            // Hook up Simple Injector in the Nancy pipeline.
            nancy.Register(typeof(INancyModuleCatalog), new SimpleInjectorModuleCatalog(container));
            nancy.Register(typeof(INancyContextFactory), new SimpleInjectorScopedContextFactory(
                               container, nancy.Resolve <INancyContextFactory>()));
        }
Ejemplo n.º 2
0
        // Constructors

        public MethodDispatcherModule(RequestBroker requestBroker)
        {
            this.requestBroker = requestBroker;

            Post["/async", true] = async(parameters, ct) => await DispatchMethodAsync(parameters, ct);

            Post["/"] = DispatchMethod;
        }
Ejemplo n.º 3
0
        // private Methods

        private void RegisterMethods(RequestBroker requestBroker)
        {
            var systemAuth = new SystemAuth();

            requestBroker.Add("system.login", systemAuth.Login);

            var orderPicking = new OrderPicking();

            requestBroker.Add("orderPicking.getPickList", orderPicking.GetPickList);
        }