Пример #1
0
 public void Convert(Region source, Region4 target)
 {
     target.StartLine   = source.StartLine;
     target.StartColumn = source.StartColumn;
     target.EndLine     = source.EndLine;
     target.EndColumn   = source.EndColumn;
     target.ByteOffset  = source.ByteOffset;
     target.ByteLength  = source.ByteLength;
     target.CharOffset  = source.CharOffset;
     target.CharLength  = source.CharLength;
 }
Пример #2
0
        public RegionTable Convert(IList <Region> regions)
        {
            RegionTable table = new RegionTable();

            for (int i = 0; i < regions.Count; ++i)
            {
                Region4 region = new Region4(table);
                Convert(regions[i], region);
            }

            return(table);
        }
Пример #3
0
        public override RegionTable ReadJson(JsonReader reader, Type objectType, [AllowNull] RegionTable existingValue, bool hasExistingValue, JsonSerializer serializer)
        {
            RegionTable result = existingValue ?? new RegionTable();

            Expect(reader, JsonToken.StartArray, "List<Region4>");

            while (reader.TokenType != JsonToken.EndArray)
            {
                Region4 item = result.Add();
                DeserializeRegion4(reader, item);
            }

            Expect(reader, JsonToken.EndArray, "List<Region4>");
            return(result);
        }
Пример #4
0
        public void DeserializeRegion4(JsonReader reader, Region4 result)
        {
            Expect(reader, JsonToken.StartObject, "Region4");

            while (reader.TokenType == JsonToken.PropertyName)
            {
                string propertyName = reader.Value.ToString();

                if (!regionFieldParsers.TryGetValue(propertyName, out Action <JsonReader, Region4> parser))
                {
                    throw new NotImplementedException($"Unknown property Region.{propertyName}. Stopping.");
                }

                parser(reader, result);
                reader.Read();
            }

            Expect(reader, JsonToken.EndObject, "Region4");
        }