当前位置: 首页>>代码示例>>C#>>正文


C# Delegate.GetInvocationList方法代码示例

本文整理汇总了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.
        }
开发者ID:tijoytom,项目名称:corert,代码行数:59,代码来源:DelegateMethodInfoRetriever.cs

示例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(" )");
 }
开发者ID:quela,项目名称:myprojects,代码行数:10,代码来源:MulticastDelegatesExample.cs

示例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);
        }
    }
开发者ID:Writkas,项目名称:VT--C-Sharp,代码行数:14,代码来源:Delegados4.cs

示例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 {}
      }
    }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:24,代码来源:RoutedEventArgs.cs

示例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;
    }
开发者ID:zhangxiangsong,项目名称:some_work,代码行数:28,代码来源:DelegateFactory.cs

示例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});
		}
开发者ID:Profit0004,项目名称:mono,代码行数:24,代码来源:FileSystemWatcher.cs

示例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);
     }
 }
开发者ID:walrus7521,项目名称:code,代码行数:9,代码来源:Delegate.cs

示例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;
				}
			}
		}
开发者ID:carrie901,项目名称:mono,代码行数:54,代码来源:HttpApplication.jvm.cs

示例9: RunHooksEnumerator

			internal RunHooksEnumerator(HttpApplication app, Delegate list)
			{
				this.app = app;
				delegates = list.GetInvocationList ();
			}
开发者ID:carrie901,项目名称:mono,代码行数:5,代码来源:HttpApplication.jvm.cs


注:本文中的Delegate.GetInvocationList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。