Ejemplo n.º 1
0
        internal override BlittableJsonReaderObject ReadJson(BlittableJsonReader blittableReader)
        {
            if (!(blittableReader.Value is BlittableJsonReaderObject blittableValue))
            {
                throw new SerializationException(
                          $"Can't convert {blittableReader.Value?.GetType()} type to {nameof(BlittableJsonReaderObject)}. The value must to be a complex object");
            }

            if (blittableReader.TokenType == JsonToken.StartObject)
            {
                //Because the value that return is the blittable as a whole
                //we skip the reading inside this blittable
                blittableReader.SkipBlittableInside();
            }

            return
                (blittableValue.BelongsToContext(blittableReader.Context) &&
                 blittableValue.HasParent == false
                    ? blittableValue
                    : blittableValue.Clone(blittableReader.Context));
        }