public static string GetProperty <T>(this XLANGMessage message, MessageContextProperty <T, string> property)
            where T : MessageContextPropertyBase, new()
        {
            var value = message.GetPropertyValue(property.Type);

            return((string)value);
        }
        public static string GetProperty <T>(this IBaseMessageContext context, MessageContextProperty <T, string> property)
            where T : MessageContextPropertyBase, new()
        {
            var value = context.Read(property.Name, property.Namespace);

            return((string)value);
        }
Exemple #3
0
        public static Type ResolvePluginType <T>(this IBaseMessage message, MessageContextProperty <T, string> messageContextProperty, Type configuredPluginType)
            where T : MessageContextPropertyBase, new()
        {
            // look after plugin type name in message context
            var pluginTypeName = message.GetProperty(messageContextProperty);

            if (!pluginTypeName.IsNullOrEmpty())
            {
                // remove plugin type name from context to ensure no one else will use it too
                message.DeleteProperty(messageContextProperty);
                if (_logger.IsDebugEnabled)
                {
                    _logger.Debug($"Using message context's plugin type '{pluginTypeName}'.");
                }
                return(Type.GetType(pluginTypeName, true));
            }
            // use plugin type configured at pipeline level if no one found in context
            if (configuredPluginType != null)
            {
                if (_logger.IsDebugEnabled)
                {
                    _logger.Debug($"Using configured plugin type '{configuredPluginType.AssemblyQualifiedName}'.");
                }
                return(configuredPluginType);
            }
            return(null);
        }
 public static void SetProperty <T>(this XLANGMessage message, MessageContextProperty <T, string> property, string value)
     where T : MessageContextPropertyBase, new()
 {
     if (value != null)
     {
         message.SetPropertyValue(property.Type, value);
     }
 }
 public static void Promote <T>(this BizMockMessage message, MessageContextProperty <T, string> property, string value)
     where T : MessageContextPropertyBase, new()
 {
     if (value != null)
     {
         message.Promote(property.Name, property.Namespace, value);
     }
 }
        public static TR?GetProperty <T, TR>(this XLANGMessage message, MessageContextProperty <T, TR> property)
            where T : MessageContextPropertyBase, new()
            where TR : struct
        {
            var value = message.GetPropertyValue(property.Type);

            return((TR?)value);
        }
        public static TR?GetProperty <T, TR>(this IBaseMessage message, MessageContextProperty <T, TR> property)
            where T : MessageContextPropertyBase, new()
            where TR : struct
        {
            var value = message.Context.Read(property.Name, property.Namespace);

            return((TR?)value);
        }
        public static TR?GetProperty <T, TR>(this IBaseMessageContext context, MessageContextProperty <T, TR> property)
            where T : MessageContextPropertyBase, new()
            where TR : struct
        {
            var value = context.Read(property.Name, property.Namespace);

            return(value != null ? (TR?)Convert.ChangeType(value, typeof(TR)) : null);
        }
 public static void SetProperty <T>(this IBaseMessageContext context, MessageContextProperty <T, string> property, string value)
     where T : MessageContextPropertyBase, new()
 {
     if (value != null)
     {
         context.Write(property.Name, property.Namespace, value);
     }
 }
Exemple #10
0
 public Property <string> GetProperty <T>(MessageContextProperty <T, string> property)
     where T : MessageContextPropertyBase, new()
 {
     return(Properties.SingleOrDefault(p => p.Name == property.Name && p.Namespace == property.Namespace));
 }
            // TODO enforce value of the right type when promoting/reading/writing a Transform<T> for ResolvedProperties.MapTypeName
            // TODO ?? rename MapTypeName to MapType ??
            //public static Type Read(MessageContextProperty<MapTypeName, string> property)
            //{
            //   return null;
            //}

            // TODO enforce value of the right type when promoting/reading/writing a Schema<T> for BtsProperties.MessageType
            //public static Type Read(MessageContextProperty<MessageType, string> property)
            //{
            //   return null;
            //}

            public static void Write <TP>(MessageContextProperty <TP, string> property, string value)
                where TP : MessageContextPropertyBase, new()
            {
            }
 public static TV Read <TP, TV>(MessageContextProperty <TP, TV> property)
     where TP : MessageContextPropertyBase, new()
     where TV : struct
 {
     return(default(TV));
 }
            // TODO enforce value of the right type when promoting/reading/writing a Transform<T> for ResolvedProperties.MapTypeName
            //public static void Promote(MessageContextProperty<MapTypeName, string> property, Type value)
            //{
            //}

            // TODO enforce value of the right type when promoting/reading/writing a Schema<T> for BtsProperties.MessageType
            //public static void Promote(MessageContextProperty<MessageType, string> property, Type value)
            //{
            //}

            public static string Read <TP>(MessageContextProperty <TP, string> property)
                where TP : MessageContextPropertyBase, new()
            {
                return(null);
            }
 public static void Promote <TP, TV>(MessageContextProperty <TP, TV> property, TV value)
     where TP : MessageContextPropertyBase, new()
     where TV : struct
 {
 }
 public static void DeleteProperty <T>(this IBaseMessage message, MessageContextProperty <T, string> property)
     where T : MessageContextPropertyBase, new()
 {
     message.Context.Write(property.Name, property.Namespace, null);
 }
