public SerializationMapper(IMessageMapper mapper, Conventions conventions, Configure configure) { jsonSerializer = new JsonMessageSerializer(mapper); xmlSerializer = new XmlMessageSerializer(mapper, conventions); List<Type> messageTypes = configure.TypesToScan.Where(conventions.IsMessageType).ToList(); xmlSerializer.Initialize(messageTypes); }
public SerializationMapper(IMessageMapper mapper,Conventions conventions, ReadOnlySettings settings) { jsonSerializer = new JsonMessageSerializer(mapper); xmlSerializer = new XmlMessageSerializer(mapper, conventions); List<Type> messageTypes = settings.GetAvailableTypes().Where(conventions.IsMessageType).ToList(); xmlSerializer.Initialize(messageTypes); }
/// <summary> /// Initializes an instance of a <see cref="XmlMessageSerializer" />. /// </summary> /// <param name="mapper">Message Mapper.</param> /// <param name="conventions">The endpoint conventions.</param> public XmlMessageSerializer(IMessageMapper mapper, Conventions conventions) { Guard.AgainstNull(nameof(mapper), mapper); Guard.AgainstNull(nameof(conventions), conventions); this.mapper = mapper; this.conventions = conventions; }
static List<Type> GetMessageTypesHandledByThisEndpoint(MessageHandlerRegistry handlerRegistry, Conventions conventions) { var messageTypesHandled = handlerRegistry.GetMessageTypes()//get all potential messages .Where(t => !conventions.IsInSystemConventionList(t)) //never auto-route system messages .ToList(); return messageTypesHandled; }
public IEnumerable<RouteTableEntry> GenerateRoutes(Conventions conventions) { if (!conventions.IsMessageType(messageType)) { throw new Exception($"Cannot configure routing for type '{messageType.FullName}' because it is not considered a message. Message types have to either implement NServiceBus.IMessage interface or match a defined message convention."); } yield return new RouteTableEntry(messageType, route); }
public IEnumerable<PublisherTableEntry> GenerateWithoutBestPracticeEnforcement(Conventions conventions) { if (!conventions.IsMessageType(messageType)) { throw new Exception($"Cannot configure publisher for type '{messageType.FullName}' because it is not considered a message. Message types have to either implement NServiceBus.IMessage interface or match a defined message convention."); } if (conventions.IsCommandType(messageType)) { throw new Exception($"Cannot configure publisher for type '{messageType.FullName}' because it is a command."); } yield return new PublisherTableEntry(messageType, address); }
public IEnumerable<RouteTableEntry> GenerateRoutes(Conventions conventions) { var routes = messageAssembly.GetTypes() .Where(t => conventions.IsMessageType(t) && string.Equals(t.Namespace, messageNamespace, StringComparison.OrdinalIgnoreCase)) .Select(t => new RouteTableEntry(t, route)) .ToArray(); if (!routes.Any()) { throw new Exception($"Cannot configure routing for namespace {messageNamespace} because it contains no types considered as messages. Message types have to either implement NServiceBus.IMessage interface or match a defined message convention."); } return routes; }
public XmlSerialization(Type messageType, Stream stream, object message, Conventions conventions, XmlSerializerCache cache, bool skipWrappingRawXml, string @namespace = DefaultNamespace) { this.messageType = messageType; this.message = message; this.conventions = conventions; this.cache = cache; this.skipWrappingRawXml = skipWrappingRawXml; this.@namespace = @namespace; writer = new RawXmlTextWriter(stream, new XmlWriterSettings { CloseOutput = false }); }
public IEnumerable<PublisherTableEntry> GenerateWithoutBestPracticeEnforcement(Conventions conventions) { var entries = messageAssembly.GetTypes() .Where(type => conventions.IsMessageType(type) && !conventions.IsCommandType(type)) .Select(t => new PublisherTableEntry(t, address)) .ToArray(); if (!entries.Any()) { throw new Exception($"Cannot configure publisher for assembly {messageAssembly.GetName().Name} because it contains no types considered as messages. Message types have to either implement NServiceBus.IMessage interface or match a defined convention."); } return entries; }
public IEnumerable<PublisherTableEntry> GenerateWithBestPracticeEnforcement(Conventions conventions) { var entries = messageAssembly.GetTypes() .Where(t => conventions.IsEventType(t) && string.Equals(t.Namespace, messageNamespace, StringComparison.OrdinalIgnoreCase)) .Select(t => new PublisherTableEntry(t, address)) .ToArray(); if (!entries.Any()) { throw new Exception($"Cannot configure publisher for namespace {messageNamespace} because it contains no types considered as events. Event types have to either implement NServiceBus.IEvent interface or match a defined event convention."); } return entries; }
static IEnumerable<PublisherTableEntry> Generate(Conventions conventions, IPublisherSource source, bool enforceBestPractices) { return enforceBestPractices ? source.GenerateWithBestPracticeEnforcement(conventions) : source.GenerateWithoutBestPracticeEnforcement(conventions); }
public void Apply(Publishers publishers, Conventions conventions, bool enforceBestPractices) { var entries = publisherSources.SelectMany(s => Generate(conventions, s, enforceBestPractices)).ToList(); publishers.AddOrReplacePublishers("EndpointConfiguration", entries); }
public Validations(Conventions conventions) { this.conventions = conventions; }
public EncryptionInspector(Conventions conventions) { this.conventions = conventions; }