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


C# Container.AllowResolvingParameterizedFuncFactories方法代码示例

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


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

示例1: AllowResolvingParameterizedFuncFactories_WithParametersInIncorrectOrder_ThrowExpectedException

        public void AllowResolvingParameterizedFuncFactories_WithParametersInIncorrectOrder_ThrowExpectedException()
        {
            // Arrange
            var container = new Container();

            container.AllowResolvingParameterizedFuncFactories();

            container.Register<ILogger, NullLogger>(Lifestyle.Singleton);
            container.Register<ICommand, ConcreteCommand>();

            // Act
            Action action = () => container.GetInstance<Func<int, string, Tuple<ILogger, string, int>>>();

            // Assert
            AssertThat.Throws<ActivationException>(action);
        }
开发者ID:jamesqo,项目名称:SimpleInjector,代码行数:16,代码来源:ResolvingFactoriesExtensionsTests.cs

示例2: AllowResolvingParameterizedFuncFactories_WithDependencies_PrevervesLifestyles

        public void AllowResolvingParameterizedFuncFactories_WithDependencies_PrevervesLifestyles()
        {
            // Arrange
            var container = new Container();

            container.AllowResolvingParameterizedFuncFactories();

            container.Register<ILogger, NullLogger>(Lifestyle.Singleton);
            container.Register<ICommand, ConcreteCommand>();

            // Act
            var tupleFactory = container.GetInstance<Func<string, Tuple<ILogger, string, ICommand>>>();

            var tuple1 = tupleFactory(null);
            var tuple2 = tupleFactory(null);

            // Assert
            Assert.AreSame(tuple1.Item1, tuple2.Item1, "Logger is expected to be singleton");
            Assert.AreNotSame(tuple1.Item3, tuple2.Item3, "Command is expected to be transient");
        }
开发者ID:jamesqo,项目名称:SimpleInjector,代码行数:20,代码来源:ResolvingFactoriesExtensionsTests.cs

示例3: AllowResolvingParameterizedFuncFactories_ResolvingTypeWithOneDependencyAsLastCtorParameter_Succeeds

        public void AllowResolvingParameterizedFuncFactories_ResolvingTypeWithOneDependencyAsLastCtorParameter_Succeeds()
        {
            // Arrange
            var container = new Container();

            container.AllowResolvingParameterizedFuncFactories();

            container.Register<ILogger, NullLogger>();

            // Act
            var tupleFactory = container.GetInstance<Func<int, string, Tuple<int, string, ILogger>>>();

            var tuple = tupleFactory(0, null);

            // Assert
            AssertThat.IsInstanceOfType(typeof(ILogger), tuple.Item3);
        }
开发者ID:jamesqo,项目名称:SimpleInjector,代码行数:17,代码来源:ResolvingFactoriesExtensionsTests.cs

示例4: Container

        public void AllowResolvingParameterizedFuncFactories_ResolvingTypeWithOneDependencyAtBothSidesOfCtorParameterList_Succeeds()
        {
            // Arrange
            var container = new Container();

            container.AllowResolvingParameterizedFuncFactories();

            container.Register<ILogger, NullLogger>();
            container.Register<ICommand, ConcreteCommand>();

            // Act
            var tupleFactory = container.GetInstance<Func<int, string, Tuple<ILogger, int, string, ICommand>>>();

            var tuple = tupleFactory(0, null);

            // Assert
            AssertThat.IsInstanceOfType(typeof(NullLogger), tuple.Item1);
            AssertThat.IsInstanceOfType(typeof(ConcreteCommand), tuple.Item4);
        }
开发者ID:jamesqo,项目名称:SimpleInjector,代码行数:19,代码来源:ResolvingFactoriesExtensionsTests.cs

示例5: AllowResolvingParameterizedFuncFactories_ResolvingTypeWithoutDependencies_Succeeds

        public void AllowResolvingParameterizedFuncFactories_ResolvingTypeWithoutDependencies_Succeeds()
        {
            // Arrange
            var container = new Container();

            container.AllowResolvingParameterizedFuncFactories();

            // Act
            var tupleFactory = container.GetInstance<Func<int, string, Tuple<int, string>>>();

            var tuple = tupleFactory(1, "foo");

            // Assert
            Assert.AreEqual(1, tuple.Item1);
            Assert.AreEqual("foo", tuple.Item2);
        }
开发者ID:jamesqo,项目名称:SimpleInjector,代码行数:16,代码来源:ResolvingFactoriesExtensionsTests.cs


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