public static CosmosElement Parse(string json)
        {
            if (!CosmosElement.TryParse(json, out CosmosElement cosmosElement))
            {
                throw new ArgumentException($"Failed to parse json: {json}.");
            }

            return(cosmosElement);
        }
        public static TCosmosElement Parse <TCosmosElement>(string json)
            where TCosmosElement : CosmosElement
        {
            if (!CosmosElement.TryParse(json, out TCosmosElement cosmosElement))
            {
                throw new ArgumentException($"Failed to parse json: {json}.");
            }

            return(cosmosElement);
        }
        public static bool TryParse <TCosmosElement>(string serializedCosmosElement, out TCosmosElement cosmosElement)
            where TCosmosElement : CosmosElement
        {
            if (!CosmosElement.TryParse(serializedCosmosElement, out CosmosElement rawCosmosElement))
            {
                cosmosElement = default(TCosmosElement);
                return(false);
            }

            if (!(rawCosmosElement is TCosmosElement typedCosmosElement))
            {
                cosmosElement = default(TCosmosElement);
                return(false);
            }

            cosmosElement = typedCosmosElement;
            return(true);
        }
        public static bool TryParse <TCosmosElement>(
            string serializedCosmosElement,
            out TCosmosElement typedCosmosElement)
        {
            if (!CosmosElement.TryParse(serializedCosmosElement, out CosmosElement cosmosElement))
            {
                typedCosmosElement = default;
                return(false);
            }

            if (!(cosmosElement is TCosmosElement tempCosmosElement))
            {
                typedCosmosElement = default;
                return(false);
            }

            typedCosmosElement = tempCosmosElement;
            return(true);
        }
Пример #5
0
 public static bool TryParse(
     string json,
     out CosmosGuid cosmosGuid) => CosmosElement.TryParse <CosmosGuid>(json, out cosmosGuid);
 public static bool TryParse(
     string json,
     out CosmosString cosmosString)
 {
     return(CosmosElement.TryParse <CosmosString>(json, out cosmosString));
 }
Пример #7
0
 public static bool TryParse(string json, out CosmosBinary cosmosBinary)
 {
     return(CosmosElement.TryParse <CosmosBinary>(json, out cosmosBinary));
 }
Пример #8
0
 public static bool TryParse(string json, out CosmosNumber cosmosNumber)
 {
     return(CosmosElement.TryParse <CosmosNumber>(json, out cosmosNumber));
 }
 public static bool TryParse(
     string json,
     out CosmosBoolean cosmosBoolean) => CosmosElement.TryParse <CosmosBoolean>(json, out cosmosBoolean);
Пример #10
0
 public static bool TryParse(string json, out CosmosNull cosmosNull)
 {
     return(CosmosElement.TryParse <CosmosNull>(json, out cosmosNull));
 }
 public static bool TryParse(
     string json,
     out CosmosString cosmosString) => CosmosElement.TryParse <CosmosString>(json, out cosmosString);
Пример #12
0
 public static bool TryParse(
     string json,
     out CosmosNull cosmosNull) => CosmosElement.TryParse <CosmosNull>(json, out cosmosNull);
Пример #13
0
 public static bool TryParse(
     string json,
     out CosmosGuid cosmosGuid)
 {
     return(CosmosElement.TryParse <CosmosGuid>(json, out cosmosGuid));
 }