private void InsertContainer(int index, CompositeContainer container)
        {
            IEnumerable collection = _collections[index] = container.Collection;

            foreach (object obj in collection)
            {
                base.InsertItem(index++, obj);
            }
        }
Beispiel #2
0
        public static void Run()
        {
            IDeveloper developer = null;
            var container = new CompositeContainer();

            container.Configure();
            developer = container.Resolve<IDeveloper>();
            developer.Code();
        }
Beispiel #3
0
        public static void Run()
        {
            IDeveloper developer = null;
            var        container = new CompositeContainer();

            container.Configure();
            developer = container.Resolve <IDeveloper>();
            developer.Code();
        }
        public static CompositeContainer AddEventAndExceptionConsumer(this CompositeContainer container)
        {
            var appPlugin = new MockApplicationPlugin();

            appPlugin.AddPluginType <MockErrorMessageConsumer>();

            container.RegisterPlugins(appPlugin);
            return(container);
        }
        public static CompositeContainer WithHost(this CompositeContainer container)
        {
            var hostPlugin = new MockHostPlugin();

            container.RegisterPlugins(hostPlugin);
            container.RegisterPlugin <MessagingPlugin>();

            return(container);
        }
        static void Main(string[] args)
        {
            ICompositeWindow window = null;
            var container           = new CompositeContainer();

            container.Configure();
            window = container.Resolve <ICompositeWindow>();
            window.Show();
            window.BeforeClose();
        }
 public CompositeContainerBuilder(IServiceCollection serviceCollection, 
     ITypeResolver typeResolver,
     IConfiguration configuration)
 {
     if (configuration == null) throw new ArgumentNullException(nameof(configuration));
     
     _serviceCollection = serviceCollection ?? throw new ArgumentNullException(nameof(serviceCollection));
     _typeResolver = typeResolver ?? throw new ArgumentNullException(nameof(typeResolver));
     _container = new CompositeContainer(serviceCollection, configuration);
 }
        public static CompositeContainer AddMultipleConsumers(this CompositeContainer container)
        {
            var appPlugin = new MockApplicationPlugin();

            appPlugin.AddPluginType <MockInvalidCommandConsumer>();

            container.RegisterPlugins(appPlugin);
            container.RegisterPlugin <MessagingPlugin>();

            return(container);
        }
Beispiel #9
0
        public static void Run()
        {
            IDeveloper developer = null;
            var container = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(IDeveloper) }
            });

            container.Configure();
            developer = container.Resolve<IDeveloper>();
            container.Dispose();
        }
Beispiel #10
0
        public static void Run()
        {
            IDeveloper developer = null;
            var        container = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(IDeveloper) }
            });

            container.Configure();
            developer = container.Resolve <IDeveloper>();
            Console.WriteLine("Each resolve creates a new instance: {0}", developer != container.Resolve <IDeveloper>());
        }
        public static CompositeContainer WithHostConsumer(this CompositeContainer container)
        {
            var hostPlugin = new MockHostPlugin();

            hostPlugin.AddPluginType <MockDomainEventConsumer>();

            container.RegisterPlugins(hostPlugin);
            container.RegisterPlugin <MessagingPlugin>();

            return(container);
        }
Beispiel #12
0
        public static void Run()
        {
            ICSharpDeveloper developer = null;
            var container = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(ICSharpDeveloper) }
            });

            container.Configure();
            developer = container.Resolve<ICSharpDeveloper>();
            Console.WriteLine(developer.Code());
        }
Beispiel #13
0
        public static void Run()
        {
            IPerson person = null;
            var container = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(IPerson) }
            });

            container.Configure();
            person = container.Resolve<IPerson>();
            person.Code();
        }
Beispiel #14
0
        public static void Run()
        {
            IPerson person    = null;
            var     container = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(IPerson) }
            });

            container.Configure();
            person = container.Resolve <IPerson>();
            person.Code();
        }
Beispiel #15
0
 public ContainerAssert(
     ContainerFixture fixture,
     CompositeContainer container,
     IServiceProvider serviceProvider,
     Exception resultingException)
 {
     _fixture            = fixture;
     _container          = container;
     _resultingException = resultingException;
     _testServiceScope   = serviceProvider;
 }
Beispiel #16
0
        public static void Run()
        {
            IDeveloper developer = null;
            var        container = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(IDeveloper) }
            });

            container.Configure();
            developer = container.Resolve <IDeveloper>();
            Console.WriteLine(developer.Code());
        }
Beispiel #17
0
        public static void Run()
        {
            IDeveloper developer = null;
            var container = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(IDeveloper) }
            });

            container.Configure();
            developer = container.Resolve<IDeveloper>();
            Console.WriteLine("All instances are the same: {0}", developer == container.Resolve<IDeveloper>());
        }
