示例#1
0
        public static ConnegGraph Build(BehaviorGraph behaviorGraph)
        {
            var graph = new ConnegGraph();

            TypePool typePool = behaviorGraph.Types();
            var      writers  = typePool
                                .TypesMatching(
                x =>
                x.Closes(typeof(IMediaWriter <>)) && x.IsConcreteWithDefaultCtor() &&
                !x.IsOpenGeneric());

            graph.Writers.AddRange(writers);


            var readers = typePool
                          .TypesMatching(
                x =>
                x.Closes(typeof(IReader <>)) && x.IsConcreteWithDefaultCtor() &&
                !x.IsOpenGeneric());

            graph.Readers.AddRange(readers);


            return(graph);
        }
示例#2
0
        public void Configure(IServiceRegistry services)
        {
            var matchedTypes = _types.TypesMatching(_typeFilters.Matches);

            _conventions
            .Each(convention => convention.Register(matchedTypes, services));
        }
示例#3
0
        public void BuildBehaviors(TypePool pool, BehaviorGraph graph)
        {
            _graph = graph;

            pool.TypesMatching(TypeFilters.Matches).Each(scanMethods);
            _graph = null;
        }
示例#4
0
        public IEnumerable <Type> Find()
        {
            var list = new List <string> {
                AppDomain.CurrentDomain.SetupInformation.ApplicationBase
            };

            string binPath = AppDomain.CurrentDomain.SetupInformation.PrivateBinPath;

            if (binPath.IsNotEmpty())
            {
                if (Path.IsPathRooted(binPath))
                {
                    list.Add(binPath);
                }
                else
                {
                    list.Add(AppDomain.CurrentDomain.SetupInformation.ApplicationBase.AppendPath(binPath));
                }
            }

            var assemblies = list.SelectMany(x => AssembliesFromPath(x));
            var pool       = new TypePool();

            pool.IgnoreExportTypeFailures = true;

            pool.AddAssemblies(assemblies);
            return(pool.TypesMatching(x => x.IsConcreteTypeOf <IApplicationSource>() && x.IsConcreteWithDefaultCtor()));
        }
示例#5
0
 public void Configure(BehaviorGraph graph)
 {
     _types.TypesMatching(t => t.IsConcreteTypeOf <ISmartGrid>()).Each(t =>
     {
         buildChain(graph, t);
         addHarnessToServices(graph, t);
     });
 }
示例#6
0
        public void BuildBehaviors(TypePool pool, BehaviorGraph graph)
        {
            _graph = graph;

            // Do not do any assembly scanning if no type or method filters are set
            pool.ShouldScanAssemblies = HasFilters();

            pool.TypesMatching(TypeFilters.Matches).Each(scanMethods);
            _graph = null;
        }
示例#7
0
        public void BuildBehaviors(TypePool pool, BehaviorGraph graph)
        {
            _graph = graph;

            // Do not do any assembly scanning if no type or method filters are set
            pool.ShouldScanAssemblies = HasFilters();

            pool.TypesMatching(TypeFilters.Matches).Each(scanMethods);
            _graph = null;
        }
示例#8
0
 public IEnumerable<ActionCall> FindActions(TypePool types)
 {
     // Do not do any assembly scanning if no type or method filters are set
     types.ShouldScanAssemblies = HasFilters();
     return types
         .TypesMatching(TypeFilters.Matches)
         .SelectMany(type => type.GetMethods(BindingFlags.Instance | BindingFlags.Public)
                                 .Select(x => _actionCallProvider(type, x))
                                 .Where(MethodFilters.Matches));
 }
示例#9
0
 public void BuildChains(TypePool pool, CommandGraph graph)
 {
     pool
         .TypesMatching(TypeFilters.Matches)
         .Each(t =>
                   {
                       graph.AddChainForNew(new CommandChain(t));
                       graph.AddChainForExisting(new CommandChain(t));
                   });
 }
示例#10
0
        public IEnumerable <IViewToken> FindViews(BehaviorGraph graph)
        {
            var types = new TypePool();

            types.AddAssemblies(AppDomain.CurrentDomain.GetAssemblies());
            types.IgnoreExportTypeFailures = true;

            return(types.TypesMatching(t => t.IsConcrete() && t.Closes(typeof(FubuHtmlDocument <>)) && !t.Equals(typeof(FubuHtmlDocument <>)))
                   .Select(t => new HtmlDocumentViewToken(t)));
        }
