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


C# Registry.For方法代码示例

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


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

示例1: Generate

        public INoobotContainer Generate()
        {
            var registry = new Registry();

            registry.Scan(x =>
            {
                x.TheCallingAssembly();
                x.WithDefaultConventions();
            });

            registry = _pipelineManager.Initialise(registry);
            registry = _pluginManager.Initialise(registry);

            registry
                .For<ISlackWrapper>()
                .Singleton();

            registry
                .For<IPipelineFactory>()
                .Singleton();

            Type[] pluginTypes = _pluginManager.ListPluginTypes();
            var container = new NoobotContainer(registry, pluginTypes);

            IPipelineFactory pipelineFactory = container.GetInstance<IPipelineFactory>();
            pipelineFactory.SetContainer(container);

            return container;
        }
开发者ID:irmbrady,项目名称:noobot,代码行数:29,代码来源:ContainerGenerator.cs

示例2: ConfigureModuleSpecificDependencies

 private static void ConfigureModuleSpecificDependencies(Registry registry)
 {
     registry.For<IMasslogConfiguration>().Singleton().Use<LoggingConfiguration>();
     registry.For<ILoggingConfiguration>().Singleton().Use<LoggingConfiguration>();
     registry.For<IMonitorBehaviorFactory>().Singleton().Use<MonitorBehaviorFactory>();
     registry.For<IMonitor>().HttpContextScoped().Use<Monitor>();
 }
开发者ID:ByteCarrot,项目名称:Masslog,代码行数:7,代码来源:LoggingModuleIoC.cs

示例3: RegisterCommand

        public void RegisterCommand(Registry registry)
        {
            var openCommandMethodResultType = typeof(CommandResult<>);
            var closedCommandMethodResultType = openCommandMethodResultType.MakeGenericType(CommandType);

            var openActionMethodInvokerType = typeof(IActionMethodResultInvoker<>);
            var closedActionMethodInvokerType =
                openActionMethodInvokerType.MakeGenericType(closedCommandMethodResultType);

            var closedDomainResultType = typeof(CommandResult);

            var openCommandMethodResultInvokerType = typeof(ResultInvoker<,>);
            var closedCommandMethodResultInvokerType =
                openCommandMethodResultInvokerType.MakeGenericType(closedCommandMethodResultType, closedDomainResultType);

            registry.For(closedActionMethodInvokerType).Use(closedCommandMethodResultInvokerType);

            var openResultProcessor = typeof(IResultProcessor<,>);
            var closedResultProcessor =
                openResultProcessor.MakeGenericType(closedCommandMethodResultType, closedDomainResultType);

            var openCommandMethodResultProcessorType = typeof(CommandResultProcessor<>);
            var closedCommandMethodResultProcessorType =
                openCommandMethodResultProcessorType.MakeGenericType(CommandType);

            registry.For(closedResultProcessor).Use(closedCommandMethodResultProcessorType);
        }
开发者ID:basicdays,项目名称:Guidelines,代码行数:27,代码来源:MvcCommandRegistrar.cs

示例4: LoadApplicationBusImplementations

        private static void LoadApplicationBusImplementations(Registry registry)
        {
            registry.For<IApplicationBus>()
                .Singleton().Use<ApplicationBus>();

            registry.For<IMessageHandlerFactory>()
                .Use<StructureMapMessageHandlerFactory>();
        }
开发者ID:darrencauthon,项目名称:warmup,代码行数:8,代码来源:ContainerBuilder.cs

示例5: Process

 public void Process(Type type, Registry registry) {
     if (type.CanBeCastTo<Controller>() && !type.IsAbstract) {
         registry.For(type).LifecycleIs(new UniquePerRequestLifecycle());
     }
     else if (type.CanBeCastTo<ApiController>() && !type.IsAbstract)
     {
         registry.For(type).LifecycleIs(new UniquePerRequestLifecycle());
     }
 }
开发者ID:NemeStats,项目名称:NemeStats,代码行数:9,代码来源:ControllerConvention.cs

示例6: CreateServiceLocator

        protected override IServiceLocator CreateServiceLocator()
        {
            var registry = new Registry();
            registry.For<ILogger>().Use<AdvancedLogger>();
            registry.For<ILogger>().Use(new SimpleLogger()).Named(typeof(SimpleLogger).FullName);
            registry.For<ILogger>().Use(new AdvancedLogger()).Named(typeof(AdvancedLogger).FullName);
            IContainer container = new Container(registry);

            return new StructureMapAdapter(container);
        }
开发者ID:ssethi,项目名称:TestFrameworks,代码行数:10,代码来源:The_StructureMap_container.cs

示例7: RegisterDependencies

        public static Registry RegisterDependencies()
        {
            if (_hasBeenCalled) return _registry;
            _registry = new Registry();

            _registry.For<IEnvironment>().Use<Environment>();
            _registry.For<IDatabaseConnection>().Use<DatabaseConnection>();

            _hasBeenCalled = true;
            return _registry;
        }
开发者ID:peterbartels,项目名称:GenForm,代码行数:11,代码来源:DatabaseRegistrationAssembler.cs

示例8: Test_Singleton

        public void Test_Singleton()
        {
            Registry registry1 = new Registry();
            registry1.For<IOutput>().Use<Output>().Singleton();
            registry1.For<IFruit>().Use<Apple>();

            Container con1 = new Container(registry1);
            IOutput output1 = con1.GetInstance<IOutput>();
            IOutput output2 = con1.GetInstance<IOutput>();
            Assert.AreSame(output1, output2);
        }
