MakeSerializer_Delegate() { var Type = typeof(t); Action <SerializeData, object> Serializer = (Data, obj) => { var MD = (MulticastDelegate)obj; var Delegates = MD.GetInvocationList(); Data.Data.Write(BitConverter.GetBytes(Delegates.Length), 0, 4); for (int i = 0; i < Delegates.Length; i++) { LoadedFunc LoadedFunc; var Delegate = Delegates[i]; var DelegateMethod = Delegate.Method; Data.TrustToMethod?.Invoke(DelegateMethod); LoadedFunc = Serializere.VisitedInfoSerialize(Data, DelegateMethod, () => { var Key = new LoadedFunc(DelegateMethod); if (Serializere.LoadedFuncs_Ser.TryGetValue(Key, out LoadedFunc) == false) { var TargetType = DelegateMethod.DeclaringType; LoadedFunc = Key; LoadedFunc.NameAsByte = Serializere.Write( DelegateMethod.Name, DelegateMethod.ReflectedType.MidName()); LoadedFunc.SerializerTarget = GetSerialize(TargetType); Serializere.LoadedFuncs_Ser.Add(LoadedFunc); } return(LoadedFunc.NameAsByte, LoadedFunc); });
public override void Make() { var Type = typeof(t); var IsSerializable = Type.GetInterfaces().Where( (c) => { if (c.IsGenericType) { if (c.GetGenericTypeDefinition() == ISerializableType) { return(true); } } return(false); }).FirstOrDefault(); if (IsSerializable != null) { InsertSerializer(() => { var sr = MakeSerializer_Serializable(); return(sr.Serializer, sr.Deserializer); }); } else if (Type == typeof(Delegate)) { InsertSerializer( (Data, obj) => { var DType = obj.GetType(); var Serializer = GetSerialize(DType); Serializere.VisitedInfoSerialize <object>(Data, DType, () => (Serializer.NameAsByte, null)); Serializer.Serializer(Data, obj); }, (Data) => { var Info = Serializere.VisitedInfoDeserialize(Data, () => Serializere.Read(Data)); return(GetSerialize(Info).Deserializer(Data)); }); } else if (Type.GetInterfaces().Where((c) => c == typeof(Collection.Array.Base.IArray)).FirstOrDefault() != null) { InsertSerializer(() => { var sr = MakeSerializer_Monsajem_Array(); return(sr.Serializer, sr.Deserializer); }); } else if (Type.IsInterface) { InsertSerializer(() => { var Sr = SerializeInfo <object> .GetSerialize(); return(Sr.Serializer, Sr.Deserializer); }); } else if (Type.IsArray) { var size = SerializeInfo.GetSerialize(Type.GetElementType()).ConstantSize; if (size != -1) { InsertSerializer(() => { var sr = MakeSerializer_Array_Struct(size); return(sr.Serializer, sr.Deserializer); }); } else { InsertSerializer(() => { var sr = MakeSerializer_Array_Class(); return(sr.Serializer, sr.Deserializer); }); } } else if (Type == typeof(System.Array)) { InsertSerializer(() => { var Sr = SerializeInfo <object> .GetSerialize(); return(Sr.Serializer, Sr.Deserializer); }); } else if (Type == typeof(System.Array)) { InsertSerializer(() => { var sr = MakeSerializer_Array_Class(); return((Data, obj) => { var ar = (System.Array)obj; }, (Data) => { return null; } ); }); } else if (Type.BaseType == typeof(MulticastDelegate)) { InsertSerializer(() => { var sr = MakeSerializer_Delegate(); return(sr.Serializer, sr.Deserializer); }); } else if (Nullable.GetUnderlyingType(Type) != null) { InsertSerializer(() => { var sr = MakeSerializer_Nullable(); return(sr.Serializer, sr.Deserializer); }); } else if (Type.IsValueType) { if (ConstantSize == -1) { InsertSerializer(() => { var sr = MakeSerializer_ValueType(); return(sr.Serializer, sr.Deserializer); }); } else { InsertSerializer(() => (Default_Serializer, Default_Deserializer)); } } else { InsertSerializer(() => { var sr = MakeSerializer_Else(); return(sr.Serializer, sr.Deserializer); }); } }