Example #1
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()));
        }
Example #2
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)));
        }
Example #3
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));
            }
        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));
        }
Example #5
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));
        }
Example #6
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));
        }
Example #8
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
                }
            });
        }