public static object DeserializeObject(char *chars, int length, Type type, JsonFormatterOptions options)
        {
            if ((options & JsonFormatterOptions.MultiReferencingReference) != 0)
            {
                var jsonDeserializer = new JsonReferenceDeserializer(chars, length);

                var result = ValueInterface.GetInterface(type).Read(jsonDeserializer);

                if (jsonDeserializer.references.Count != 0)
                {
                    ReferenceInfo.ProcessReference(result, jsonDeserializer.references);

                    if (jsonDeserializer.updateBase)
                    {
                        result = RWHelper.GetContent <object>(jsonDeserializer.writer);

                        result = Convert.ChangeType(result, type);
                    }
                }

                return(result);
            }

            return(DeserializeObject(chars, length, type));
        }
예제 #2
0
 public static object DeserializeObject(string text, Type type, JsonFormatterOptions options = JsonFormatterOptions.Default)
 {
     fixed(char *chars = text)
     {
         return(ValueInterface.GetInterface(type).ReadValue(new JsonDeserializer(chars, 0, text.Length, options)));
     }
 }
예제 #3
0
 public object Deserialize(string text, Type type)
 {
     fixed(char *chars = text)
     {
         return(ValueInterface.GetInterface(type).ReadValue(new JsonDeserializer(chars, 0, text.Length, Options)));
     }
 }
예제 #4
0
 public static object DeserializeObject(string text, Type type)
 {
     fixed(char *chars = text)
     {
         return(ValueInterface.GetInterface(type).Read(new JsonDeserializer(chars, 0, text.Length)));
     }
 }
예제 #5
0
 static FSharpOptionInterface()
 {
     if (default(T) != null)
     {
         NullableInterface = ValueInterface.GetInterface(typeof(Nullable <>).MakeGenericType(typeof(T)));
     }
 }
예제 #6
0
        private protected override void InitializeByRef(PropertyInfo propertyInfo, XBindingFlags flags)
        {
            base.InitializeByRef(propertyInfo, flags);

            _get = null;
            _set = null;

            @interface = ValueInterface.GetInterface(propertyInfo.PropertyType.GetElementType());
        }
예제 #7
0
 public object DirectRead()
 {
     try
     {
         return(ValueInterface.GetInterface(ReadType()).Read(this));
     }
     catch
     {
         return(null);
     }
 }
예제 #8
0
        object Deserialize <TMode>(byte *bytes, int length, Type type, MessagePackFormatterOptions options) where TMode : struct
        {
            var deserializer = new MessagePackDeserializer <TMode>(this, bytes, length, MaxDepth, options);

            if (typeof(TMode) == typeof(MessagePackDeserializeModes.ReferenceMode))
            {
                deserializer.InitReferences();
            }

            return(ValueInterface.GetInterface(type).Read(deserializer));
        }
예제 #9
0
        private protected override void InitializeByValue(PropertyInfo propertyInfo, XBindingFlags flags)
        {
            base.InitializeByValue(propertyInfo, flags);

            if (_get is null)
            {
                _get = propertyInfo.GetGetMethod((flags & XBindingFlags.NonPublic) != 0);
            }

            if (_set is null)
            {
                _set = propertyInfo.GetSetMethod((flags & XBindingFlags.NonPublic) != 0);
            }

            @interface = ValueInterface.GetInterface(propertyInfo.PropertyType);
        }
예제 #10
0
        public static object DeserializeObject(char *chars, int length, Type type, JsonFormatterOptions options)
        {
            switch (options & ModeOptions)
            {
            case JsonFormatterOptions.MultiReferencingReference:
                return(ValueInterface.GetInterface(type).Read(new JsonDeserializer <JsonDeserializeModes.Reference>(chars, length)));

            case JsonFormatterOptions.DeflateDeserialize:
                return(ValueInterface.GetInterface(type).Read(new JsonDeserializer <JsonDeserializeModes.Deflate>(chars, length)));

            case JsonFormatterOptions.StandardDeserialize:
                return(ValueInterface.GetInterface(type).Read(new JsonDeserializer <JsonDeserializeModes.Standard>(chars, length)));

            default:
                return(ValueInterface.GetInterface(type).Read(new JsonDeserializer <DefaultDeserializeMode>(chars, length)));
            }
        }
