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


C# DefaultKernel.CreateComponentActivator方法代码示例

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


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

示例1: LeaseIsCorrectWhenAccessedAfterInitializationButNoLeaseIsAvailableInKernel

        public void LeaseIsCorrectWhenAccessedAfterInitializationButNoLeaseIsAvailableInKernel()
        {
            // Fixture setup
            var kernel = new DefaultKernel();
            var model = new ComponentModel("foo", typeof(ICloneable), typeof(Version));
            var activator = kernel.CreateComponentActivator(model);

            var sut = new CacheLifestyleManager();
            sut.Init(activator, kernel, model);
            // Exercise system
            var result = sut.Lease;
            // Verify outcome
            var actual = Assert.IsAssignableFrom<SlidingLease>(result);
            Assert.Equal(TimeSpan.FromMinutes(1), actual.Timeout);
            // Teardown
        }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:16,代码来源:CacheLifestyleManagerFacts.cs

示例2: LeaseIsCorrectWhenAccessedAfterInitializationWhenLeaseIsAvailabeInKernel

        public void LeaseIsCorrectWhenAccessedAfterInitializationWhenLeaseIsAvailabeInKernel()
        {
            // Fixture setup
            var kernel = new DefaultKernel();
            var model = new ComponentModel("foo", typeof(ICloneable), typeof(Version));
            var activator = kernel.CreateComponentActivator(model);

            var expectedLease = new Mock<ILease> { DefaultValue = DefaultValue.Mock }.Object;
            kernel.Register(Component.For<ILease>().Instance(expectedLease));

            var sut = new CacheLifestyleManager();
            sut.Init(activator, kernel, model);
            // Exercise system
            var result = sut.Lease;
            // Verify outcome
            Assert.Equal(expectedLease, result);
            // Teardown
        }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:18,代码来源:CacheLifestyleManagerFacts.cs

示例3: ResolveOnceReturnsCorrectResult

        public void ResolveOnceReturnsCorrectResult()
        {
            // Fixture setup
            var kernel = new DefaultKernel();
            var model = new ComponentModel("foo", typeof(ICloneable), typeof(Version));
            var activator = kernel.CreateComponentActivator(model);

            var sut = new CacheLifestyleManager();
            sut.Init(activator, kernel, model);
            // Exercise system
            var result = sut.Resolve(CreationContext.Empty);
            // Verify outcome
            Assert.IsAssignableFrom<Version>(result);
            // Teardown
        }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:15,代码来源:CacheLifestyleManagerFacts.cs

示例4: ReleaseWrongObjectWillNotReleaseInstance

        public void ReleaseWrongObjectWillNotReleaseInstance()
        {
            // Fixture setup
            var kernel = new DefaultKernel();
            var model = new ComponentModel("foo", typeof(ICloneable), typeof(Version));
            var activator = kernel.CreateComponentActivator(model);

            var leaseMock = new Mock<ILease> { DefaultValue = DefaultValue.Mock };
            kernel.Register(Component.For<ILease>().Instance(leaseMock.Object));

            var sut = new CacheLifestyleManager();
            sut.Init(activator, kernel, model);

            var first = sut.Resolve(CreationContext.Empty);
            // Exercise system
            sut.Release(new object());
            // Verify outcome
            var second = sut.Resolve(CreationContext.Empty);
            Assert.Same(first, second);
            // Teardown
        }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:21,代码来源:CacheLifestyleManagerFacts.cs

示例5: ResolveWillReturnNewInstanceWhenLeaseExpires

        public void ResolveWillReturnNewInstanceWhenLeaseExpires()
        {
            // Fixture setup
            var kernel = new DefaultKernel();
            var model = new ComponentModel("foo", typeof(ICloneable), typeof(Version));
            var activator = kernel.CreateComponentActivator(model);

            var expired = false;
            var leaseStub = new Mock<ILease> { DefaultValue = DefaultValue.Mock };
            leaseStub.Setup(l => l.IsExpired).Returns(() =>
                {
                    var b = expired;
                    expired = !expired;
                    return b;
                });
            kernel.Register(Component.For<ILease>().Instance(leaseStub.Object));

            var sut = new CacheLifestyleManager();
            sut.Init(activator, kernel, model);
            // Exercise system
            var first = sut.Resolve(CreationContext.Empty);
            var second = sut.Resolve(CreationContext.Empty);
            // Verify outcome
            Assert.NotSame(first, second);
            // Teardown
        }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:26,代码来源:CacheLifestyleManagerFacts.cs

示例6: MultipleResolvesWillOnlyRenewOnce

        public void MultipleResolvesWillOnlyRenewOnce()
        {
            // Fixture setup
            var kernel = new DefaultKernel();
            var model = new ComponentModel("foo", typeof(ICloneable), typeof(Version));
            var activator = kernel.CreateComponentActivator(model);

            var leaseMock = new Mock<ILease> { DefaultValue = DefaultValue.Mock };
            kernel.Register(Component.For<ILease>().Instance(leaseMock.Object));

            var sut = new CacheLifestyleManager();
            sut.Init(activator, kernel, model);
            // Exercise system
            sut.Resolve(CreationContext.Empty);
            sut.Resolve(CreationContext.Empty);
            // Verify outcome
            leaseMock.Verify(l => l.Renew(), Times.Once());
            // Teardown
        }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:19,代码来源:CacheLifestyleManagerFacts.cs

示例7: ResolveTwiceReturnsSame

        public void ResolveTwiceReturnsSame()
        {
            // Fixture setup
            var kernel = new DefaultKernel();
            var model = new ComponentModel("foo", typeof(ICloneable), typeof(Version));
            var activator = kernel.CreateComponentActivator(model);

            var sut = new CacheLifestyleManager();
            sut.Init(activator, kernel, model);
            // Exercise system
            var first = sut.Resolve(CreationContext.Empty);
            var second = sut.Resolve(CreationContext.Empty);
            // Verify outcome
            Assert.Same(first, second);
            // Teardown
        }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:16,代码来源:CacheLifestyleManagerFacts.cs


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