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);
        }
Beispiel #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));
 }
Beispiel #5
0
 public static CosmosElement CreateFromBuffer(ReadOnlyMemory <byte> buffer)
 {
     return(CosmosElement.CreateFromBuffer <CosmosElement>(buffer));
 }
Beispiel #6
0
 public static CosmosElement Parse(string json)
 {
     byte[] buffer = Encoding.UTF8.GetBytes(json);
     return(CosmosElement.CreateFromBuffer(buffer));
 }