public override BubbleLayerOptions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { var depth = reader.CurrentDepth; var result = new BubbleLayerOptions(); while (reader.TokenType != JsonTokenType.EndObject || depth != reader.CurrentDepth) { reader.Read(); if (reader.TokenType == JsonTokenType.PropertyName) { var propertyName = reader.GetString(); if (IsSourceLayerOptionsProperty(propertyName)) { ReadSourceLayerOptionsProperty(propertyName, reader, result); } else { reader.Read(); switch (propertyName) { case "pitchAlignment": result.PitchAlignment = reader.TokenType == JsonTokenType.Null ? default : PitchAlignment.FromString(reader.GetString()); break; } } } } return(result); }
public override IconOptions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { var depth = reader.CurrentDepth; var result = new IconOptions(); while (reader.TokenType != JsonTokenType.EndObject || depth != reader.CurrentDepth) { reader.Read(); if (reader.TokenType == JsonTokenType.PropertyName) { var propertyName = reader.GetString(); reader.Read(); switch (propertyName) { case "allowOverlap": result.AllowOverlap = reader.TokenType == JsonTokenType.Null ? null : reader.GetBoolean(); break; case "ignorePlacement": result.IgnorePlacement = reader.TokenType == JsonTokenType.Null ? null : reader.GetBoolean(); break; case "optional": result.Optional = reader.TokenType == JsonTokenType.Null ? null : reader.GetBoolean(); break; case "pitchAlignment": result.PitchAlignment = reader.TokenType == JsonTokenType.Null ? default : PitchAlignment.FromString(reader.GetString()); break; case "rotationAlignment": result.RotationAlignment = reader.TokenType == JsonTokenType.Null ? default : PitchAlignment.FromString(reader.GetString()); break; } } } return(result); }
public static void Should_ReturnPitchAlignmentFromString(string pitchAlignmentType) { var pitchAlignment = PitchAlignment.FromString(pitchAlignmentType); Assert.Equal(pitchAlignmentType, pitchAlignment.ToString()); }
public static void Should_ReturnDefaultPitchAlignment_IfStringDoesNotMatch() { var interpolationType = "obviouslyNotAValidOne"; var interpolation = PitchAlignment.FromString(interpolationType); Assert.Equal(default, interpolation);
public override PolygonExtrusionLayerOptions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { var depth = reader.CurrentDepth; var result = new PolygonExtrusionLayerOptions(); while (reader.TokenType != JsonTokenType.EndObject || depth != reader.CurrentDepth) { reader.Read(); if (reader.TokenType == JsonTokenType.PropertyName) { var propertyName = reader.GetString(); if (IsSourceLayerOptionsProperty(propertyName)) { ReadSourceLayerOptionsProperty(propertyName, reader, result); } else { reader.Read(); switch (propertyName) { case "fillOpacity": result.FillOpacity = reader.TokenType == JsonTokenType.Null ? null : reader.GetDouble(); break; case "fillPattern": result.FillPattern = reader.TokenType == JsonTokenType.Null ? null : reader.GetString(); break; case "translate": result.Translate = reader.TokenType == JsonTokenType.Null ? null : JsonSerializer.Deserialize <Pixel>(ref reader, options); break; case "translateAnchor": result.TranslateAnchor = reader.TokenType == JsonTokenType.Null ? default : PitchAlignment.FromString(reader.GetString()); break; case "verticalGradient": result.VerticalGradient = reader.TokenType == JsonTokenType.Null ? null : reader.GetBoolean(); break; } } } } return(result); }