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; })); }
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); }
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); }
public ForwardingRegistration(Forwarders forwarders) { _forwarders = forwarders; }