コード例 #1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var output = new Result.OutputDto();
            var key    = "";

            while (reader.Read())
            {
                if (reader.TokenType == JsonToken.PropertyName)
                {
                    key = reader.Value.ToString();
                }

                if (reader.TokenType == JsonToken.Date || reader.TokenType == JsonToken.String)
                {
                    output.SingleValues.Add(ReadProperty(reader, key));
                }

                if (reader.TokenType == JsonToken.StartObject)
                {
                    var    complex    = new ComplexValueResult();
                    string currentKey = null;

                    while (reader.Read())
                    {
                        if (reader.TokenType == JsonToken.EndObject)
                        {
                            break;
                        }

                        if (reader.TokenType == JsonToken.PropertyName)
                        {
                            currentKey = reader.Value.ToString();
                        }

                        if (reader.TokenType == JsonToken.String)
                        {
                            complex.SingleValues.Add(ReadProperty(reader, currentKey));
                        }
                    }

                    output.ComplexValues.Add(key, complex);
                }

                if (reader.TokenType == JsonToken.StartArray)
                {
                    var multiValue = ReadArray(reader);

                    output.MultiValues.Add(key, multiValue);
                }
            }

            return(output);
        }
コード例 #2
0
 public QuestionDto(string type)
 {
     Type   = type;
     Input  = new List <XElement>();
     Output = new OutputDto();
 }