Beispiel #1
0
        void InitializeFromConfiguration(MessageAddressConversionConfiguration configuration)
        {
            Contract.Requires(configuration != null);

            this.topicTemplateTable = new List <UriPathTemplate>();
            this.topicTemplateTable.Add(new UriPathTemplate(configuration.InboundTemplates[0]));
            this.outboundTemplate = configuration.OutboundTemplates.Select(x => new UriPathTemplate(x)).Single();
        }
        public object Create(object parent, object configContext, XmlNode section)
        {
            var configuration = new MessageAddressConversionConfiguration();

            configuration.InboundTemplates.AddRange(section
                                                    .OfType <XmlElement>()
                                                    .Where(x => "inboundTemplate".Equals(x.Name, StringComparison.OrdinalIgnoreCase))
                                                    .Select(route => route.InnerText));
            configuration.OutboundTemplates.AddRange(section
                                                     .OfType <XmlElement>()
                                                     .Where(x => "outboundTemplate".Equals(x.Name, StringComparison.OrdinalIgnoreCase))
                                                     .Select(route => route.InnerText));
            return(configuration);
        }
Beispiel #3
0
        /// <summary>
        ///     Initializes a new instance of <see cref="ConfigurableMessageAddressConverter" />.
        /// </summary>
        /// <param name="configurationSectionName">Name of configuration section that contains routing configuration.</param>
        /// <remarks>
        ///     This constructor uses a section from application configuration to generate routing configuration.
        /// </remarks>
        /// <example>
        ///     <code>
        ///     <mqttTopicNameConversion>
        ///             <inboundTemplate>{deviceId}/messages/events</inboundTemplate>
        ///             <outboundTemplate>devices/{deviceId}/messages/devicebound/{*subTopic}</outboundTemplate>
        ///         </mqttTopicNameConversion>
        /// </code>
        /// </example>
        public MessageAddressConverter(string configurationSectionName)
        {
            Contract.Requires(!string.IsNullOrEmpty(configurationSectionName));

#if NETSTANDARD1_3
            var configuration = new MessageAddressConversionConfiguration();
            configurationRoot.GetSection(configurationSectionName).Bind(configuration);
#else
            var configuration =
                (MessageAddressConversionConfiguration)ConfigurationManager.GetSection(configurationSectionName);
#endif

            this.InitializeFromConfiguration(configuration);
        }
Beispiel #4
0
 public MessageAddressConverter(MessageAddressConversionConfiguration configuration)
 {
     this.InitializeFromConfiguration(configuration);
 }
Beispiel #5
0
        public ConfigurableMessageAddressConverter(List <string> inboundTemplates, List <string> outboundTemplates)
        {
            var configuration = new MessageAddressConversionConfiguration(inboundTemplates, outboundTemplates);

            this.InitializeFromConfiguration(configuration);
        }