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


C# Box.Resolve方法代码示例

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


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

示例1: NewPerResolveLifeStyleTestByClass

        public void NewPerResolveLifeStyleTestByClass()
        {
            var box = new Box();
            box.Register<NoDependenciesClass>(LifeStyle.NewPerResolve);

            var obj1 = box.Resolve<NoDependenciesClass>();
            var obj2 = box.Resolve<NoDependenciesClass>();
            Assert.That(ReferenceEquals(obj1, obj2), Is.False);
        }
开发者ID:aleffnull,项目名称:parmezan,代码行数:9,代码来源:LifeStyleFixture.cs

示例2: DefaultLifeStyleIsSingleForContainerByInterface

        public void DefaultLifeStyleIsSingleForContainerByInterface()
        {
            var box = new Box();
            box.Register<ISomething, Something>();

            var obj1 = box.Resolve<ISomething>();
            var obj2 = box.Resolve<ISomething>();
            Assert.That(ReferenceEquals(obj1, obj2), Is.True);
        }
开发者ID:aleffnull,项目名称:parmezan,代码行数:9,代码来源:LifeStyleFixture.cs

示例3: DefaultLifeStyleIsSingleForContainerByClass

        public void DefaultLifeStyleIsSingleForContainerByClass()
        {
            var box = new Box();
            box.Register<NoDependenciesClass>();

            var obj1 = box.Resolve<NoDependenciesClass>();
            var obj2 = box.Resolve<NoDependenciesClass>();
            Assert.That(ReferenceEquals(obj1, obj2), Is.True);
        }
开发者ID:aleffnull,项目名称:parmezan,代码行数:9,代码来源:LifeStyleFixture.cs

示例4: DifferentLifeStylesTestByInterface

        public void DifferentLifeStylesTestByInterface()
        {
            var box = new Box();
            box.Register<FirstDependencyClass>();
            box.Register<ISomethingWithDependency, SomethingWithDependency>(LifeStyle.NewPerResolve);
            box.Register<ISomething, Something>(LifeStyle.SingleForContainer);

            var obj11 = box.Resolve<ISomethingWithDependency>();
            var obj12 = box.Resolve<ISomethingWithDependency>();
            Assert.That(ReferenceEquals(obj11, obj12), Is.False);

            var obj21 = box.Resolve<ISomething>();
            var obj22 = box.Resolve<ISomething>();
            Assert.That(ReferenceEquals(obj21, obj22), Is.True);
        }
开发者ID:aleffnull,项目名称:parmezan,代码行数:15,代码来源:LifeStyleFixture.cs

示例5: DifferentLifeStylesTestByClass

        public void DifferentLifeStylesTestByClass()
        {
            var box = new Box();
            box.Register<NoDependenciesClass>(LifeStyle.NewPerResolve);
            box.Register<FirstDependencyClass>(LifeStyle.SingleForContainer);
            box.Register<OneDependencyClass>(LifeStyle.SingleForContainer);

            var obj11 = box.Resolve<NoDependenciesClass>();
            var obj12 = box.Resolve<NoDependenciesClass>();
            Assert.That(ReferenceEquals(obj11, obj12), Is.False);

            var obj21 = box.Resolve<OneDependencyClass>();
            var obj22 = box.Resolve<OneDependencyClass>();
            Assert.That(ReferenceEquals(obj21, obj22), Is.True);
        }
开发者ID:aleffnull,项目名称:parmezan,代码行数:15,代码来源:LifeStyleFixture.cs

示例6: CanResolveByInterface

        public void CanResolveByInterface()
        {
            var box = new Box();
            box.Register<ISomething, Something>();

            var resolvedObject = box.Resolve<ISomething>();
            Assert.That(resolvedObject, Is.Not.Null);
        }
开发者ID:aleffnull,项目名称:parmezan,代码行数:8,代码来源:NoDependenciesFixture.cs

示例7: CanResolveByClass

        public void CanResolveByClass()
        {
            var box = new Box();
            box.Register<NoDependenciesClass>();

            var resolvedObj = box.Resolve<NoDependenciesClass>();
            Assert.That(resolvedObj, Is.Not.Null);
        }
开发者ID:aleffnull,项目名称:parmezan,代码行数:8,代码来源:NoDependenciesFixture.cs

示例8: CanResolveClassWithOneDependencyByInterface

        public void CanResolveClassWithOneDependencyByInterface()
        {
            var box = new Box();
            box.Register<FirstDependencyClass>();
            box.Register<ISomethingWithDependency, SomethingWithDependency>();

            var obj = box.Resolve<ISomethingWithDependency>();
            Assert.That(obj, Is.Not.Null);
            Assert.That(obj.FirstDependency, Is.Not.Null);
        }
开发者ID:aleffnull,项目名称:parmezan,代码行数:10,代码来源:DependenciesFixture.cs

示例9: CanResolveClassWithOneDependency

        public void CanResolveClassWithOneDependency()
        {
            var box = new Box();
            box.Register<FirstDependencyClass>();
            box.Register<OneDependencyClass>();

            var obj = box.Resolve<OneDependencyClass>();
            Assert.That(obj, Is.Not.Null);
            Assert.That(obj.FirstDependency, Is.Not.Null);
        }
开发者ID:aleffnull,项目名称:parmezan,代码行数:10,代码来源:DependenciesFixture.cs

示例10: CanResolveClassWithTwoDependencyLevels

        public void CanResolveClassWithTwoDependencyLevels()
        {
            var box = new Box();
            box.Register<TopLevelClass>();
            box.Register<FirstLevelDependency>();
            box.Register<SecondLevelDependency>();

            var obj = box.Resolve<TopLevelClass>();
            Assert.That(obj, Is.Not.Null);
            Assert.That(obj.FirstLevelDependency, Is.Not.Null);
            Assert.That(obj.FirstLevelDependency.SecondLevelDependency, Is.Not.Null);
        }
开发者ID:aleffnull,项目名称:parmezan,代码行数:12,代码来源:DependenciesFixture.cs

示例11: ResolvingOfNotRegisteredClassThrowsException

 public void ResolvingOfNotRegisteredClassThrowsException()
 {
     var box = new Box();
     Assert.That(() => box.Resolve<NoDependenciesClass>(), Throws.InstanceOf<TypeNotFoundException>());
 }
开发者ID:aleffnull,项目名称:parmezan,代码行数:5,代码来源:NoDependenciesFixture.cs

示例12: ResolvingByClassIfRegisteredByInterfaceThrowsException

 public void ResolvingByClassIfRegisteredByInterfaceThrowsException()
 {
     var box = new Box();
     box.Register<ISomething, Something>();
     Assert.That(() => box.Resolve<Something>(), Throws.InstanceOf<TypeNotFoundException>());
 }
开发者ID:aleffnull,项目名称:parmezan,代码行数:6,代码来源:NoDependenciesFixture.cs

示例13: NewPerResolveLifeStyleTestByInterface

        public void NewPerResolveLifeStyleTestByInterface()
        {
            var box = new Box();
            box.Register<ISomething, Something>(LifeStyle.NewPerResolve);

            var obj1 = box.Resolve<ISomething>();
            var obj2 = box.Resolve<ISomething>();
            Assert.That(ReferenceEquals(obj1, obj2), Is.False);
        }
开发者ID:aleffnull,项目名称:parmezan,代码行数:9,代码来源:LifeStyleFixture.cs


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