예제 #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)
                { }
            }
        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();
        }