MassTransit.Util.TypeMetadataCache.IsValidMessageType C# (CSharp) Method

IsValidMessageType() public static method

public static IsValidMessageType ( Type type ) : bool
type System.Type
return bool
        public static bool IsValidMessageType(Type type)
        {
            return GetOrAdd(type).IsValidMessageType;
        }

Usage Example

Ejemplo n.º 1
0
        public object Deserialize(object value, Type objectType, bool allowNull = false)
        {
            var token = value as JToken ?? new JValue(value);

            if (token.Type == JTokenType.Null && allowNull)
            {
                return(null);
            }

            if (token.Type == JTokenType.String && objectType.IsInterface && TypeMetadataCache.IsValidMessageType(objectType))
            {
                return(JsonConvert.DeserializeObject((string)value, objectType, JsonMessageSerializer.DeserializerSettings));
            }

            using var jsonReader = new JTokenReader(token);

            return(SerializerCache.Deserializer.Deserialize(jsonReader, objectType));
        }