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


C# Action.GetInvocationList方法代码示例

本文整理汇总了C#中System.Action.GetInvocationList方法的典型用法代码示例。如果您正苦于以下问题:C# Action.GetInvocationList方法的具体用法?C# Action.GetInvocationList怎么用?C# Action.GetInvocationList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Action的用法示例。


在下文中一共展示了Action.GetInvocationList方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderMenu

        private static void RenderMenu(Action examples)
        {
            Console.WriteLine("Select an example:");
              for (int i = 0; i < examples.GetInvocationList().Count(); i++)
              {
            var action = examples.GetInvocationList().ToArray()[i];
            Console.WriteLine("  {0} - {1}", i, action.Method.DeclaringType.Name);
              }

              Console.Write(">");
        }
开发者ID:robhalevt,项目名称:20140421_VTdotNET_DelegationAndDelegates,代码行数:11,代码来源:Program.cs

示例2: AddTaskDelay

        private static void AddTaskDelay(Action action, int delayInMilliseconds)
        {
            System.Threading.Thread.Sleep(delayInMilliseconds);
            bool bFired;

            if (action != null)
            {
                foreach (Delegate singleCast in action.GetInvocationList())
                {
                    bFired = false;
                    try
                    {
                        ISynchronizeInvoke syncInvoke = (ISynchronizeInvoke)singleCast.Target;
                        if (syncInvoke != null && syncInvoke.InvokeRequired)
                        {
                            bFired = true;
                            syncInvoke.BeginInvoke(singleCast, null);
                        }
                        else
                        {
                            bFired = true;
                            singleCast.DynamicInvoke(null);
                        }
                    }
                    catch (Exception)
                    {
                        if (!bFired)
                            singleCast.DynamicInvoke(null);
                    }
                }
            }
        }
开发者ID:henriqueuller,项目名称:sharpot,代码行数:32,代码来源:Scheduler.cs

示例3: IdentifySelection

        private static int IdentifySelection(Action examples)
        {
            var selection = Console.ReadLine();

              int index;
              if (!int.TryParse(selection, out index))
              {
            // put it out of range
            index = examples.GetInvocationList().Count();
              }

              return index;
        }
开发者ID:robhalevt,项目名称:20140421_VTdotNET_DelegationAndDelegates,代码行数:13,代码来源:Program.cs

示例4: Running

        public Running(Action action)
        {
            this.action = action;

            try
            {
                foreach (var action_delegate in action.GetInvocationList())
                {
                    action_delegate.DynamicInvoke();
                }
            }
            catch (Exception e)
            {
                exception = e.InnerException;
            }
        }
开发者ID:maodd,项目名称:nbdn_prep,代码行数:16,代码来源:Running.cs

示例5: ExecuteDelegateExample

        private static void ExecuteDelegateExample(Action examples, int selectedIndex)
        {
            var counter = 0;
              foreach (Action action in examples.GetInvocationList())
              {
            if (counter.Equals(selectedIndex))
            {
              Console.WriteLine("{1}{0}{1}{2}", action.Method.DeclaringType, Environment.NewLine, new string('-', 20));
              try
              {
            action();
              }
              catch (Exception exception)
              {
            Console.WriteLine(exception);
              }

              break;
            }

            counter++;
              }
        }
开发者ID:robhalevt,项目名称:20140421_VTdotNET_DelegationAndDelegates,代码行数:23,代码来源:Program.cs

示例6: RaiseEvent

 private void RaiseEvent(Action<string, byte[]> handler, string key, RedisResult value)
 {
     if (handler == null) return;
     foreach (Action<string, byte[]> child in handler.GetInvocationList())
     {
         try
         {
             child(key, value.ValueBytes);
         }
         catch (Exception ex)
         {
             OnError("Subscriber callback", ex, false);
         }
     }
 }
开发者ID:jorik041,项目名称:booksleeve-unofficial,代码行数:15,代码来源:RedisSubscriberConnection.cs

示例7: AddUnique

 private Action AddUnique(Action listeners, Action callback)
 {
     if (!listeners.GetInvocationList().Contains(callback))
     {
         listeners += callback;
     }
     return listeners;
 }
开发者ID:5941120,项目名称:UnitySample,代码行数:8,代码来源:Signal.cs

示例8: InvokeDuringEventWithBehaviorDecision

        private static MethodBehaviors InvokeDuringEventWithBehaviorDecision(Action<DuringCallbackEventArgs> call, DuringCallbackEventArgs args)
        {
            if (call == null) {
                return MethodBehaviors.IDontCare;
            }
            bool wasLastOptionChangedAtLeastOnce = false;
            MethodBehaviors lastOption = args.MethodBehavior;
            Aspect lastAspect = null;

            Delegate[] list = call.GetInvocationList();
            foreach (Delegate d2 in list) {
                try {
                    Action<DuringCallbackEventArgs> invokeEvent = d2 as Action<DuringCallbackEventArgs>;
                    args.MethodBehavior = MethodBehaviors.IDontCare;
                    args.WasBehaviorSet = false;

                    invokeEvent(args);
                    bool wasRealBehaviorSet = args.WasBehaviorSet && args.MethodBehavior != MethodBehaviors.IDontCare;
                    bool isNewBehaviorConflictingWithOlderBehaviorRequest = wasRealBehaviorSet && lastOption != MethodBehaviors.IDontCare;
                    bool isThisTheFirstRealBehaviorSelection = wasRealBehaviorSet && !wasLastOptionChangedAtLeastOnce;

                    //var aspect = GetAspectHandledBy(invokeEvent);

                    if (isThisTheFirstRealBehaviorSelection) {
                        wasLastOptionChangedAtLeastOnce = true;
                        lastAspect = GetAspectHandledBy(invokeEvent);
                        lastOption = args.MethodBehavior;
                        continue;
                    }

                    if (isNewBehaviorConflictingWithOlderBehaviorRequest) {
                        Aspect currentAspect = GetAspectHandledBy(invokeEvent);
                        string msg = BuildConflictMessage(args, lastOption, lastAspect, currentAspect);
                        throw new ConflictingBehaviorException(msg);
                    }
                    if (args.MethodBehavior != MethodBehaviors.IDontCare) {
                        lastAspect = GetAspectHandledBy(invokeEvent);
                        lastOption = args.MethodBehavior;
                    }
                }

                catch (Exception e) {
                    args.MethodBehavior = MethodBehaviors.ThrowException;
                    args.ReturnValueOrException = e;
                    return MethodBehaviors.ThrowException;
                }
            }

            return lastOption;
        }
开发者ID:royosherove,项目名称:cthru,代码行数:50,代码来源:CThruEngine.cs

示例9: AddUnique

		void AddUnique(ref Action listeners, Action callback) //ref because it's initially null
		{
			if (listeners == null || !listeners.GetInvocationList().Contains(callback)) {
				listeners += callback;
			}
		}
开发者ID:skrohn,项目名称:MemoWar,代码行数:6,代码来源:Signal.cs

示例10: RemoveAll

 public static Action<Danmaku> RemoveAll(this Action<Danmaku> source, Action<Danmaku> toRemove) {
     Delegate[] elements = toRemove.GetInvocationList();
     foreach (var element in elements)
         source = Delegate.Remove(source, element) as Action<Danmaku>;
     return source;
 }
开发者ID:tng2903,项目名称:DanmakU,代码行数:6,代码来源:DanmakuControllerExtensions.cs


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