Пример #1
0
        internal static Nullable <T> CallNullableObjectInvoke <T>(IDeserializerReader reader, JsonDeserializeSetting setting, string name, int arrayLevel) where T : struct
        {
            if (reader.Count == 0)
            {
                return(null);
            }

            var node = reader.Read(name);

            if (node == null)
            {
                return(null);
            }

            var nodeValue = node.GetValue();

            if (node != null && StringMethodProvider.Default.IsNullValue(nodeValue))
            {
                return(null);
            }

            if (node != null && node.NodeType == ContentNodeType.Object)
            {
                return(ZzzZzDeserializerBuilder <T> .Register(setting).Invoke(reader.Parse(node), setting, arrayLevel));
            }

            return(ZzzZzDeserializerBuilder <T> .Register(setting).Invoke(reader, setting, arrayLevel));
        }
Пример #2
0
        /// <summary>
        /// 创建委托
        /// </summary>
        /// <returns></returns>
        public static Func <IDeserializerReader, JsonDeserializeSetting, int, T> Register(JsonDeserializeSetting setting)
        {
            Func <IDeserializerReader, JsonDeserializeSetting, int, T> func = null;

            if (caching.TryGetValue(setting, out func))
            {
                return(func);
            }

            lock (caching)
            {
                if (caching.TryGetValue(setting, out func))
                {
                    return(func);
                }

                var customSerialierBuilder = CustomSerializationProvider.QueryCustomeDeserilizerbuilder <T>();
                if (customSerialierBuilder != null)
                {
                    func = customSerialierBuilder.Build(setting);
                    caching.TryAdd(setting, func);
                    return(func);
                }

                func = new ZzzZzDeserializerBuilder <T>().Build(setting);
                caching.TryAdd(setting, func);
                return(func);
            }
        }
Пример #3
0
        internal static T CallObjectInvoke <T>(IDeserializerReader reader, JsonDeserializeSetting setting, string name, int arrayLevel)
        {
            var node = reader.Read(name);

            if (node == null)
            {
                return(default(T));
            }

            var nodeValue = node.GetValue();

            if (nodeValue != null && StringMethodProvider.Default.IsNullValue(nodeValue))
            {
                return(default(T));
            }

            return(ZzzZzDeserializerBuilder <T> .Register(setting).Invoke(reader.Parse(node), setting, arrayLevel));
        }
Пример #4
0
        /// <summary>
        /// 执行builder,反射用到的
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="reader">The writer.</param>
        /// <param name="setting">The setting.</param>
        /// <param name="name"></param>
        /// <param name="arrayLevel">层次</param>
        internal static T CallBuilderInvoke <T>(IDeserializerReader reader, JsonDeserializeSetting setting, string name, int arrayLevel)
        {
            var @delegate = ZzzZzDeserializerBuilder <T> .Register(setting);

            return(name == null? @delegate.Invoke(reader, setting, arrayLevel) : @delegate.Invoke(reader.Parse(reader.Read(name)), setting, arrayLevel));
        }