using System; namespace SerializableCallback { /// /// https://github.com/Siccity/SerializableCallback /// public abstract class SerializableEventBase : SerializableCallbackBase { /// /// https://github.com/Siccity/SerializableCallback /// public InvokableEventBase invokable; /// /// https://github.com/Siccity/SerializableCallback /// public override void ClearCache() { base.ClearCache(); invokable = null; } /// /// https://github.com/Siccity/SerializableCallback /// /// An instance of serialized event protected InvokableEventBase GetPersistentMethod() { Type[] types = new Type[ArgTypes.Length]; Array.Copy(ArgTypes, types, ArgTypes.Length); Type genericType = null; switch (types.Length) { case 0: genericType = typeof(InvokableEvent); break; case 1: genericType = typeof(InvokableEvent<>).MakeGenericType(types); break; case 2: genericType = typeof(InvokableEvent<,>).MakeGenericType(types); break; case 3: genericType = typeof(InvokableEvent<, ,>).MakeGenericType(types); break; case 4: genericType = typeof(InvokableEvent<, , ,>).MakeGenericType(types); break; default: throw new ArgumentException(types.Length + "args"); } return Activator.CreateInstance(genericType, new object[] { target, methodName }) as InvokableEventBase; } } }