public static CosmosElement Dispatch( IJsonNavigator jsonNavigator, IJsonNavigatorNode jsonNavigatorNode) { JsonNodeType jsonNodeType = jsonNavigator.GetNodeType(jsonNavigatorNode); return(jsonNodeType switch { JsonNodeType.Null => CosmosNull.Create(), JsonNodeType.False => CosmosBoolean.Create(false), JsonNodeType.True => CosmosBoolean.Create(true), JsonNodeType.Number64 => CosmosNumber64.Create(jsonNavigator, jsonNavigatorNode), JsonNodeType.FieldName => CosmosString.Create(jsonNavigator, jsonNavigatorNode), JsonNodeType.String => CosmosString.Create(jsonNavigator, jsonNavigatorNode), JsonNodeType.Array => CosmosArray.Create(jsonNavigator, jsonNavigatorNode), JsonNodeType.Object => CosmosObject.Create(jsonNavigator, jsonNavigatorNode), JsonNodeType.Int8 => CosmosInt8.Create(jsonNavigator, jsonNavigatorNode), JsonNodeType.Int16 => CosmosInt16.Create(jsonNavigator, jsonNavigatorNode), JsonNodeType.Int32 => CosmosInt32.Create(jsonNavigator, jsonNavigatorNode), JsonNodeType.Int64 => CosmosInt64.Create(jsonNavigator, jsonNavigatorNode), JsonNodeType.UInt32 => CosmosUInt32.Create(jsonNavigator, jsonNavigatorNode), JsonNodeType.Float32 => CosmosFloat32.Create(jsonNavigator, jsonNavigatorNode), JsonNodeType.Float64 => CosmosFloat64.Create(jsonNavigator, jsonNavigatorNode), JsonNodeType.Guid => CosmosGuid.Create(jsonNavigator, jsonNavigatorNode), JsonNodeType.Binary => CosmosBinary.Create(jsonNavigator, jsonNavigatorNode), _ => throw new ArgumentException($"Unknown {nameof(JsonNodeType)}: {jsonNodeType}") });
public bool Equals(CosmosGuid guid1, CosmosGuid guid2) { return(guid1.Value.Equals(guid2.Value)); }
public static bool TryParse(string json, out CosmosGuid cosmosGuid) { return(CosmosElement.TryParse <CosmosGuid>(json, out cosmosGuid)); }
public static CosmosElement Dispatch( IJsonNavigator jsonNavigator, IJsonNavigatorNode jsonNavigatorNode) { JsonNodeType jsonNodeType = jsonNavigator.GetNodeType(jsonNavigatorNode); CosmosElement item; switch (jsonNodeType) { case JsonNodeType.Null: item = CosmosNull.Create(); break; case JsonNodeType.False: item = CosmosBoolean.Create(false); break; case JsonNodeType.True: item = CosmosBoolean.Create(true); break; case JsonNodeType.Number: item = CosmosNumber64.Create(jsonNavigator, jsonNavigatorNode); break; case JsonNodeType.FieldName: case JsonNodeType.String: item = CosmosString.Create(jsonNavigator, jsonNavigatorNode); break; case JsonNodeType.Array: item = CosmosArray.Create(jsonNavigator, jsonNavigatorNode); break; case JsonNodeType.Object: item = CosmosObject.Create(jsonNavigator, jsonNavigatorNode); break; case JsonNodeType.Int8: item = CosmosInt8.Create(jsonNavigator, jsonNavigatorNode); break; case JsonNodeType.Int16: item = CosmosInt16.Create(jsonNavigator, jsonNavigatorNode); break; case JsonNodeType.Int32: item = CosmosInt32.Create(jsonNavigator, jsonNavigatorNode); break; case JsonNodeType.Int64: item = CosmosInt64.Create(jsonNavigator, jsonNavigatorNode); break; case JsonNodeType.UInt32: item = CosmosUInt32.Create(jsonNavigator, jsonNavigatorNode); break; case JsonNodeType.Float32: item = CosmosFloat32.Create(jsonNavigator, jsonNavigatorNode); break; case JsonNodeType.Float64: item = CosmosFloat64.Create(jsonNavigator, jsonNavigatorNode); break; case JsonNodeType.Guid: item = CosmosGuid.Create(jsonNavigator, jsonNavigatorNode); break; case JsonNodeType.Binary: item = CosmosBinary.Create(jsonNavigator, jsonNavigatorNode); break; default: throw new ArgumentException($"Unknown {nameof(JsonNodeType)}: {jsonNodeType}"); } return(item); }
public static bool TryCreateFromBuffer(ReadOnlyMemory <byte> buffer, out CosmosGuid cosmosGuid) { return(CosmosElement.TryCreateFromBuffer <CosmosGuid>(buffer, out cosmosGuid)); }