开发者ID:ezeh2,项目名称:ezeh2.github.io,代码行数:11,代码来源:Fruit_Test.cs

示例9: RegisterDependencies

        public static Registry RegisterDependencies()
        {
            if (_hasBeenCalled) return _registry;
            _registry = new Registry();

            _registry.For<IDatabaseServices>().Use<DatabaseServices>();
            _registry.For<IDatabaseSetting>().Use<DatabaseSetting>();
            _registry.For<IDatabaseConnection>().Use<DatabaseConnection>();

            _hasBeenCalled = true;
            return _registry;
        }
开发者ID:halcwb,项目名称:GenPres_Old,代码行数:12,代码来源:DatabaseRegistrationAssembler.cs

示例10: Process

        public void Process(Type type, Registry registry)
        {
            if (!type.IsSubclassOf(typeof(Entity))) return;

            var openQueryModelBinder = typeof (QueryableModelBinder<>);
            var closedQueryModelBinder = openQueryModelBinder.MakeGenericType(type);

            var openIdToEntityModelBinder = typeof (IdToEntityModelBinder<>);
            var closedIdToEntityModelBinder = openIdToEntityModelBinder.MakeGenericType(type);

            registry.For(typeof(IFilteredModelBinder)).Use(closedQueryModelBinder);
            registry.For(typeof(IFilteredModelBinder)).Use(closedIdToEntityModelBinder);
        }
开发者ID:adargel,项目名称:wedomvc,代码行数:13,代码来源:EntityModelBinderConventions.cs

示例11: ScanTypes

 public void ScanTypes(TypeSet types, Registry registry)
 {
     foreach(var type in types.FindTypes(TypeClassification.Concretes | TypeClassification.Closed))
     {
         if (type.CanBeCastTo<Controller>() && !type.IsAbstract)
         {
             registry.For(type).LifecycleIs(new UniquePerRequestLifecycle());
         }
         else if (type.CanBeCastTo<ApiController>() && !type.IsAbstract)
         {
             registry.For(type).LifecycleIs(new UniquePerRequestLifecycle());
         }
     }
 }
开发者ID:NemeStats,项目名称:NemeStats,代码行数:14,代码来源:ControllerConvention.cs

示例12: Process

        public void Process(Type type, Registry registry)
        {
            // Only work on concrete types
            if (!type.IsConcrete() || type.IsGenericType) return;

            // Add against all the interfaces implemented
            // by this concrete class
            type.GetInterfaces()
                .Where(@interface => @interface.Name == $"I{type.Name}" )
                .ForEach(@interface => registry.For(@interface).Use(type).Singleton());

            if (type.Name.EndsWith("Job"))
                registry.For(type).Singleton();
        }
开发者ID:RomanBlyshchyk,项目名称:TailBlazer,代码行数:14,代码来源:AppConventions.cs

示例13: ScanTypes

        public void ScanTypes(TypeSet types, Registry registry)
        {
            // Only work on concrete types
            types.FindTypes(TypeClassification.Concretes | TypeClassification.Closed).ForEach(type =>
            {

                type.GetInterfaces()
                    .Where(@interface => @interface.Name == $"I{type.Name}")
                    .ForEach(@interface => registry.For(@interface).Use(type).Singleton());

                if (type.Name.EndsWith("Job"))
                    registry.For(type).Singleton();
            });
        }
开发者ID:mgnslndh,项目名称:TailBlazer,代码行数:14,代码来源:AppConventions.cs

示例14: Apply

        public void Apply(PluginGraph graph)
        {
            var registry = new Registry();

            _interfaces.Each(@interface =>
            {
                var expression = registry.For(@interface);
                ConfigureFamily(expression);

                var exactMatches = _concretions.Where(x => x.CanBeCastTo(@interface)).ToArray();
                if (exactMatches.Length == 1)
                {
                    expression.Use(exactMatches.Single());
                }
                else
                {
                    exactMatches.Each(type => expression.Add(type));
                }


                if ([email protected]())
                {
                    addConcretionsThatCouldBeClosed(@interface, expression);
                }
            });

            _concretions.Each(t => graph.ConnectedConcretions.Fill(t));
            registry.As<IPluginGraphConfiguration>().Configure(graph);
        }
开发者ID:goraw,项目名称:structuremap,代码行数:29,代码来源:GenericConnectionScanner.cs

示例15: Test_GetAllInstances

        public void Test_GetAllInstances()
        {
            Registry registry1 = new Registry();
            registry1.For<IOutput>().Use<Output>().Singleton();
            registry1.For<IFruit>().Use<Apple>();

            Container con1 = new Container(registry1);

            Type t1 = typeof(IOutput);
            Assert.AreEqual(1, ConvertToList(con1, t1).Count);
            Assert.AreEqual(1, ConvertToList(con1, t1).Count);

            Type t2 = typeof(Apple);
            Assert.AreEqual(0, ConvertToList(con1, t2).Count);
            Assert.AreEqual(0, ConvertToList(con1, t2).Count);
        }
开发者ID:ezeh2,项目名称:ezeh2.github.io,代码行数:16,代码来源:Fruit_Test.cs


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