public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var jTokenReader = (JTokenReader)reader;

            var canonicalDataCase = new CanonicalDataCase();

            serializer.Populate(jTokenReader, canonicalDataCase);

            canonicalDataCase.Properties = CanonicalDataCaseJson.ToDictionary(jTokenReader.CurrentToken);
            canonicalDataCase.SetInputParameters(GetInputProperties(canonicalDataCase.Properties));
            canonicalDataCase.DescriptionPath = GetDescriptionPath(jTokenReader.CurrentToken);

            return(canonicalDataCase);
        }
예제 #2
0
        private static CanonicalDataCase Parse(JToken canonicalDataCaseJToken)
        {
            var canonicalDataCase = new CanonicalDataCase
            {
                Property        = canonicalDataCaseJToken.Value <string>("property"),
                Properties      = ToDictionary(canonicalDataCaseJToken),
                Input           = ToDictionary(canonicalDataCaseJToken["input"]),
                Expected        = ConvertJToken(canonicalDataCaseJToken["expected"]),
                Description     = canonicalDataCaseJToken.Value <string>("description"),
                DescriptionPath = GetDescriptionPath(canonicalDataCaseJToken)
            };

            canonicalDataCase.SetInputParameters(canonicalDataCase.Input.Keys.ToArray());

            return(canonicalDataCase);
        }
예제 #3
0
 private static bool IsEmptyJArray(CanonicalDataCase x, IGrouping <string, KeyValuePair <string, dynamic> > groupedProperties)
 => x.Properties[groupedProperties.Key] is JArray jArray && jArray.Count == 0;