コード例 #1
0
            public void Base()
            {
                IDependencyContainer root = new SimpleDependencyContainer();

                IReflectionService reflectionService = ReflectionFactory.FromCurrentAppDomain();

                using (ITypeExecutorService executorService = reflectionService.PrepareTypeExecutors())
                {
                    executorService.AddQueryHandlers(root);
                }

                IQueryHandler <Q1, R1> handler1 = root.Resolve <IQueryHandler <Q1, R1> >();
                IQueryHandler <Q2, R2> handler2 = root.Resolve <IQueryHandler <Q2, R2> >();
            }
コード例 #2
0
    public static void Start()
    {
        //HtmlContext.alert("Hell, World!");

        IDependencyContainer dependencyContainer = new SimpleDependencyContainer();

        dependencyContainer.Definitions
        .AddTransient <Presenter>()
        .AddScoped <MainView>();

        Presenter p1 = dependencyContainer.Resolve <Presenter>();

        p1.Render();

        Presenter p2 = dependencyContainer.Resolve <Presenter>();

        p2.Render();
    }
コード例 #3
0
        public static void Test()
        {
            IDependencyContainer dependencyContainer = new SimpleDependencyContainer();

            dependencyContainer.Definitions
            .AddScoped <ResolveUrl>(dependencyContainer.ScopeName, new ResolveUrl(ResolveUrl));

            ResolveUrl resolveUrl = dependencyContainer.Resolve <ResolveUrl>();

            resolveUrl("~/root");
        }
コード例 #4
0
            public void ConcreteType()
            {
                IDependencyContainer root = new SimpleDependencyContainer();

                IReflectionService reflectionService = ReflectionFactory.FromCurrentAppDomain();

                using (ITypeExecutorService executorService = reflectionService.PrepareTypeExecutors())
                {
                    executorService.AddQueryHandlers(root);
                }

                IQueryHandler <Q3, R3> handler1 = root.Resolve <IQueryHandler <Q3, R3> >();

                try
                {
                    IQueryHandler <Q4, R4> handler2 = root.Resolve <IQueryHandler <Q4, R4> >();
                    Assert.Fail("Handler for Q4 should not be registered");
                }
                catch (DependencyRegistrationFailedException)
                { }
            }
コード例 #5
0
        private static HelloService Sequence()
        {
            IDependencyContainer dependencyContainer = new SimpleDependencyContainer();

            dependencyContainer.Definitions
            .AddScoped <string>(dependencyContainer.ScopeName, "Hi")
            .AddScoped <TextWriter>(dependencyContainer.ScopeName, Console.Out);

            SequenceBootstrapper bootstrapper = new SequenceBootstrapper(task => dependencyContainer.Resolve <IBootstrapTask>(task));

            bootstrapper.Register <Sequence.WriterBootstrapTask>();
            bootstrapper.Register <Sequence.HelloBootstrapTask>();
            bootstrapper.Initialize();

            //return Engine.Environment.With<HelloService>();
            throw new NotImplementedException();
        }