public CustomDecorator(Type forType, ICustomProtoSerializer customSerializer, int fieldNumber, IProtoSerializer tail) : base(tail) { Helpers.DebugAssert(forType != null); Helpers.DebugAssert(customSerializer != null); this.forType = forType; this.fieldNumber = fieldNumber; this.customSerializer = customSerializer; }
private static bool CustomSerializerHook(Type targetType, int fieldNumber, ref IProtoSerializer serializer) { ICustomProtoSerializer customSerializer = CustomSetting.TryGetCustomSerializer(targetType); if (customSerializer == null) { return(false); } serializer = Activator.CreateInstance(typeof(CustomDecorator), new object[] { targetType, customSerializer, fieldNumber, serializer }) as IProtoSerializer; return(true); }
static public void AddCustomSerializer(Type type, ICustomProtoSerializer customSerializer) { customSerializerMap.Add(type, customSerializer); }