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;
        }
Пример #5
0
 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);
 }
Пример #6
0
 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;
 }
Пример #8
0
 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;
        }
Пример #11
0
 static IEnumerable<PublisherTableEntry> Generate(Conventions conventions, IPublisherSource source, bool enforceBestPractices)
 {
     return enforceBestPractices
         ? source.GenerateWithBestPracticeEnforcement(conventions)
         : source.GenerateWithoutBestPracticeEnforcement(conventions);
 }
Пример #12
0
 public void Apply(Publishers publishers, Conventions conventions, bool enforceBestPractices)
 {
     var entries = publisherSources.SelectMany(s => Generate(conventions, s, enforceBestPractices)).ToList();
     publishers.AddOrReplacePublishers("EndpointConfiguration", entries);
 }
Пример #13
0
 public Validations(Conventions conventions)
 {
     this.conventions = conventions;
 }
Пример #14
0
 public EncryptionInspector(Conventions conventions)
 {
     this.conventions = conventions;
 }
Пример #15
0
 public Validations(Conventions conventions)
 {
     this.conventions = conventions;
 }