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


C# Registry.Scan方法代码示例

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


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

示例1: FindRegistriesWithinPluginGraphSeal

        public void FindRegistriesWithinPluginGraphSeal()
        {
            var builder = new PluginGraphBuilder();
            var registry = new Registry();
            registry.Scan(x =>
            {
                x.AssemblyContainingType(typeof(RedGreenRegistry));
                x.LookForRegistries();
            });
            builder.AddConfiguration(registry);

            var graph = builder.Build();

            var colors = new List<string>();
            PluginFamily family = graph.FindFamily(typeof (IWidget));

            family.Instances.Each(instance => colors.Add(instance.Name));

            Assert.Contains("Red", colors);
            Assert.Contains("Green", colors);
            Assert.Contains("Yellow", colors);
            Assert.Contains("Blue", colors);
            Assert.Contains("Brown", colors);
            Assert.Contains("Black", colors);
        }
开发者ID:satish860,项目名称:StructureMap3,代码行数:25,代码来源:RegistryIntegratedTester.cs

示例2: 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

示例3: Test_Registry_Scan

 public void Test_Registry_Scan()
 {
     Registry registry1 = new Registry();
     registry1.Scan(scanner => {
         // scanner.Assembly("FruitImplementations");
         scanner.AssemblyContainingType<Output>();
         scanner.WithDefaultConventions();
     });
     Container con1 = new Container(registry1);
     IOutput output1 = con1.GetInstance<IOutput>();
     IOutput output2 = con1.GetInstance<IOutput>();
     Assert.AreNotSame(output1, output2);
 }
开发者ID:ezeh2,项目名称:ezeh2.github.io,代码行数:13,代码来源:Fruit_Test.cs

示例4: SetUp

        public void SetUp()
        {
            var registry = new Registry();
            registry.For<Rule>();
            registry.Scan(x => {
                x.Assembly("StructureMap.Testing.Widget");
                x.Assembly("StructureMap.Testing.Widget2");
            });

            var graph = registry.Build();

            _session = BuildSession.ForPluginGraph(graph);
        }
开发者ID:goraw,项目名称:structuremap,代码行数:13,代码来源:ConfiguredInstanceTester.cs

示例5: CreateRegistry

        private static Registry CreateRegistry()
        {
            var registry = new Registry();

            // setups DI for everything in Noobot.Core
            registry.Scan(x =>
            {
                x.TheCallingAssembly();
                x.WithDefaultConventions();
            });

            return registry;
        }
开发者ID:group6tech,项目名称:noobot,代码行数:13,代码来源:ContainerFactory.cs

示例6: ConfiguredInstanceTester

        public ConfiguredInstanceTester()
        {
            var registry = new Registry();
            registry.For<Rule>();
            registry.Scan(x =>
            {
                x.Assembly("StructureMap.Testing.Widget");
                x.Assembly("StructureMap.Testing.Widget2");

                x.WithDefaultConventions();
            });

            var graph = registry.Build();

            _session = BuildSession.ForPluginGraph(graph);
        }
开发者ID:khellang,项目名称:structuremap,代码行数:16,代码来源:ConfiguredInstanceTester.cs

示例7: CanMakeAClassWithNoConstructorParametersWithoutADefinedMemento

        public void CanMakeAClassWithNoConstructorParametersWithoutADefinedMemento()
        {
            var registry = new Registry();
            registry.Scan(x => x.Assembly("StructureMap.Testing.Widget3"));

            registry.BuildInstancesOf<IGateway>();

            PluginGraph graph = registry.Build();
            var pipelineGraph = new PipelineGraph(graph);

            var session = new BuildSession(graph);

            var gateway =
                (DefaultGateway) session.CreateInstance(typeof (IGateway), "Default");

            Assert.IsNotNull(gateway);
        }
开发者ID:hp4711,项目名称:structuremap,代码行数:17,代码来源:InstanceFactoryTester.cs

示例8: SetUp

        public void SetUp()
        {
            var registry = new Registry();
            registry.BuildInstancesOf<Rule>();
            registry.Scan(x =>
            {
                x.Assembly("StructureMap.Testing.Widget");
                x.Assembly("StructureMap.Testing.Widget2");
            });

            PluginGraph graph = registry.Build();

            var pipelineGraph = new PipelineGraph(graph);
            _session = new BuildSession(pipelineGraph, graph.InterceptorLibrary);
        }
