/// <summary>
        /// 创建委托
        /// </summary>
        /// <returns></returns>
        public static Action <ISerializerWriter, JsonSerializeSetting, T, byte> Register(JsonSerializeSetting setting)
        {
            Action <ISerializerWriter, JsonSerializeSetting, T, byte> action = null;

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

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

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

                action = new ZzzZzSerialierBuilder <T>().Build(setting);
                caching.TryAdd(setting, action);
                return(action);
            }
        }
Example #2
0
        /// <summary>
        /// 执行builder,反射用到的
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="setting">The setting.</param>
        /// <param name="level"></param>
        /// <param name="source">The source.</param>
        internal static void CallNullablePrimitiveBuilderInvoke <T>(ISerializerWriter writer, JsonSerializeSetting setting, Nullable <T> source, byte level) where T : struct
        {
            if (!source.HasValue)
            {
                writer.Write("null");
                return;
            }

            ZzzZzSerialierBuilder <T> .Register(setting).Invoke(writer, setting, source.Value, level);
        }
Example #3
0
        /// <summary>
        /// 执行builder,反射用到的
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="writer">The writer.</param>
        /// <param name="setting">The setting.</param>
        /// <param name="level"></param>
        /// <param name="source">The source.</param>
        internal static void CallBuilderInvoke <T>(ISerializerWriter writer, JsonSerializeSetting setting, T source, byte level)
        {
            var @delegate = ZzzZzSerialierBuilder <T> .Register(setting);

            @delegate(writer, setting, source, level++);
        }
Example #4
0
 /// <summary>
 /// 执行构建序列化,反射用到的
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="writer"></param>
 /// <param name="setting"></param>
 /// <param name="level"></param>
 /// <param name="object"></param>
 /// <returns></returns>
 private static void BuilderInvoke <T>(ISerializerWriter writer, JsonSerializeSetting setting, object @object, byte level)
 {
     ZzzZzSerialierBuilder <T> .Register(setting).Invoke(writer, setting, (T)@object, level);
 }