Ejemplo n.º 1
0
        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;
            }));
        }
Ejemplo n.º 2
0
        public void ScanTypes(TypeSet types, ServiceRegistry services)
        {
            var forwardingTypes = types.FindTypes(TypeClassification.Closed)
                                  .Where(t => TypeExtensions.Closes(t, typeof(IForwardsTo <>)));

            foreach (var type in forwardingTypes)
            {
                _forwarders.Add(type);
            }
        }