scripts
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
|
||||
namespace System.Runtime.InteropServices
|
||||
{
|
||||
/// <summary>Enables customization of managed objects that extend from unmanaged objects during creation.</summary>
|
||||
// Token: 0x02000310 RID: 784
|
||||
[ComVisible(true)]
|
||||
public sealed class ExtensibleClassFactory
|
||||
{
|
||||
// Token: 0x060021F5 RID: 8693 RVA: 0x00079448 File Offset: 0x00077648
|
||||
private ExtensibleClassFactory()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060021F7 RID: 8695 RVA: 0x0007945C File Offset: 0x0007765C
|
||||
internal static ObjectCreationDelegate GetObjectCreationCallback(Type t)
|
||||
{
|
||||
return ExtensibleClassFactory.hashtable[t] as ObjectCreationDelegate;
|
||||
}
|
||||
|
||||
/// <summary>Registers a delegate that is called when an instance of a managed type, that extends from an unmanaged type, needs to allocate the aggregated unmanaged object.</summary>
|
||||
/// <param name="callback">A delegate that is called in place of CoCreateInstance. </param>
|
||||
// Token: 0x060021F8 RID: 8696 RVA: 0x00079470 File Offset: 0x00077670
|
||||
public static void RegisterObjectCreationCallback(ObjectCreationDelegate callback)
|
||||
{
|
||||
int i = 1;
|
||||
StackTrace stackTrace = new StackTrace(false);
|
||||
while (i < stackTrace.FrameCount)
|
||||
{
|
||||
StackFrame frame = stackTrace.GetFrame(i);
|
||||
MethodBase method = frame.GetMethod();
|
||||
if (method.MemberType == MemberTypes.Constructor && method.IsStatic)
|
||||
{
|
||||
ExtensibleClassFactory.hashtable.Add(method.DeclaringType, callback);
|
||||
return;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
throw new InvalidOperationException("RegisterObjectCreationCallback must be called from .cctor of class derived from ComImport type.");
|
||||
}
|
||||
|
||||
// Token: 0x04000D18 RID: 3352
|
||||
private static Hashtable hashtable = new Hashtable();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user