private static CsdlExpressionBase ParseExpression(string json, out JsonParserContext context) { using (JsonDocument document = JsonDocument.Parse(json)) { JsonElement rootElement = document.RootElement; context = new JsonParserContext(); return(AnnotationJsonParser.ParseExpression(rootElement, context)); } }
private static CsdlAnnotation ParseAnnotation(string annotation, out JsonParserContext context) { string wrapper = "{" + annotation + "}"; using (JsonDocument document = JsonDocument.Parse(wrapper)) { JsonElement rootElement = document.RootElement; context = new JsonParserContext(); Assert.Equal(JsonValueKind.Object, rootElement.ValueKind); // only one property JsonProperty property = Assert.Single(rootElement.EnumerateObject()); bool ok = AnnotationJsonParser.TryParseCsdlAnnotation(property.Name, property.Value, context, out CsdlAnnotation csdlAnnotation); Assert.True(ok); return(csdlAnnotation); } }