コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: PluginGraph.cs プロジェクト: sami1971/structuremap
        /// <summary>
        ///   Add configuration to a PluginGraph with the Registry DSL
        /// </summary>
        /// <param name = "action"></param>
        public void Configure(Action <Registry> action)
        {
            var registry = new Registry();

            action(registry);

            registry.As <IPluginGraphConfiguration>().Configure(this);
        }
コード例 #4
0
        public void ScanForTypes(TypePool types, PluginGraph pluginGraph)
        {
            var registry = new Registry();

            types.For(_assemblies, _filter).Each(
                type => _conventions.Each(c => c.Process(type, registry)));

            registry.As <IPluginGraphConfiguration>().Configure(pluginGraph);
            _postScanningActions.Each(x => x(pluginGraph));
        }
コード例 #5
0
        public void ScanForTypes(PluginGraph pluginGraph)
        {
            var registry = new Registry();

            TypeRepository.FindTypes(_assemblies, TypeClassification.All, _filter.Matches)
            .ContinueWith(t =>
            {
                t.Result.Each(type => _conventions.Each(c => c.Process(type, registry)));
            }).Wait();

            registry.As <IPluginGraphConfiguration>().Configure(pluginGraph);
            _postScanningActions.Each(x => x(pluginGraph));
        }
コード例 #6
0
        public void Apply(PluginGraph graph)
        {
            var registry = new Registry();

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

                _concretions.Where(x => x.CanBeCastTo(@interface)).Each(type => expression.Add(type));
            });

            registry.As <IPluginGraphConfiguration>().Configure(graph);
        }
コード例 #7
0
        public void Apply(PluginGraph graph)
        {
            var registry = new Registry();

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

                _concretions.Where(x => x.CanBeCastTo(@interface)).Each(type => expression.Add(type));
            });

            registry.As<IPluginGraphConfiguration>().Configure(graph);
        }
コード例 #8
0
        public void Process_to_PluginGraph()
        {
            var graph   = new PluginGraph();
            var scanner = new DefaultConventionScanner();

            var registry = new Registry();

            scanner.Process(typeof(Convention), registry);

            registry.As <IPluginGraphConfiguration>().Configure(graph);

            graph.Families.Has(typeof(IServer)).ShouldBeFalse();
            graph.Families.Has(typeof(IConvention)).ShouldBeTrue();

            var family = graph.Families[typeof(IConvention)];

            family.Instances.Count().ShouldBe(1);
        }
コード例 #9
0
ファイル: PluginGraph.cs プロジェクト: rhyss/structuremap
        /// <summary>
        ///   Add configuration to a PluginGraph with the Registry DSL
        /// </summary>
        /// <param name = "action"></param>
        public void Configure(Action<Registry> action)
        {
            var registry = new Registry();
            action(registry);

            registry.As<IPluginGraphConfiguration>().Configure(this);
        }
コード例 #10
0
        public void Process_to_PluginGraph()
        {
            var graph = new PluginGraph();
            var scanner = new DefaultConventionScanner();

            var registry = new Registry();

            scanner.Process(typeof (Convention), registry);

            registry.As<IPluginGraphConfiguration>().Configure(graph);

            graph.Families.Has(typeof (IServer)).ShouldBeFalse();
            graph.Families.Has(typeof (IConvention)).ShouldBeTrue();

            var family = graph.Families[typeof (IConvention)];
            family.Instances.Count().ShouldBe(1);
        }