当前位置: 首页>>代码示例>>C#>>正文


C# UnityContainer.ResolveAll方法代码示例

本文整理汇总了C#中UnityContainer.ResolveAll方法的典型用法代码示例。如果您正苦于以下问题:C# UnityContainer.ResolveAll方法的具体用法?C# UnityContainer.ResolveAll怎么用?C# UnityContainer.ResolveAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityContainer的用法示例。


在下文中一共展示了UnityContainer.ResolveAll方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ContainerReturnsEmptyArrayIfNoObjectsRegistered

        public void ContainerReturnsEmptyArrayIfNoObjectsRegistered()
        {
            IUnityContainer container = new UnityContainer();
            List<object> results = new List<object>(container.ResolveAll<object>());

            Assert.IsNotNull(results);
            CollectionAssert.AreEqual(new object[0], results);
        }
开发者ID:theoju,项目名称:CleanCode,代码行数:8,代码来源:ResolvingArraysFixture.cs

示例2: ResolveAllReturnsRegisteredObjectsForBaseClass

        public void ResolveAllReturnsRegisteredObjectsForBaseClass()
        {
            IUnityContainer container = new UnityContainer();
            ILogger o1 = new MockLogger();
            ILogger o2 = new SpecialLogger();

            container
                .RegisterInstance<ILogger>("o1", o1)
                .RegisterInstance<ILogger>("o2", o2);

            List<ILogger> results = new List<ILogger>(container.ResolveAll<ILogger>());
            CollectionAssert.AreEqual(new ILogger[] {o1, o2}, results);
        }
开发者ID:jorgeds001,项目名称:CodeSamples,代码行数:13,代码来源:ResolvingArraysFixture.cs

示例3: ResolveAllReturnsRegisteredObjects

        public void ResolveAllReturnsRegisteredObjects()
        {
            IUnityContainer container = new UnityContainer();
            object o1 = new object();
            object o2 = new object();

            container
                .RegisterInstance<object>("o1", o1)
                .RegisterInstance<object>("o2", o2);

            List<object> results = new List<object>(container.ResolveAll<object>());

            CollectionAssert.AreEqual(new object[] { o1, o2 }, results);
        }
开发者ID:theoju,项目名称:CleanCode,代码行数:14,代码来源:ResolvingArraysFixture.cs

示例4: CanSetUpAnEmptyRule

        public void CanSetUpAnEmptyRule()
        {
            // there is no visible effect for this, but it should still be resolved.
            IUnityContainer container = new UnityContainer();
            container.AddNewExtension<Interception>();

            // empty
            container
                .Configure<Interception>()
                    .AddPolicy("policy1");

            List<InjectionPolicy> policies
                = new List<InjectionPolicy>(container.ResolveAll<InjectionPolicy>());

            Assert.AreEqual(2, policies.Count);
            Assert.IsInstanceOfType(policies[0], typeof(AttributeDrivenPolicy));
            Assert.IsInstanceOfType(policies[1], typeof(RuleDrivenPolicy));
            Assert.AreEqual("policy1", policies[1].Name);
        }
开发者ID:shhyder,项目名称:MapApplication,代码行数:19,代码来源:ConvenienceConfigurationFixture.cs

示例5: CanRegisterFactoryFunctionThatReceivesTypeAndName

        public void CanRegisterFactoryFunctionThatReceivesTypeAndName()
        {
            Func<IUnityContainer, Type, string, object> factory = (c, t, s) => s + t.Name;
            var container = new UnityContainer()
                .RegisterType<string>("one", new InjectionFactory(factory))
                .RegisterType<string>("two", new InjectionFactory(factory))
                .RegisterType<string>("three", new InjectionFactory(factory));

            var result = container.ResolveAll<string>();
            result.AssertContainsInAnyOrder("oneString", "twoString", "threeString");
        }
开发者ID:jorgeds001,项目名称:CodeSamples,代码行数:11,代码来源:StaticFactoryFixture.cs

示例6: RegisteredFactoriesAreExecutedWhenDoingResolveAll

        public void RegisteredFactoriesAreExecutedWhenDoingResolveAll()
        {
            var container = new UnityContainer()
                .RegisterType<string>("one", new InjectionFactory(c => "this"))
                .RegisterType<string>("two", new InjectionFactory(c => "that"))
                .RegisterType<string>("three", new InjectionFactory(c => "the other"));

            var result = container.ResolveAll<string>();
            result.AssertContainsInAnyOrder("this", "that", "the other");
        }
开发者ID:jorgeds001,项目名称:CodeSamples,代码行数:10,代码来源:StaticFactoryFixture.cs

示例7: RegisteredFactoriesAreExecutedWhenDoingResolveAllWithOldAPI

        public void RegisteredFactoriesAreExecutedWhenDoingResolveAllWithOldAPI()
        {
            var container = new UnityContainer()
                .AddNewExtension<StaticFactoryExtension>()
                .Configure<StaticFactoryExtension>()
                    .RegisterFactory<string>("one", c => "this")
                    .RegisterFactory<string>("two", c => "that" )
                    .RegisterFactory<string>("three", c => "the other")
                .Container;

            var result = container.ResolveAll<string>();
            result.AssertContainsInAnyOrder("this", "that", "the other");
        }
开发者ID:jorgeds001,项目名称:CodeSamples,代码行数:13,代码来源:StaticFactoryFixture.cs


注:本文中的UnityContainer.ResolveAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。