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


C# ServiceContainer.LoadFromBaseDirectory方法代码示例

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


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

示例1: CanReturnServiceIfInitializedAndRegistered

        public void CanReturnServiceIfInitializedAndRegistered()
        {
            ServiceContainer container = new ServiceContainer();
            container.LoadFromBaseDirectory("Shaml.Data.dll");
            container.AddService("validator", typeof(IValidator), typeof(Validator), LinFu.IoC.Configuration.LifecycleType.OncePerRequest);

            ServiceLocator.SetLocatorProvider(() => new LinFuServiceLocator(container));

            IValidator validatorService = SafeServiceLocator<IValidator>.GetService();

            Assert.That(validatorService, Is.Not.Null);
        }
开发者ID:sztupy,项目名称:shaml,代码行数:12,代码来源:SafeServiceLocatorTests.cs

示例2: ShouldFindGenericMethod

        public void ShouldFindGenericMethod()
        {
            var container = new ServiceContainer();
            container.LoadFromBaseDirectory("*.dll");

            var context = new MethodFinderContext(new Type[]{typeof(object)}, new object[0], typeof(void));
            var methods = typeof(SampleClassWithGenericMethod).GetMethods(BindingFlags.Public | BindingFlags.Instance);
            var finder = container.GetService<IMethodFinder<MethodInfo>>();
            var result = finder.GetBestMatch(methods, context);

            Assert.IsTrue(result.IsGenericMethod);
            Assert.IsTrue(result.GetGenericArguments().Count() == 1);
        }
开发者ID:leehavin,项目名称:linfu,代码行数:13,代码来源:MethodFinderTests.cs

示例3: ShouldAutoInjectClassCreatedWithAutoCreate

        public void ShouldAutoInjectClassCreatedWithAutoCreate()
        {
            // Configure the container
            var container = new ServiceContainer();
            container.LoadFromBaseDirectory("*.dll");

            var sampleService = new Mock<ISampleService>();
            container.AddService(sampleService.Object);

            var instance = (SampleClassWithInjectionProperties)container.AutoCreate(typeof(SampleClassWithInjectionProperties));

            // The container should initialize the SomeProperty method to match the mock ISampleService instance
            Assert.IsNotNull(instance.SomeProperty);
            Assert.AreSame(instance.SomeProperty, sampleService.Object);
        }
开发者ID:sdether,项目名称:LinFu,代码行数:15,代码来源:PropertyInjectionTests.cs

示例4: ShouldBeAbleToRedirectInterfaceCallToTarget

        public void ShouldBeAbleToRedirectInterfaceCallToTarget()
        {
            var container = new ServiceContainer();
            container.LoadFromBaseDirectory("*.dll");

            // The duck should call the implementation instance
            var mock = new Mock<SampleDuckTypeImplementation>();
            mock.Expect(i => i.DoSomething());

            object target = mock.Object;

            var sampleService = target.CreateDuck<ISampleService>();
            sampleService.DoSomething();

            mock.VerifyAll();
        }
开发者ID:sdether,项目名称:LinFu,代码行数:16,代码来源:DuckTypingTests.cs

示例5: ShouldBeAbleToInstantiateCustomFactoryWithServiceArgumentsInConstructor

        public void ShouldBeAbleToInstantiateCustomFactoryWithServiceArgumentsInConstructor()
        {
            var mock = new Mock<ISampleService>();
            var container = new ServiceContainer();
            container.LoadFromBaseDirectory("*.dll");

            container.AddService(mock.Object);
            var result = container.GetService<string>("SampleFactoryWithConstructorArguments");

            Assert.IsNotNull(result);
            Assert.IsNotEmpty(result);
        }
开发者ID:slieser,项目名称:LinFu,代码行数:12,代码来源:FactoryTests.cs


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