/// <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); } }
/// <summary> /// 进行构建 /// </summary> /// <returns></returns> public static Action <ISerializerWriter, JsonSerializeSetting, TException, byte> Register(JsonSerializeSetting setting) { if (action != null) { return(action); } lock (locker) { if (action != null) { return(action); } var customSerialierBuilder = CustomSerializationProvider.QueryCustomeSerilizerbuilder <TException>(); if (customSerialierBuilder != null) { return(action = customSerialierBuilder.Build(setting)); } return(action = new ExceptionSerialierBuilder <TException>().Build(setting)); } }
/// <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 CallCustomeBuilderInvoke <T>(ISerializerWriter writer, JsonSerializeSetting setting, T source, byte level) { var @delegate = CustomSerializationProvider.QueryCustomeSerilizerbuilder <T>().Build(setting); @delegate(writer, setting, source, level++); }