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


C# Container.Create方法代码示例

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


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

示例1: Dependency

        public void Dependency()
        {
            var container = new Container();
            container.Bind<IRepository>().To<ConcreteRepository>();
            container.Bind<IService>().To<ConcreteService>();

            Assert.That(container.Create<IService>(), Is.TypeOf<ConcreteService>());
        }
开发者ID:RossMerr,项目名称:IoC.Hack,代码行数:8,代码来源:ContainerTests.cs

示例2: CanCreateInstanceOfConcreteTypeFromInterfaceWhenNotConfiguredIfOnlyOneImplementationExists

        public void CanCreateInstanceOfConcreteTypeFromInterfaceWhenNotConfiguredIfOnlyOneImplementationExists() {
            var container = new Container();

            var inst = container.Create<ISomeInterface>();

            Assert.IsNotNull(inst);
            Assert.IsInstanceOfType(inst, typeof(SomeClass));
        }
开发者ID:garydouble,项目名称:Acquire.NET,代码行数:8,代码来源:ContainerTests.cs

示例3: BindTo

        public void BindTo()
        {
            var container = new Container();
            container.Bind<IRepository>().To<ConcreteRepository>();

            Assert.That(container.Create<IRepository>(), Is.TypeOf<ConcreteRepository>());

        }
开发者ID:RossMerr,项目名称:IoC.Hack,代码行数:8,代码来源:ContainerTests.cs

示例4: CanCreateInstanceOfConcreteType

        public void CanCreateInstanceOfConcreteType() {
            var container = new Container();

            var inst = container.Create<SomeClass>();

            Assert.IsNotNull(inst);
            Assert.IsInstanceOfType(inst, typeof(SomeClass));
        }
开发者ID:garydouble,项目名称:Acquire.NET,代码行数:8,代码来源:ContainerTests.cs

示例5: Register

        public void Register()
        {
            var container = new Container();

            container.Register<IRepository>(() => new ConcreteRepository());

            Assert.That(container.Create<IRepository>(), Is.TypeOf<ConcreteRepository>());
            
        }
开发者ID:RossMerr,项目名称:IoC.Hack,代码行数:9,代码来源:ContainerTests.cs

示例6: CanCreateInstanceOfConcreteTypeFromInterface

        public void CanCreateInstanceOfConcreteTypeFromInterface() {
            var container = new Container();

            container.Configure<ISomeInterface>().ToUse(typeof(SomeClass));

            var inst = container.Create<ISomeInterface>();

            Assert.IsNotNull(inst);
            Assert.IsInstanceOfType(inst, typeof(SomeClass));
        }
开发者ID:garydouble,项目名称:Acquire.NET,代码行数:10,代码来源:ContainerTests.cs

示例7: Main

        private static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                args = new[] { "10", "+", "20", "-", "30", "+", "1" };
            }

            var container = new Container();
            var calculator = (ICalculator)container.Create("ICalculator");
            int result = calculator.Evaluate(args);

            Console.WriteLine(result);
        }
开发者ID:asylzhan,项目名称:IoCTasksSolutions,代码行数:13,代码来源:Program.cs

示例8: CanCreateInstanceUsingConstructorInjection

        public void CanCreateInstanceUsingConstructorInjection() {
            var container = new Container();
            
            var A = container.Create<A>();

            Assert.IsNotNull(A);
            Assert.IsNotNull(A.B);
            Assert.IsNotNull(A.B.C);
        }
开发者ID:garydouble,项目名称:Acquire.NET,代码行数:9,代码来源:ContainerTests.cs

示例9: ThrowsExceptionWhenNotConfiguredAndMoreThanOneImplementationExists

        public void ThrowsExceptionWhenNotConfiguredAndMoreThanOneImplementationExists() {
            var container = new Container();

            var inst = container.Create<IManyInterface>();
        }
开发者ID:garydouble,项目名称:Acquire.NET,代码行数:5,代码来源:ContainerTests.cs

示例10: ThrowsExceptionWhenNotConfiguredAndNoImplementationsExists

        public void ThrowsExceptionWhenNotConfiguredAndNoImplementationsExists() {
            var container = new Container();

            var inst = container.Create<INoneInterface>();
        }
开发者ID:garydouble,项目名称:Acquire.NET,代码行数:5,代码来源:ContainerTests.cs


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