Exemple #16
0
 public static Stream InjectAttribute <T>(this Stream stream, MessageContextProperty <T, DateTime> property, DateTimeOffset value)
     where T : MessageContextPropertyBase, new()
 {
     return(stream.InjectAttribute(property.Name, XmlConvert.ToString(value)));
 }
Exemple #17
0
 public static Stream InjectAttribute <T, TR>(this Stream stream, MessageContextProperty <T, TR> property, TR value)
     where T : MessageContextPropertyBase, new()
 {
     return(stream.InjectAttribute(property.Name, value.ToString()));
 }
Exemple #18
0
 public Property <TR> GetProperty <T, TR>(MessageContextProperty <T, TR> property)
     where T : MessageContextPropertyBase, new()
     where TR : struct
 {
     return(Properties.SingleOrDefault(p => p.Name == property.Name && p.Namespace == property.Namespace));
 }
 public static void Promote <T, TV>(this IBaseMessageContext context, MessageContextProperty <T, TV> property, TV value)
     where T : MessageContextPropertyBase, new()
     where TV : struct
 {
     context.Promote(property.Name, property.Namespace, value);
 }
 public static bool IsPromoted <T, TV>(this IBaseMessageContext context, MessageContextProperty <T, TV> property)
     where T : MessageContextPropertyBase, new()
     where TV : struct
 {
     return(context.GetProperty(property).HasValue&& context.IsPromoted(property.Name, property.Namespace));
 }
 public static bool IsPromoted <T>(this IBaseMessageContext context, MessageContextProperty <T, string> property)
     where T : MessageContextPropertyBase, new()
 {
     return(!context.GetProperty(property).IsNullOrEmpty() && context.IsPromoted(property.Name, property.Namespace));
 }
 public static void DeleteProperty <T, TR>(this IBaseMessageContext context, MessageContextProperty <T, TR> property)
     where T : MessageContextPropertyBase, new()
     where TR : struct
 {
     context.Write(property.Name, property.Namespace, null);
 }
 public static void DeleteProperty <T>(this XLANGMessage message, MessageContextProperty <T, object> property)
     where T : MessageContextPropertyBase, new()
 {
     message.SetPropertyValue(property.Type, null);
 }
Exemple #24
0
 public ContextFact <TV> Property <TP, TV>(MessageContextProperty <TP, TV> contextProperty)
     where TP : MessageContextPropertyBase, new()
 {
     return(new ContextFact <TV>(new XmlQualifiedName(contextProperty.Name, contextProperty.Namespace)));
 }
 public static void SetProperty <T, TV>(this IBaseMessage message, MessageContextProperty <T, TV> property, TV value)
     where T : MessageContextPropertyBase, new()
     where TV : struct
 {
     message.Context.Write(property.Name, property.Namespace, value);
 }
Exemple #26
0
 public static Stream InjectAttribute <T>(this Stream stream, MessageContextProperty <T, DateTime> property, DateTime value)
     where T : MessageContextPropertyBase, new()
 {
     return(stream.InjectAttribute(property.Name, XmlConvert.ToString(value, XmlDateTimeSerializationMode.RoundtripKind)));
 }
 public static void Promote <T, TV>(this BizMockMessage message, MessageContextProperty <T, TV> property, TV value)
     where T : MessageContextPropertyBase, new()
     where TV : struct
 {
     message.Promote(property.Name, property.Namespace, value);
 }
Exemple #28
0
 public static string GetProperty <T>(this MessageProperties properties, MessageContextProperty <T, string> property)
     where T : MessageContextPropertyBase, new()
 {
     return(properties.TryGetProperty(property, out var value) ? value : default);
 public static void SetProperty <T, TV>(this XLANGMessage message, MessageContextProperty <T, TV> property, TV value)
     where T : MessageContextPropertyBase, new()
     where TV : struct
 {
     message.SetPropertyValue(property.Type, value);
 }