开发者ID:joshuaflanagan,项目名称:structuremap,代码行数:15,代码来源:ConfiguredInstanceTester.cs

示例9: SetupMiddlewarePipeline

        private void SetupMiddlewarePipeline(Registry registry)
        {
            Stack<Type> pipeline = GetPipelineStack();

            registry.Scan(x =>
            {
                // scan assemblies that we are loading pipelines from
                foreach (Type middlewareType in pipeline)
                {
                    x.AssemblyContainingType(middlewareType);
                }
            });

            registry.For<IMiddleware>().Use<UnhandledMessageMiddleware>();

            // defined here so they can be overridden
            registry.For<IMiddleware>().DecorateAllWith<AboutMiddleware>();
            registry.For<IMiddleware>().DecorateAllWith<StatsMiddleware>();

            while (pipeline.Any())
            {
                Type nextType = pipeline.Pop();
                var nextDeclare = registry.For<IMiddleware>();

                // using reflection as Structuremap doesn't allow passing types in at the moment :-(
                MethodInfo decorateMethod = nextDeclare.GetType().GetMethod("DecorateAllWith", new[] { typeof(Func<Instance, bool>) });
                MethodInfo generic = decorateMethod.MakeGenericMethod(nextType);
                generic.Invoke(nextDeclare, new object[] { null });
            }

            if (_configReader.HelpEnabled())
            {
                registry.For<IMiddleware>().DecorateAllWith<HelpMiddleware>();
            }
            registry.For<IMiddleware>().DecorateAllWith<BeginMessageMiddleware>();
        }
开发者ID:group6tech,项目名称:noobot,代码行数:36,代码来源:ContainerFactory.cs

示例10: SetupPlugins

        private Type[] SetupPlugins(Registry registry)
        {
            var pluginTypes = new List<Type>
            {
                typeof (StatsPlugin)
            };

            Type[] customPlugins = _configuration.ListPluginTypes() ?? new Type[0];
            pluginTypes.AddRange(customPlugins);

            registry.Scan(x =>
            {
                // scan assemblies that we are loading pipelines from
                foreach (Type pluginType in pluginTypes)
                {
                    x.AssemblyContainingType(pluginType);
                    x.WithDefaultConventions();
                }
            });

            // make all plugins singletons
            foreach (Type pluginType in pluginTypes)
            {
                registry
                    .For(pluginType)
                    .Singleton();
            }

            return pluginTypes.ToArray();
        }
开发者ID:group6tech,项目名称:noobot,代码行数:30,代码来源:ContainerFactory.cs

示例11: TheDefaultInstanceIsPickedUpFromTheAttribute

        public void TheDefaultInstanceIsPickedUpFromTheAttribute()
        {
            var registry = new Registry();
            registry.BuildInstancesOf<IGateway>();
            registry.Scan(x => x.AssemblyContainingType<IGateway>());

            PluginGraph pluginGraph = registry.Build();

            Assert.IsTrue(pluginGraph.ContainsFamily(typeof (IGateway)));

            var manager = new Container(pluginGraph);
            var gateway = (IGateway) manager.GetInstance(typeof (IGateway));

            Assert.IsInstanceOfType(typeof (DefaultGateway), gateway);
        }
开发者ID:joshuaflanagan,项目名称:structuremap,代码行数:15,代码来源:CreatePluginFamilyTester.cs

示例12: GotPluginsThatAreMarkedAsPluggable

        public void GotPluginsThatAreMarkedAsPluggable()
        {
            var registry = new Registry();
            registry.Scan(x => x.AssemblyContainingType<IWidget>());

            registry.BuildInstancesOf<IWidget>();
            PluginGraph pluginGraph = registry.Build();

            PluginFamily pluginFamily = pluginGraph.FindFamily(typeof (IWidget));
            Plugin plugin = pluginFamily.FindPlugin(typeof (ColorWidget));
            Assert.IsNotNull(plugin);
        }
开发者ID:hp4711,项目名称:structuremap,代码行数:12,代码来源:PluginGraphBuilderTester.cs


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