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));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// All types in the AppDomain in non dynamic assemblies
        /// </summary>
        public static TypePool AppDomainTypes()
        {
            var pool = new TypePool {
                IgnoreExportTypeFailures = true
            };

            pool.AddAssemblies(AppDomain.CurrentDomain.GetAssemblies().Where(x => !x.IsDynamic));

            return(pool);
        }
        public IEnumerable<ActionCall> FindActions(Assembly applicationAssembly)
        {
            var types = new TypePool();
            types.AddAssemblies(AppDomain.CurrentDomain.GetAssemblies());
            types.IgnoreExportTypeFailures = true;

            return types.TypesMatching(type => type.IsConcreteTypeOf<ILookupProvider>()).Select(type =>
            {
                var method = GetLookupMethod(type);
                return new ActionCall(type, method);
            });
        }
Ejemplo n.º 4
0
        public TypePool Types()
        {
            var types = new TypePool();

            if (ApplicationAssembly != null)
            {
                types.AddAssembly(ApplicationAssembly);
            }
            types.AddAssemblies(PackageRegistry.PackageAssemblies);

            return(types);
        }
Ejemplo n.º 5
0
        public IEnumerable<Type> FindApplicationSourceTypes(ApplicationSettings settings)
        {
            var assemblies = AssembliesFromApplicationBaseDirectory(x => true);
            if (!assemblies.Any())
            {
                var assemblyName = Path.GetFileName(settings.GetApplicationFolder());
                assemblies = AssembliesFromApplicationBaseDirectory(x => x.GetName().Name == assemblyName);
            }

            var types = new TypePool {IgnoreExportTypeFailures = true};
            types.AddAssemblies(assemblies);

            return types.TypesMatching(x => x.CanBeCastTo<IApplicationSource>() && x.IsConcreteWithDefaultCtor());
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        public void Configure(BehaviorGraph graph)
        {
            var rules = graph.Settings.Get <AccessorRules>();

            var types = new TypePool(null);

            types.AddAssemblies(graph.Types.Assemblies.Union(PackageRegistry.PackageAssemblies));

            types.TypesMatching(x => x.CanBeCastTo <IAccessorRulesRegistration>() && x.IsConcreteWithDefaultCtor()).
            Distinct().Select(x => {
                return(Activator.CreateInstance(x).As <IAccessorRulesRegistration>());
            })
            .Each(x => x.AddRules(rules));

            graph.Services.AddService(rules);
        }
Ejemplo n.º 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
                }
            });
        }
Ejemplo n.º 9
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());
        }