예제 #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;
            }));
        }
예제 #2
0
        public SerializationGraph(HandlerGraph handlers, Forwarders forwarders, IEnumerable <ISerializerFactory> serializers, IEnumerable <IMessageDeserializer> readers, IEnumerable <IMessageSerializer> writers)
        {
            _handlers   = handlers;
            _forwarders = forwarders;
            foreach (var serializer in serializers)
            {
                _serializers.SmartAdd(serializer.ContentType, serializer);
            }

            _readers.AddRange(readers);
            _writers.AddRange(writers);
        }
예제 #3
0
        protected SerializationGraph(ObjectPoolProvider pooling, MediaSelectionMode selectionMode, JsonSerializerSettings jsonSettings, Forwarders forwarders, IEnumerable <ISerializerFactory> serializers, IEnumerable <IMessageDeserializer> readers, IEnumerable <IMessageSerializer> writers)
        {
            _selectionMode = selectionMode;
            _forwarders    = forwarders;
            foreach (var serializer in serializers)
            {
                _serializers.SmartAdd(serializer.ContentType, serializer);
            }

            if (!_serializers.ContainsKey("application/json"))
            {
                var factory = new NewtonsoftSerializerFactory(jsonSettings, pooling);
                _serializers.SmartAdd("application/json", factory);
            }

            _readers.AddRange(readers);
            _writers.AddRange(writers);
        }
예제 #4
0
 public ForwardingRegistration(Forwarders forwarders)
 {
     _forwarders = forwarders;
 }