/// <summary> /// Use XML serialization that supports interface-based messages. /// </summary> /// <param name="config"></param> /// <returns></returns> public static Configure XmlSerializer(this Configure config) { if (!Configure.BuilderIsConfigured()) { SetXmlSerializerAsDefault.UseXmlSerializer = true; return(config); } var messageTypes = Configure.TypesToScan.Where(t => t.IsMessageType()).ToList(); var mapper = new MessageMapper(); mapper.Initialize(messageTypes); config.Configurer.RegisterSingleton <IMessageMapper>(mapper); config.Configurer.RegisterSingleton <IMessageCreator>(mapper);//todo - Modify the builders to auto register all types var serializer = new XmlMessageSerializer(mapper); serializer.Initialize(messageTypes); config.Configurer.RegisterSingleton <IMessageSerializer>(serializer); return(config); }
/// <summary> /// Provides a factory method for building a message serializer. /// </summary> public override Func <IMessageMapper, IMessageSerializer> Configure(ReadOnlySettings settings) { return(mapper => { var conventions = settings.Get <Conventions>(); var serializer = new XmlMessageSerializer(mapper, conventions); string customNamespace; if (settings.TryGet(CustomNamespaceConfigurationKey, out customNamespace)) { serializer.Namespace = customNamespace; } bool skipWrappingRawXml; if (settings.TryGet(SkipWrappingRawXml, out skipWrappingRawXml)) { serializer.SkipWrappingRawXml = skipWrappingRawXml; } bool sanitizeInput; if (settings.TryGet(SanitizeInput, out sanitizeInput)) { serializer.SanitizeInput = sanitizeInput; } var registry = settings.Get <MessageMetadataRegistry>(); var messageTypes = registry.GetAllMessages().Select(m => m.MessageType); serializer.Initialize(messageTypes); return serializer; }); }
/// <summary> /// Provides a factory method for building a message serializer. /// </summary> public override Func<IMessageMapper, IMessageSerializer> Configure(ReadOnlySettings settings) { return mapper => { var conventions = settings.Get<Conventions>(); var serializer = new XmlMessageSerializer(mapper, conventions); string customNamespace; if (settings.TryGet(CustomNamespaceConfigurationKey, out customNamespace)) { serializer.Namespace = customNamespace; } bool skipWrappingRawXml; if (settings.TryGet(SkipWrappingRawXml, out skipWrappingRawXml)) { serializer.SkipWrappingRawXml = skipWrappingRawXml; } bool sanitizeInput; if (settings.TryGet(SanitizeInput, out sanitizeInput)) { serializer.SanitizeInput = sanitizeInput; } var registry = settings.Get<MessageMetadataRegistry>(); var messageTypes = registry.GetAllMessages().Select(m => m.MessageType); serializer.Initialize(messageTypes); return serializer; }; }
/// <summary> /// Use XML serialization that supports interface-based messages. /// </summary> /// <param name="config"></param> /// <returns></returns> public static Configure XmlSerializer(this Configure config) { if (!Configure.BuilderIsConfigured()) { SetXmlSerializerAsDefault.UseXmlSerializer = true; return config; } var messageTypes = Configure.TypesToScan.Where(t => t.IsMessageType()).ToList(); var mapper = new MessageMapper(); mapper.Initialize(messageTypes); config.Configurer.RegisterSingleton<IMessageMapper>(mapper); config.Configurer.RegisterSingleton<IMessageCreator>(mapper);//todo - Modify the builders to auto register all types var serializer = new XmlMessageSerializer(mapper); serializer.Initialize(messageTypes); config.Configurer.RegisterSingleton<IMessageSerializer>(serializer); return config; }