scripts
This commit is contained in:
@@ -0,0 +1,172 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
|
||||
namespace System.Runtime.Serialization
|
||||
{
|
||||
// Token: 0x02000491 RID: 1169
|
||||
internal sealed class SerializationCallbacks
|
||||
{
|
||||
// Token: 0x06002C3B RID: 11323 RVA: 0x00091BF8 File Offset: 0x0008FDF8
|
||||
public SerializationCallbacks(Type type)
|
||||
{
|
||||
this.onSerializingList = SerializationCallbacks.GetMethodsByAttribute(type, typeof(OnSerializingAttribute));
|
||||
this.onSerializedList = SerializationCallbacks.GetMethodsByAttribute(type, typeof(OnSerializedAttribute));
|
||||
this.onDeserializingList = SerializationCallbacks.GetMethodsByAttribute(type, typeof(OnDeserializingAttribute));
|
||||
this.onDeserializedList = SerializationCallbacks.GetMethodsByAttribute(type, typeof(OnDeserializedAttribute));
|
||||
}
|
||||
|
||||
// Token: 0x170008A0 RID: 2208
|
||||
// (get) Token: 0x06002C3D RID: 11325 RVA: 0x00091C7C File Offset: 0x0008FE7C
|
||||
public bool HasSerializingCallbacks
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.onSerializingList != null;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170008A1 RID: 2209
|
||||
// (get) Token: 0x06002C3E RID: 11326 RVA: 0x00091C8C File Offset: 0x0008FE8C
|
||||
public bool HasSerializedCallbacks
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.onSerializedList != null;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170008A2 RID: 2210
|
||||
// (get) Token: 0x06002C3F RID: 11327 RVA: 0x00091C9C File Offset: 0x0008FE9C
|
||||
public bool HasDeserializingCallbacks
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.onDeserializingList != null;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170008A3 RID: 2211
|
||||
// (get) Token: 0x06002C40 RID: 11328 RVA: 0x00091CAC File Offset: 0x0008FEAC
|
||||
public bool HasDeserializedCallbacks
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.onDeserializedList != null;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06002C41 RID: 11329 RVA: 0x00091CBC File Offset: 0x0008FEBC
|
||||
private static ArrayList GetMethodsByAttribute(Type type, Type attr)
|
||||
{
|
||||
ArrayList arrayList = new ArrayList();
|
||||
for (Type type2 = type; type2 != typeof(object); type2 = type2.BaseType)
|
||||
{
|
||||
int num = 0;
|
||||
foreach (MethodInfo methodInfo in type2.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
|
||||
{
|
||||
if (methodInfo.IsDefined(attr, false))
|
||||
{
|
||||
arrayList.Add(methodInfo);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
if (num > 1)
|
||||
{
|
||||
throw new TypeLoadException(string.Format("Type '{0}' has more than one method with the following attribute: '{1}'.", type.AssemblyQualifiedName, attr.FullName));
|
||||
}
|
||||
}
|
||||
return (arrayList.Count != 0) ? arrayList : null;
|
||||
}
|
||||
|
||||
// Token: 0x06002C42 RID: 11330 RVA: 0x00091D68 File Offset: 0x0008FF68
|
||||
private static void Invoke(ArrayList list, object target, StreamingContext context)
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SerializationCallbacks.CallbackHandler callbackHandler = null;
|
||||
foreach (object obj in list)
|
||||
{
|
||||
MethodInfo methodInfo = (MethodInfo)obj;
|
||||
callbackHandler = (SerializationCallbacks.CallbackHandler)Delegate.Combine(Delegate.CreateDelegate(typeof(SerializationCallbacks.CallbackHandler), target, methodInfo), callbackHandler);
|
||||
}
|
||||
callbackHandler(context);
|
||||
}
|
||||
|
||||
// Token: 0x06002C43 RID: 11331 RVA: 0x00091DF8 File Offset: 0x0008FFF8
|
||||
public void RaiseOnSerializing(object target, StreamingContext contex)
|
||||
{
|
||||
SerializationCallbacks.Invoke(this.onSerializingList, target, contex);
|
||||
}
|
||||
|
||||
// Token: 0x06002C44 RID: 11332 RVA: 0x00091E08 File Offset: 0x00090008
|
||||
public void RaiseOnSerialized(object target, StreamingContext contex)
|
||||
{
|
||||
SerializationCallbacks.Invoke(this.onSerializedList, target, contex);
|
||||
}
|
||||
|
||||
// Token: 0x06002C45 RID: 11333 RVA: 0x00091E18 File Offset: 0x00090018
|
||||
public void RaiseOnDeserializing(object target, StreamingContext contex)
|
||||
{
|
||||
SerializationCallbacks.Invoke(this.onDeserializingList, target, contex);
|
||||
}
|
||||
|
||||
// Token: 0x06002C46 RID: 11334 RVA: 0x00091E28 File Offset: 0x00090028
|
||||
public void RaiseOnDeserialized(object target, StreamingContext contex)
|
||||
{
|
||||
SerializationCallbacks.Invoke(this.onDeserializedList, target, contex);
|
||||
}
|
||||
|
||||
// Token: 0x06002C47 RID: 11335 RVA: 0x00091E38 File Offset: 0x00090038
|
||||
public static SerializationCallbacks GetSerializationCallbacks(Type t)
|
||||
{
|
||||
SerializationCallbacks serializationCallbacks = (SerializationCallbacks)SerializationCallbacks.cache[t];
|
||||
if (serializationCallbacks != null)
|
||||
{
|
||||
return serializationCallbacks;
|
||||
}
|
||||
object obj = SerializationCallbacks.cache_lock;
|
||||
SerializationCallbacks serializationCallbacks2;
|
||||
lock (obj)
|
||||
{
|
||||
serializationCallbacks = (SerializationCallbacks)SerializationCallbacks.cache[t];
|
||||
if (serializationCallbacks == null)
|
||||
{
|
||||
Hashtable hashtable = (Hashtable)SerializationCallbacks.cache.Clone();
|
||||
serializationCallbacks = new SerializationCallbacks(t);
|
||||
hashtable[t] = serializationCallbacks;
|
||||
SerializationCallbacks.cache = hashtable;
|
||||
}
|
||||
serializationCallbacks2 = serializationCallbacks;
|
||||
}
|
||||
return serializationCallbacks2;
|
||||
}
|
||||
|
||||
// Token: 0x04001127 RID: 4391
|
||||
private const BindingFlags DefaultBindingFlags = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
|
||||
|
||||
// Token: 0x04001128 RID: 4392
|
||||
private readonly ArrayList onSerializingList;
|
||||
|
||||
// Token: 0x04001129 RID: 4393
|
||||
private readonly ArrayList onSerializedList;
|
||||
|
||||
// Token: 0x0400112A RID: 4394
|
||||
private readonly ArrayList onDeserializingList;
|
||||
|
||||
// Token: 0x0400112B RID: 4395
|
||||
private readonly ArrayList onDeserializedList;
|
||||
|
||||
// Token: 0x0400112C RID: 4396
|
||||
private static Hashtable cache = new Hashtable();
|
||||
|
||||
// Token: 0x0400112D RID: 4397
|
||||
private static object cache_lock = new object();
|
||||
|
||||
// Token: 0x020006D0 RID: 1744
|
||||
// (Invoke) Token: 0x060041C8 RID: 16840
|
||||
public delegate void CallbackHandler(StreamingContext context);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user