示例#11
0
        public void Configure(BehaviorGraph graph)
        {
            // This needs to be forced to true here
            _types.ShouldScanAssemblies = true;
            _types.TypesMatching(_viewTypeFilter).Each(type =>
            {
                var chain = graph.AddChain();
                var node  = _facilities.FirstValue(x => x.CreateViewNode(type));
                chain.AddToEnd(node);

                _configureChain(chain);
            });
        }
        IEnumerable <HandlerCall> IHandlerSource.FindCalls()
        {
            var types = new TypePool();

            if (_assemblies.Any())
            {
                types.AddAssemblies(_assemblies);
            }
            else
            {
                types.AddAssembly(FubuTransportRegistry.FindTheCallingAssembly());
            }

            return(types.TypesMatching(_typeFilters.Matches).SelectMany(actionsFromType));
        }
示例#13
0
            internal void Apply(SettingRegistry registry, BehaviorGraph graph)
            {
                var typePool = new TypePool();

                if (_useApplicationAssembly)
                {
                    typePool.AddAssembly(graph.ApplicationAssembly);
                }

                typePool.AddAssemblies(_assemblies);

                typePool.TypesMatching(_filter)
                .Where(type => graph.Services.DefaultServiceFor(type) == null)
                .Each(type => registry.AddSettingType(type));
            }
示例#14
0
        public static IEnumerable <IFubuRegistryExtension> FindAllExtensions()
        {
            if (!PackageRegistry.PackageAssemblies.Any())
            {
                return(new IFubuRegistryExtension[0]);
            }

            var pool = new TypePool(null);

            pool.AddAssemblies(PackageRegistry.PackageAssemblies);

            // Yeah, it really does have to be this way
            return(pool.TypesMatching(
                       t =>
                       hasDefaultCtor(t) && t.GetInterfaces().Any(i => i.FullName == typeof(IFubuRegistryExtension).FullName))
                   .Select(buildExtension));
        }
示例#15
0
        public static IEnumerable <Type> FindAllExtensionTypes(IEnumerable <Assembly> assemblies)
        {
            if (!assemblies.Any())
            {
                return(new Type[0]);
            }

            var pool = new TypePool {
                IgnoreExportTypeFailures = false
            };

            pool.AddAssemblies(assemblies);

            // Yeah, it really does have to be this way
            return(pool.TypesMatching(
                       t =>
                       hasDefaultCtor(t) && t.GetInterfaces().Any(i => i.FullName == typeof(IFubuRegistryExtension).FullName)));
        }
        public void Configure(FubuRegistry registry)
        {
            var types = new TypePool();

            types.AddAssemblies(AppDomain.CurrentDomain.GetAssemblies());
            types.IgnoreExportTypeFailures = true;

            // Some ugly Generic trickery
            types.TypesMatching(IsGridDefinitionType).Each(type => {
                typeof(Loader <>).CloseAndBuildAs <ILoader>(type).Apply(registry);
            });


            var policies = new ColumnPolicies();

            registry.ReplaceSettings(policies);

            registry.Services(x => x.AddService <IColumnPolicies>(policies));
        }
示例#17
0
        public void Activate(IEnumerable <IPackageInfo> packages, IPackageLog log)
        {
            var pool = new TypePool();

            pool.AddAssemblies(AppDomain.CurrentDomain.GetAssemblies());
            pool.IgnoreExportTypeFailures = true;

            pool.TypesMatching(type => type.IsConcreteWithDefaultCtor() && type.CanBeCastTo <TopicRegistry>())
            .Each(type => {
                // All we have to do is create it to work
                Activator.CreateInstance(type);
            });

            TopicGraph.AllTopics.All().Each(node => {
                node.Url = _urls.UrlFor(node.TopicType);
                if (!node.Url.StartsWith("/"))
                {
                    node.Url = "/" + node.Url; // has to be an absolute
                }
            });
        }
示例#18
0
 public IEnumerable <IViewToken> FindViews(TypePool types, BehaviorGraph graph)
 {
     return(types.TypesMatching(IsWebFormView).Select(x => new WebFormViewToken(x) as IViewToken));
 }
示例#19
0
 public void RegisterBuilders(TypePool pool, IEnumerable<IEntityBuilderRegistrationConvention> conventions, EntityBuilderRegistry registry)
 {
     pool
         .TypesMatching(TypeFilters.Matches)
         .Each(t => conventions.Each(convention => convention.Process(t, registry)));
 }
示例#20
0
 public static IEnumerable <Type> EntityTypes(this TypePool pool)
 {
     return((from type in pool.TypesMatching(AwesomeConfiguration.AwesomeEntities)
             where type.IsConcrete()
             select type).Distinct());
 }
示例#21
0
 public void BuildChains(TypePool types, ValidationGraph graph)
 {
     types
         .TypesMatching(TypeFilters.Matches)
         .Each(type => graph.AddChain(ValidationChain.GenericForModel(type)));
 }
示例#22
0
 public void EachType(TypePool types, Action<Type> action)
 {
     types
         .TypesMatching(TypeFilters.Matches)
         .Each(action);
 }