public Task <ServiceRegistry> Bootstrap(JasperRegistry registry)
        {
            var forwarding = new Forwarders();
            var services   = new ServiceRegistry();

            services.AddSingleton(forwarding);

            if (registry.ApplicationAssembly == null)
            {
                return(Task.FromResult(services));
            }


            services.Scan(_ =>
            {
                _.Assembly(registry.ApplicationAssembly);
                _.AddAllTypesOf <IMessageSerializer>();
                _.AddAllTypesOf <IMessageDeserializer>();
            });

            // TODO -- move serializer discovery here

            return(TypeRepository.FindTypes(registry.ApplicationAssembly,
                                            TypeClassification.Closed | TypeClassification.Closed, t => t.Closes(typeof(IForwardsTo <>)))
                   .ContinueWith(t =>
            {
                foreach (var type in t.Result)
                {
                    forwarding.Add(type);
                }

                return services;
            }));
        }
示例#2
0
        internal async Task <HandlerCall[]> FindCalls(JasperRegistry registry)
        {
            if (_conventionalDiscoveryDisabled)
            {
                return(_explicitTypes.SelectMany(actionsFromType).ToArray());
            }

            if (registry.ApplicationAssembly == null)
            {
                return(new HandlerCall[0]);
            }


            // TODO -- need to expose the module assemblies off of this

            var types = await TypeRepository.FindTypes(registry.ApplicationAssembly,
                                                       TypeClassification.Concretes | TypeClassification.Closed, type => _typeFilters.Matches(type))
                        .ConfigureAwait(false);


            return(types
                   .Where(x => !x.HasAttribute <JasperIgnoreAttribute>())
                   .Concat(_explicitTypes)
                   .Distinct()
                   .SelectMany(actionsFromType).ToArray());
        }
示例#3
0
        internal Task <MethodCall[]> FindActions(Assembly applicationAssembly)
        {
            if (applicationAssembly == null)
            {
                return(Task.FromResult(new MethodCall[0]));
            }

            var assemblies = Applies.Assemblies.Any() ? Applies.Assemblies : new[] { applicationAssembly };

            return(TypeRepository.FindTypes(assemblies, TypeClassification.Concretes, _typeFilters.Matches)
                   .ContinueWith(x => x.Result.SelectMany(actionsFromType).ToArray()));
        }
示例#4
0
        internal async Task <MethodCall[]> FindActions(Assembly applicationAssembly)
        {
            if (applicationAssembly == null)
            {
                return(new MethodCall[0]);
            }

            var assemblies = Applies.Assemblies.Any() ? Applies.Assemblies : new[] { applicationAssembly };

            var discovered =
                await TypeRepository.FindTypes(assemblies, TypeClassification.Concretes, _typeFilters.Matches);

            return(discovered
                   .Concat(_explicitTypes)
                   .Distinct()
                   .SelectMany(actionsFromType).ToArray());
        }
示例#5
0
        public async Task <ServiceCapabilities> Compile(HandlerGraph handlers, SerializationGraph serialization, IChannelGraph channels, JasperRuntime runtime, ITransport[] transports, UriAliasLookup lookups)
        {
            if (runtime.ApplicationAssembly != null)
            {
                var publishedTypes = await TypeRepository.FindTypes(runtime.ApplicationAssembly,
                                                                    TypeClassification.Closed | TypeClassification.Closed, type => _publishFilters.Any(x => x(type)));

                foreach (var type in publishedTypes)
                {
                    Publish(type);
                }
            }



            var capabilities = await compile(handlers, serialization, channels, transports, lookups);

            return(capabilities);
        }