public static bool TryParse(
            string serializedCosmosElement,
            out CosmosElement cosmosElement)
        {
            if (serializedCosmosElement == null)
            {
                throw new ArgumentNullException(nameof(serializedCosmosElement));
            }

            try
            {
                byte[] buffer = Encoding.UTF8.GetBytes(serializedCosmosElement);
                cosmosElement = CosmosElement.CreateFromBuffer(buffer);
            }
            catch (JsonParseException)
            {
                cosmosElement = default;
            }

            return(cosmosElement != default);
        }
        public static bool TryParse(
            string serializedCosmosElement,
            out CosmosElement cosmosElement)
        {
            if (string.IsNullOrWhiteSpace(serializedCosmosElement))
            {
                cosmosElement = default;
                return(false);
            }

            try
            {
                byte[] buffer = Encoding.UTF8.GetBytes(serializedCosmosElement);
                cosmosElement = CosmosElement.CreateFromBuffer(buffer);
            }
            catch (JsonParseException)
            {
                cosmosElement = default;
            }

            return(cosmosElement != default);
        }
Esempio n. 3
0
 public static new CosmosGuid CreateFromBuffer(ReadOnlyMemory <byte> buffer) => CosmosElement.CreateFromBuffer <CosmosGuid>(buffer);
 public static new CosmosString CreateFromBuffer(ReadOnlyMemory <byte> buffer)
 {
     return(CosmosElement.CreateFromBuffer <CosmosString>(buffer));
 }
Esempio n. 5
0
 public static CosmosElement CreateFromBuffer(ReadOnlyMemory <byte> buffer)
 {
     return(CosmosElement.CreateFromBuffer <CosmosElement>(buffer));
 }
Esempio n. 6
0
 public static CosmosElement Parse(string json)
 {
     byte[] buffer = Encoding.UTF8.GetBytes(json);
     return(CosmosElement.CreateFromBuffer(buffer));
 }