Beispiel #18
0
        public static void Run()
        {
            IDeveloper developer = null;
            var        container = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(IDeveloper) },
                DependencyContainerAdapter = new StructureMapAdapter()
            });

            container.Configure();
            developer = container.Resolve <IDeveloper>();
            developer.Code();
        }
Beispiel #19
0
        public static void Run()
        {
            IDeveloper developer = null;
            var container = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(IDeveloper) },
                DependencyContainerAdapter = new StructureMapAdapter()
            });

            container.Configure();
            developer = container.Resolve<IDeveloper>();
            developer.Code();
        }
Beispiel #20
0
        public async static void Run() {
            IDeveloper developer = null;
            var container = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(IDeveloper) }
            });

            container.Configure();
            SetHttpContext();
            developer = container.Resolve<IDeveloper>();
            Console.WriteLine("Instances within the same HttpContext are the same: {0}", developer == container.Resolve<IDeveloper>());
            SetHttpContext();
            Console.WriteLine("Instances within different HttpContext are not the same: {0}", developer != container.Resolve<IDeveloper>());
        }
Beispiel #21
0
        public static void Run()
        {
            IDeveloper developer = null;
            var        container = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(ICSharpDeveloper), typeof(IJavaScriptDeveloper) }
            });

            container.Configure();
            developer = container.ResolveNamed <IDeveloper>("C#");
            developer.Code();
            developer = container.ResolveNamed <IDeveloper>("JavaScript");
            developer.Code();
        }
        protected override void InsertItem(int index, object item)
        {
            CompositeContainer container = item as CompositeContainer;

            if (null != container && null != container.Collection)
            {
                InsertContainer(index, container);
            }
            else
            {
                base.InsertItem(index, item);
            }
        }
Beispiel #23
0
        public static void Run()
        {
            IDeveloper developer = null;
            var container = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(ICSharpDeveloper), typeof(IJavaScriptDeveloper) }
            });

            container.Configure();
            developer = container.ResolveNamed<IDeveloper>("C#");
            developer.Code();
            developer = container.ResolveNamed<IDeveloper>("JavaScript");
            developer.Code();
        }
Beispiel #24
0
        public async static void Run()
        {
            IDeveloper developer = null;
            var        container = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(IDeveloper) }
            });

            container.Configure();
            SetHttpContext();
            developer = container.Resolve <IDeveloper>();
            Console.WriteLine("Instances within the same HttpContext are the same: {0}", developer == container.Resolve <IDeveloper>());
            SetHttpContext();
            Console.WriteLine("Instances within different HttpContext are not the same: {0}", developer != container.Resolve <IDeveloper>());
        }
Beispiel #25
0
        public static void Run()
        {
            IDeveloper    developer = null;
            Func <string> handler   = () => "C# coding";
            var           container = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(IDeveloper) }
            });

            container.Configure();
            developer = container.Resolve <IDeveloper>();
            developer.OnCodeCompleted += handler;
            developer.Code();
            developer.OnCodeCompleted -= handler;
        }
Beispiel #26
0
        public static void Run()
        {
            IDeveloper developer = null;
            Func<string> handler = () => "C# coding";
            var container = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(IDeveloper) }
            });

            container.Configure();
            developer = container.Resolve<IDeveloper>();
            developer.OnCodeCompleted += handler;
            developer.Code();
            developer.OnCodeCompleted -= handler;
        }
Beispiel #27
0
        public static void Run()
        {
            IDeveloper developer = null;
            Action<string> codeCompletionAction = (code) => Console.WriteLine(code);
            var container = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(IDeveloper) }
            });

            container.Configure();
            developer = container.Resolve<IDeveloper>();
            developer.OnCodeCompleted += codeCompletionAction;
            developer.Code("C# coding");
            developer.OnCodeCompleted -= codeCompletionAction;
        }
Beispiel #28
0
        public static void Run()
        {
            IDeveloper      developer            = null;
            Action <string> codeCompletionAction = (code) => Console.WriteLine(code);
            var             container            = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(IDeveloper) }
            });

            container.Configure();
            developer = container.Resolve <IDeveloper>();
            developer.OnCodeCompleted += codeCompletionAction;
            developer.Code("C# coding");
            developer.OnCodeCompleted -= codeCompletionAction;
        }
Beispiel #29
0
        static void Main(string[] args)
        {
            int i = 0, j = 0, k = 0;
            //new Person().Code(ref i, j, ref k); return;
            var settings = new CompositeRuntimeSettings {
                DependencyContainerAdapter = new StructureMapAdapter()
            };

            var container = new CompositeContainer(settings);

            container.Configure();
            var person = container.TryResolveNamed <IPersonComposite>("IPersonComposite");

            person.Code(ref i, j, ref k);
            Console.WriteLine(i);
        }
