本文整理汇总了C#中Delegate.GetInvocationList方法的典型用法代码示例。如果您正苦于以下问题:C# Delegate.GetInvocationList方法的具体用法?C# Delegate.GetInvocationList怎么用?C# Delegate.GetInvocationList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Delegate
的用法示例。
在下文中一共展示了Delegate.GetInvocationList方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDelegateMethodInfo
public static MethodInfo GetDelegateMethodInfo(Delegate del)
{
if (del == null)
throw new ArgumentException();
Delegate[] invokeList = del.GetInvocationList();
del = invokeList[invokeList.Length - 1];
RuntimeTypeHandle typeOfFirstParameterIfInstanceDelegate;
bool isOpenResolver;
IntPtr originalLdFtnResult = RuntimeAugments.GetDelegateLdFtnResult(del, out typeOfFirstParameterIfInstanceDelegate, out isOpenResolver);
if (originalLdFtnResult == (IntPtr)0)
return null;
MethodHandle methodHandle = default(MethodHandle);
RuntimeTypeHandle[] genericMethodTypeArgumentHandles = null;
bool callTryGetMethod = true;
unsafe
{
if (isOpenResolver)
{
OpenMethodResolver* resolver = (OpenMethodResolver*)originalLdFtnResult;
if (resolver->ResolverType == OpenMethodResolver.OpenNonVirtualResolve)
{
originalLdFtnResult = resolver->CodePointer;
// And go on to do normal ldftn processing.
}
else if (resolver->ResolverType == OpenMethodResolver.DispatchResolve)
{
callTryGetMethod = false;
methodHandle = resolver->Handle.AsMethodHandle();
genericMethodTypeArgumentHandles = null;
}
else
{
System.Diagnostics.Debug.Assert(resolver->ResolverType == OpenMethodResolver.GVMResolve);
callTryGetMethod = false;
methodHandle = resolver->Handle.AsMethodHandle();
RuntimeTypeHandle declaringTypeHandleIgnored;
MethodNameAndSignature nameAndSignatureIgnored;
if (!TypeLoaderEnvironment.Instance.TryGetRuntimeMethodHandleComponents(resolver->GVMMethodHandle, out declaringTypeHandleIgnored, out nameAndSignatureIgnored, out genericMethodTypeArgumentHandles))
return null;
}
}
}
if (callTryGetMethod)
{
if (!ReflectionExecution.ExecutionEnvironment.TryGetMethodForOriginalLdFtnResult(originalLdFtnResult, ref typeOfFirstParameterIfInstanceDelegate, out methodHandle, out genericMethodTypeArgumentHandles))
return null;
}
MethodBase methodBase = ReflectionCoreExecution.ExecutionDomain.GetMethod(typeOfFirstParameterIfInstanceDelegate, methodHandle, genericMethodTypeArgumentHandles);
MethodInfo methodInfo = methodBase as MethodInfo;
if (methodInfo != null)
return methodInfo;
return null; // GetMethod() returned a ConstructorInfo.
}
示例2: PrintInvocationList
public static void PrintInvocationList(Delegate someDelegate)
{
Console.Write("(");
Delegate[] list = someDelegate.GetInvocationList();
foreach (Delegate del in list)
{
Console.Write(" {0}", del.Method.Name);
}
Console.WriteLine(" )");
}
示例3: InfoDelegado
public static void InfoDelegado(Delegate objDel)
{
Console.WriteLine("-- Información del objeto delegado --");
if (objDel == null) {
Console.WriteLine("\tEl objeto delegado no referencia ningún método");
return;
}
foreach (Delegate d in objDel.GetInvocationList()) {
Console.WriteLine("\tMétodo: {0}", d.Method);
Console.WriteLine("\tClase: {0}", d.Target);
}
}
示例4: InvokeEventHandler
protected virtual void InvokeEventHandler(Delegate handler, object target)
{
// Roy Osherove
// http://weblogs.asp.net/rosherove/articles/DefensiveEventPublishing.aspx
if (handler == null)
{
return;
}
foreach (Delegate sink in handler.GetInvocationList())
{
try
{
sink.Method.Invoke(target, new object[] {_source, this});
if (_isHandled)
{
return;
}
}
catch {}
}
}
示例5: RemoveDelegate
public static Delegate RemoveDelegate(Delegate obj, Delegate dg)
{
LuaDelegate remove = dg.Target as LuaDelegate;
if (remove == null)
{
obj = Delegate.Remove(obj, dg);
return obj;
}
LuaState state = remove.func.GetLuaState();
Delegate[] ds = obj.GetInvocationList();
for (int i = 0; i < ds.Length; i++)
{
LuaDelegate ld = ds[i].Target as LuaDelegate;
if (ld != null && ld == remove)
{
obj = Delegate.Remove(obj, ds[i]);
state.DelayDispose(ld.func);
state.DelayDispose(ld.self);
break;
}
}
return obj;
}
示例6: RaiseEvent
private void RaiseEvent (Delegate ev, EventArgs arg, EventType evtype)
{
if (ev == null)
return;
if (synchronizingObject == null) {
foreach (var target in ev.GetInvocationList()) {
switch (evtype) {
case EventType.RenameEvent:
((RenamedEventHandler)target).BeginInvoke (this, (RenamedEventArgs)arg, null, null);
break;
case EventType.ErrorEvent:
((ErrorEventHandler)target).BeginInvoke (this, (ErrorEventArgs)arg, null, null);
break;
case EventType.FileSystemEvent:
((FileSystemEventHandler)target).BeginInvoke (this, (FileSystemEventArgs)arg, null, null);
break;
}
}
return;
}
synchronizingObject.BeginInvoke (ev, new object [] {this, arg});
}
示例7: DisplayDelegateInfo
static void DisplayDelegateInfo(Delegate delObj)
{
// print names of each member
foreach (Delegate d in delObj.GetInvocationList())
{
Console.WriteLine("Method Name: {0}", d.Method);
Console.WriteLine("Type Name: {0}", d.Target);
}
}
示例8: RunHooks
IEnumerable RunHooks (Delegate list)
{
Delegate [] delegates = list.GetInvocationList ();
foreach (EventHandler d in delegates){
if (d.Target != null && (d.Target is AsyncInvoker)){
current_ai = (AsyncInvoker) d.Target;
try {
must_yield = true;
in_begin = true;
context.BeginTimeoutPossible ();
current_ai.begin (this, EventArgs.Empty, async_callback_completed_cb, current_ai.data);
} catch (ThreadAbortException taex){
object obj = taex.ExceptionState;
Thread.ResetAbort ();
stop_processing = true;
if (obj is StepTimeout)
ProcessError (new HttpException ("The request timed out."));
} catch (Exception e){
ProcessError (e);
} finally {
in_begin = false;
context.EndTimeoutPossible ();
}
//
// If things are still moving forward, yield this
// thread now
//
if (must_yield)
yield return stop_processing;
else if (stop_processing)
yield return true;
} else {
try {
context.BeginTimeoutPossible ();
d (this, EventArgs.Empty);
} catch (ThreadAbortException taex){
object obj = taex.ExceptionState;
Thread.ResetAbort ();
stop_processing = true;
if (obj is StepTimeout)
ProcessError (new HttpException ("The request timed out."));
} catch (Exception e){
ProcessError (e);
} finally {
context.EndTimeoutPossible ();
}
if (stop_processing)
yield return true;
}
}
}
示例9: RunHooksEnumerator
internal RunHooksEnumerator(HttpApplication app, Delegate list)
{
this.app = app;
delegates = list.GetInvocationList ();
}