예제 #11
0
        public object Deserialize(string text, Type type)
        {
            var options = Options;
            var id      = Id;

            fixed(char *chars = text)
            {
                if ((options & JsonFormatterOptions.MultiReferencingReference) != 0)
                {
                    var jsonDeserializer = new JsonReferenceDeserializer(chars, 0, text.Length);

                    if (id != 0)
                    {
                        jsonDeserializer.id = id;
                    }

                    var result = ValueInterface.GetInterface(type).Read(jsonDeserializer);

                    if (jsonDeserializer.references.Count != 0)
                    {
                        ReferenceInfo.ProcessReference(result, jsonDeserializer.references);

                        if (jsonDeserializer.updateBase)
                        {
                            result = RWHelper.GetContent <object>(jsonDeserializer.writer);

                            result = Convert.ChangeType(result, type);
                        }
                    }

                    return(result);
                }
                else
                {
                    var jsonDeserializer = new JsonDeserializer(chars, 0, text.Length);

                    if (id != 0)
                    {
                        jsonDeserializer.id = id;
                    }

                    return(ValueInterface.GetInterface(type).Read(jsonDeserializer));
                }
            }
        }
예제 #12
0
        /// <summary>
        /// 读取当前行的所有数据并进行筛选,然后将筛选结果写入器数据写入器中。
        /// </summary>
        /// <param name="dataWriter">数据写入器</param>
        /// <param name="valueFilter">值筛选器</param>
        public void OnReadAll(IDataWriter <int> dataWriter, IValueFilter <int> valueFilter)
        {
            int length = dbDataReader.FieldCount;

            var valueInfo = new ValueFilterInfo <int>();

            for (int i = 0; i < length; i++)
            {
                var value = dbDataReader[i];

                ValueInterface.GetInterface(value).Write(valueInfo.ValueCopyer, value);

                valueInfo.Key  = i;
                valueInfo.Type = dbDataReader.GetFieldType(i);

                if (valueFilter.Filter(valueInfo))
                {
                    valueInfo.ValueCopyer.WriteTo(dataWriter[valueInfo.Key]);
                }
            }
        }
예제 #13
0
        /// <summary>
        /// 在数据写入器中写入该类型的实例。
        /// </summary>
        /// <param name="valueWriter">值写入器</param>
        /// <param name="value">该类型的实例</param>
        public void WriteValue(IValueWriter valueWriter, T value)
        {
            if (value == null)
            {
                valueWriter.DirectWrite(null);

                return;
            }

            /* 父类引用,子类实例时使用 Type 获取写入器。 */
            if (CheckChildrenInstance && Int64TypeHandle != (long)TypeHelper.GetTypeHandle(value))
            {
                ValueInterface.GetInterface(value).Write(valueWriter, value);

                return;
            }

            var objectRW = XObjectRW.Create(typeof(T));

            objectRW.Initialize(value);

            valueWriter.WriteObject(objectRW);
        }
예제 #14
0
 public static object ReadScalar(DbDataReader dbDataReader, Type type)
 {
     return(ValueInterface.GetInterface(type).Read(new ReadScalarReader(dbDataReader)));
 }
예제 #15
0
        public void OnReadValue(int key, IValueWriter valueWriter)
        {
            var value = dbDataReader[key];

            ValueInterface.GetInterface(value).Write(valueWriter, value);
        }
예제 #16
0
 public void OnWriteValue(object obj, IValueReader valueReader)
 {
     SetValue(obj, ValueInterface.GetInterface(AfterType).Read(valueReader));
 }
 public static object DeserializeObject(char *chars, int length, Type type)
 {
     return(ValueInterface.GetInterface(type).Read(new JsonDeserializer(chars, length)));
 }
예제 #18
0
 static object DeserializeObject(char *chars, int length, Type type)
 {
     return(ValueInterface.GetInterface(type).Read(new JsonDeserializer <JsonDeserializeModes.Verified>(chars, length)));
 }
예제 #19
0
 static object DeserializeObject(byte *bytes, int length, Type type)
 {
     return(ValueInterface.GetInterface(type).Read(new MessagePackDeserializer <MessagePackDeserializeModes.StandardMode>(bytes, length, DefaultMaxDepth)));
 }
예제 #20
0
        private protected override void Initialize(FieldInfo fieldInfo, XBindingFlags flags)
        {
            @interface = ValueInterface.GetInterface(fieldInfo.FieldType);

            base.Initialize(fieldInfo, flags);
        }
예제 #21
0
 private object InternalDeserialize <TMode>(char *chars, int length, Type type) where TMode : struct
 {
     return(ValueInterface.GetInterface(type).Read(new JsonDeserializer <TMode>(this, chars, length)));
 }