Beispiel #30
0
        public static void Run()
        {
            IPerson person = null;
            var smContainer = ObjectFactory.Container;
            var container = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(IPerson) },
                DependencyContainerAdapter = new StructureMapAdapter(smContainer)
            });

            smContainer.Configure(x => {
                x.For<ICSharpLanguageVersion>().Use<CSharp5LanguageVersion>();
            });

            container.Configure();
            person = container.Resolve<IPerson>();
            person.Code();
        }
        public void Get()
        {
            try
            {
                var container = new CompositeContainer();

                container.Configure();
                container.Resolve <IMyPostService>();
                service.GetPostList();
                //return new OkObjectResult(new List<PostDto>());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                //return new NotFoundObjectResult(new List<PostDto>());
            }
        }
Beispiel #32
0
        public static void Run()
        {
            IPerson person      = null;
            var     smContainer = ObjectFactory.Container;
            var     container   = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(IPerson) },
                DependencyContainerAdapter = new StructureMapAdapter(smContainer)
            });

            smContainer.Configure(x => {
                x.For <ICSharpLanguageVersion>().Use <CSharp5LanguageVersion>();
            });

            container.Configure();
            person = container.Resolve <IPerson>();
            person.Code();
        }
Beispiel #33
0
        public static CompositeContainer WithRabbitMqHost(this CompositeContainer container,
                                                          params Type[] hostTypes)
        {
            var hostPlugin = new MockHostPlugin();

            hostPlugin.AddModule <HostModule>();
            hostPlugin.AddPluginType(hostTypes);

            var corePlugin = new MockCorePlugin();

            corePlugin.AddPluginType <BusSettings>();
            corePlugin.AddModule <MockBusModule>();
            corePlugin.AddModule <MockPublisherModule>();
            corePlugin.AddModule <MockSubscriberModule>();

            container.RegisterPlugin <MessagingPlugin>();
            container.RegisterPlugins(corePlugin);
            container.RegisterPlugins(hostPlugin);

            return(container);
        }
Beispiel #34
0
        public async static Task Run() {
            IDeveloper developer = null;
            bool sameInstanceAtEachThread = false;
            IDeveloper otherThreadDeveloper = null;
            var container = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(IDeveloper) }
            });

            container.Configure();
            otherThreadDeveloper = await Task.Factory.StartNew<IDeveloper>(() => {
                var first = container.Resolve<IDeveloper>();

                sameInstanceAtEachThread = container.Resolve<IDeveloper>() == first;

                return first;
            });

            developer = container.Resolve<IDeveloper>();
            Console.WriteLine("Instance is created for each thread: {0}", otherThreadDeveloper != container.Resolve<IDeveloper>());
            Console.WriteLine("All instances in the same thread are the same: {0}", sameInstanceAtEachThread && developer == container.Resolve<IDeveloper>());
        }
Beispiel #35
0
        public async static Task Run()
        {
            IDeveloper developer = null;
            bool       sameInstanceAtEachThread = false;
            IDeveloper otherThreadDeveloper     = null;
            var        container = new CompositeContainer(new CompositeRuntimeSettings {
                Types = new[] { typeof(IDeveloper) }
            });

            container.Configure();
            otherThreadDeveloper = await Task.Factory.StartNew <IDeveloper>(() => {
                var first = container.Resolve <IDeveloper>();

                sameInstanceAtEachThread = container.Resolve <IDeveloper>() == first;

                return(first);
            });

            developer = container.Resolve <IDeveloper>();
            Console.WriteLine("Instance is created for each thread: {0}", otherThreadDeveloper != container.Resolve <IDeveloper>());
            Console.WriteLine("All instances in the same thread are the same: {0}", sameInstanceAtEachThread && developer == container.Resolve <IDeveloper>());
        }
Beispiel #36
0
 static AbstractAspectTest()
 {
     container = new CompositeContainer();
     container.Configure();
 }
Beispiel #37
0
 public ContainerAct(ContainerFixture fixture)
 {
     _fixture   = fixture ?? throw new ArgumentNullException(nameof(fixture));
     _container = fixture.ContainerUnderTest;
 }
Beispiel #38
0
 static AbstractAspectTest()
 {
     container = new CompositeContainer();
     container.Configure();
 }
Beispiel #39
0
 public ContainerAssert(ContainerFixture fixture)
 {
     _container = fixture.ContainerUnderTest;
     _fixture   = fixture;
 }
 public static void MyClassInitialize(TestContext testContext)
 {
     container = new CompositeContainer();
     container.Configure();
 }