public static void UseEncryptedSerializer(this IBusFactoryConfigurator configurator, ICryptoStreamProvider streamProvider)
        {
            configurator.SetMessageSerializer(() => new EncryptedMessageSerializer(streamProvider));

            configurator.AddMessageDeserializer(EncryptedMessageSerializer.EncryptedContentType,
                                                () => new EncryptedMessageDeserializer(BsonMessageSerializer.Deserializer, streamProvider));
        }
        /// <summary>
        /// Serialize messages using the raw JSON message serializer
        /// </summary>
        /// <param name="configurator"></param>
        public static void UseRawJsonSerializer(this IBusFactoryConfigurator configurator)
        {
            configurator.SetMessageSerializer(() => new RawJsonMessageSerializer());

            configurator.AddMessageDeserializer(RawJsonMessageSerializer.RawJsonContentType,
                                                () => new RawJsonMessageDeserializer(RawJsonMessageSerializer.Deserializer));
        }
        /// <summary>
        /// Serialize messages using the raw XML message serializer
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="options">If false, only supported messages types (read from the message headers) will be returned</param>
        public static void UseRawXmlSerializer(this IBusFactoryConfigurator configurator, RawSerializerOptions options)
        {
            configurator.SetMessageSerializer(() => new RawXmlMessageSerializer(options));

            configurator.AddMessageDeserializer(RawXmlMessageSerializer.RawXmlContentType,
                                                () => new RawXmlMessageDeserializer(JsonMessageSerializer.Deserializer, options));
        }
        /// <summary>
        /// Serialize messages using the System.Text.Json serializer
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="configure"></param>
        public static void UseSystemTextJsonSerializer(this IBusFactoryConfigurator configurator,
                                                       Func <JsonSerializerOptions, JsonSerializerOptions> configure = null)
        {
            if (configure != null)
            {
                SystemTextJsonMessageSerializer.Options = configure(SystemTextJsonMessageSerializer.Options);
            }

            configurator.SetMessageSerializer(() => new SystemTextJsonMessageSerializer());
        }
        /// <summary>
        /// Replace the built-in message serializer with System.Text.Json (experimental, not yet recommended)
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="configure"></param>
        public static void UseSystemTextJsonOnly(this IBusFactoryConfigurator configurator,
                                                 Func <JsonSerializerOptions, JsonSerializerOptions> configure = null)
        {
            if (configure != null)
            {
                SystemTextJsonMessageSerializer.Options = configure(SystemTextJsonMessageSerializer.Options);
            }

            configurator.AddMessageDeserializer(JsonMessageSerializer.JsonContentType, () => new SystemTextJsonMessageDeserializer());

            configurator.SetMessageSerializer(() => new SystemTextJsonMessageSerializer(JsonMessageSerializer.JsonContentType));
        }
Exemplo n.º 6
0
        public static void UseAwsKeyManagementServiceSerializer(this IBusFactoryConfigurator configurator,
                                                                IKeyManagementService keyManagementService,
                                                                IEncryptionContextBuilder encryptionContextBuilder,
                                                                string kmsKeyId)
        {
            var kmsSecureKeyProvider =
                new KmsSecureKeyProvider(keyManagementService, encryptionContextBuilder, kmsKeyId);

            var aesCryptoStreamProvider = new AesCryptoStreamProviderV2(kmsSecureKeyProvider);

            configurator.SetMessageSerializer(() => new EncryptedMessageSerializerV2(aesCryptoStreamProvider));

            configurator.AddMessageDeserializer(EncryptedMessageSerializer.EncryptedContentType,
                                                () => new EncryptedMessageDeserializerV2(BsonMessageSerializer.Deserializer, aesCryptoStreamProvider));
        }
 /// <summary>
 /// Serialize messages using the XML message serializer
 /// </summary>
 /// <param name="configurator"></param>
 public static void UseXmlSerializer(this IBusFactoryConfigurator configurator)
 {
     configurator.SetMessageSerializer(() => new XmlMessageSerializer());
 }
        /// <summary>
        /// Serialize message using the .NET binary formatter (also adds support for the binary deserializer)
        /// </summary>
        /// <param name="configurator"></param>
        public static void UseBinarySerializer(this IBusFactoryConfigurator configurator)
        {
            configurator.SetMessageSerializer(() => new BinaryMessageSerializer());

            configurator.SupportBinaryMessageDeserializer();
        }
Exemplo n.º 9
0
        /// <summary>
        /// Use NServiceBus XML Serialization for sent/published messages.
        /// </summary>
        /// <param name="configurator"></param>
        public static void UseNServiceBusXmlSerializer(this IBusFactoryConfigurator configurator)
        {
            configurator.SetMessageSerializer(() => new NServiceBusXmlMessageSerializer());

            SupportNServiceBusXmlDeserializer(configurator);
        }