當前位置: 首頁>>代碼示例>>C#>>正文


C# ActionDelegate類代碼示例

本文整理匯總了C#中ActionDelegate的典型用法代碼示例。如果您正苦於以下問題:C# ActionDelegate類的具體用法?C# ActionDelegate怎麽用?C# ActionDelegate使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ActionDelegate類屬於命名空間,在下文中一共展示了ActionDelegate類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main

 static void Main()
 {
     var actionsNames = new[] { "Add", "Subtract", "Multiply", "Divide", "Save", "Remove", "Remove All", "Calculate", "Exit" };
     var actions = new ActionDelegate[] {Add, Subtract, Multiply, Divide, SaveVarInMemory, RemoveVarFromMemory,
                                         RemoveAllVarsFromMemory, Calculate, Close};
     using (var calculator = new CalculatorServiceClient())
     {
         do
         {
             Console.Clear();
             var choice = RunMenu(actionsNames);
             try
             {
                 actions[choice](calculator);
             }
             catch (FaultException fe)
             {
                 Console.WriteLine("FaultException {0} with reason {1}", fe.Message, fe.Reason);
             }
             catch (Exception e)
             {
                 Console.WriteLine("Error: " + e.Message);
             }
             Console.Write("\nPress any key to continue... ");
             Console.ReadKey(true);
         }
         while (!_willClose);
     }
 }
開發者ID:Atiragram,項目名稱:poit-labs,代碼行數:29,代碼來源:Program.cs

示例2: RegisterActionImplementation

        public void RegisterActionImplementation(string action, ActionDelegate actionDelegate)
        {
            Guard.ArgumentNotNullOrEmptyString(action, "action");
            Guard.ArgumentNotNull(actionDelegate, "actionDelegate");

            _actionImplementations[action] = actionDelegate;
        }
開發者ID:0811112150,項目名稱:HappyDayHistory,代碼行數:7,代碼來源:ActionCatalogService.cs

示例3: DelayAction

 public DelayAction(int milliseconds, ActionDelegate actionMethod, bool stopAfterOne)
 {
     this.actionMethod = actionMethod;
     actionTimer.Interval = new TimeSpan(0, 0, 0, 0, milliseconds);
     actionTimer.Tick += new EventHandler(actionTimer_Tick);
     this.stopAfterOne = stopAfterOne;
 }
開發者ID:klot-git,項目名稱:scrum-factory,代碼行數:7,代碼來源:DelayFilter.cs

示例4: StartAction

 /// <summary>start action</summary>
 /// <param name="_func">action 종료 시 실행할 delegate</param>
 public void StartAction(ActionDelegate _func)
 {
     IsStoped = false;
     mStopActionDelegate = _func;
     InitAction();
     ProcAction();            
 }
開發者ID:schellrom,項目名稱:freeevening,代碼行數:9,代碼來源:MonsterActionBase.cs

示例5: EnableActionGetColor

 /// <summary>
 /// Signal that the action GetColor is supported.
 /// </summary>
 /// <remarks>The action's availability will be published in the device's service.xml.
 /// GetColor must be overridden if this is called.</remarks>
 protected void EnableActionGetColor()
 {
     OpenHome.Net.Core.Action action = new OpenHome.Net.Core.Action("GetColor");
     action.AddInputParameter(new ParameterUint("Index"));
     action.AddOutputParameter(new ParameterUint("Color"));
     iDelegateGetColor = new ActionDelegate(DoGetColor);
     EnableAction(action, iDelegateGetColor, GCHandle.ToIntPtr(iGch));
 }
開發者ID:nterry,項目名稱:ohNet,代碼行數:13,代碼來源:DvOpenhomeOrgTestLights1.cs

示例6: Add

		public void Add (String name, String localizedName, string description, ActionDelegate doAction)
		{
			foreach (ActionDescription ad in actions)
				if (ad.name == name)
					return;

			actions.Add (new ActionDescription (name, localizedName, description, doAction));
		}
開發者ID:mono,項目名稱:uia2atk,代碼行數:8,代碼來源:ActionImplementorHelper.cs

示例7: EnableActionUnsubscribe

 /// <summary>
 /// Signal that the action Unsubscribe is supported.
 /// </summary>
 /// <remarks>The action's availability will be published in the device's service.xml.
 /// Unsubscribe must be overridden if this is called.</remarks>
 protected void EnableActionUnsubscribe()
 {
     OpenHome.Net.Core.Action action = new OpenHome.Net.Core.Action("Unsubscribe");
     List<String> allowedValues = new List<String>();
     action.AddInputParameter(new ParameterString("Sid", allowedValues));
     iDelegateUnsubscribe = new ActionDelegate(DoUnsubscribe);
     EnableAction(action, iDelegateUnsubscribe, GCHandle.ToIntPtr(iGch));
 }
開發者ID:MatthewMiddleweek,項目名稱:ohNet,代碼行數:13,代碼來源:DvOpenhomeOrgSubscriptionLongPoll1.cs

示例8: ActionCounter

 public ActionCounter(int fromValue, int toValue, int delta, ActionDelegate binder)
     : base(binder)
 {
     this.fromValue = fromValue;
     this.toValue = toValue;
     this.delta = delta;
     this.current = fromValue;
 }
開發者ID:rfrfrf,項目名稱:SokoSolve-Sokoban,代碼行數:8,代碼來源:ActionCounter.cs

示例9: Time

    public static void Time(string name, int iteration, ActionDelegate action)
    {
        if (String.IsNullOrEmpty(name))
        {
            return;
        }

        if (action == null)
        {
            return;
        }

        //1. Print name
        ConsoleColor currentForeColor = Console.ForegroundColor;
        Console.ForegroundColor = ConsoleColor.Yellow;
        Console.WriteLine(name);


        // 2. Record the latest GC counts
        //GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
        GC.Collect(GC.MaxGeneration);
        int[] gcCounts = new int[GC.MaxGeneration + 1];
        for (int i = 0; i <= GC.MaxGeneration; i++)
        {
            gcCounts[i] = GC.CollectionCount(i);
        }

        // 3. Run action
        Stopwatch watch = new Stopwatch();
        watch.Start();
        long ticksFst = GetCurrentThreadTimes(); //100 nanosecond one tick

        for (int i = 0; i < iteration; i++) action();
        long ticks = GetCurrentThreadTimes() - ticksFst;
        watch.Stop();

        // 4. Print CPU
        Console.ForegroundColor = currentForeColor;
        Console.WriteLine("\tTime Elapsed:\t\t" +
           watch.ElapsedMilliseconds.ToString("N0") + "ms");
        Console.WriteLine("\tTime Elapsed (one time):" +
           (watch.ElapsedMilliseconds / iteration).ToString("N0") + "ms");

        Console.WriteLine("\tCPU time:\t\t" + (ticks * 100).ToString("N0")
           + "ns");
        Console.WriteLine("\tCPU time (one time):\t" + (ticks * 100 /
           iteration).ToString("N0") + "ns");

        // 5. Print GC
        for (int i = 0; i <= GC.MaxGeneration; i++)
        {
            int count = GC.CollectionCount(i) - gcCounts[i];
            Console.WriteLine("\tGen " + i + ": \t\t\t" + count);
        }

        Console.WriteLine();

    }
開發者ID:Nacro8,項目名稱:xiaobier,代碼行數:58,代碼來源:CodeTimer.cs

示例10: EnableActionGetPropertyUpdates

 /// <summary>
 /// Signal that the action GetPropertyUpdates is supported.
 /// </summary>
 /// <remarks>The action's availability will be published in the device's service.xml.
 /// GetPropertyUpdates must be overridden if this is called.</remarks>
 protected void EnableActionGetPropertyUpdates()
 {
     OpenHome.Net.Core.Action action = new OpenHome.Net.Core.Action("GetPropertyUpdates");
     List<String> allowedValues = new List<String>();
     action.AddInputParameter(new ParameterString("ClientId", allowedValues));
     action.AddOutputParameter(new ParameterString("Updates", allowedValues));
     iDelegateGetPropertyUpdates = new ActionDelegate(DoGetPropertyUpdates);
     EnableAction(action, iDelegateGetPropertyUpdates, GCHandle.ToIntPtr(iGch));
 }
開發者ID:openhome,項目名稱:ohNet,代碼行數:14,代碼來源:DvOpenhomeOrgSubscriptionLongPoll1.cs

示例11: KeyboardAction

 public KeyboardAction(Keys key, bool shift, bool control, bool alt, bool
     allowreadonly, ActionDelegate actionDelegate)
 {
     this.Key = key;
     this.Control = control;
     this.Alt = alt;
     this.Shift = shift;
     this.Action = actionDelegate;
     this.AllowReadOnly = allowreadonly;
 }
開發者ID:BradFuller,項目名稱:pspplayer,代碼行數:10,代碼來源:KeyboardAction.cs

示例12: EnableActionRenew

 /// <summary>
 /// Signal that the action Renew is supported.
 /// </summary>
 /// <remarks>The action's availability will be published in the device's service.xml.
 /// Renew must be overridden if this is called.</remarks>
 protected void EnableActionRenew()
 {
     OpenHome.Net.Core.Action action = new OpenHome.Net.Core.Action("Renew");
     List<String> allowedValues = new List<String>();
     action.AddInputParameter(new ParameterString("Sid", allowedValues));
     action.AddInputParameter(new ParameterUint("RequestedDuration"));
     action.AddOutputParameter(new ParameterUint("Duration"));
     iDelegateRenew = new ActionDelegate(DoRenew);
     EnableAction(action, iDelegateRenew, GCHandle.ToIntPtr(iGch));
 }
開發者ID:openhome,項目名稱:ohNet,代碼行數:15,代碼來源:DvOpenhomeOrgSubscriptionLongPoll1.cs

示例13: KeyboardAction

 public KeyboardAction(Keys key, bool shift, bool control, bool alt, bool allowreadonly,
     ActionDelegate actionDelegate)
 {
     Key = key;
     Control = control;
     Alt = alt;
     Shift = shift;
     Action = actionDelegate;
     AllowReadOnly = allowreadonly;
 }
開發者ID:hksonngan,項目名稱:sharptracing,代碼行數:10,代碼來源:KeyboardAction.cs

示例14: EnableActionGetColorComponents

 /// <summary>
 /// Signal that the action GetColorComponents is supported.
 /// </summary>
 /// <remarks>The action's availability will be published in the device's service.xml.
 /// GetColorComponents must be overridden if this is called.</remarks>
 protected void EnableActionGetColorComponents()
 {
     OpenHome.Net.Core.Action action = new OpenHome.Net.Core.Action("GetColorComponents");
     action.AddInputParameter(new ParameterUint("Color"));
     action.AddOutputParameter(new ParameterUint("Brightness"));
     action.AddOutputParameter(new ParameterUint("Red"));
     action.AddOutputParameter(new ParameterUint("Green"));
     action.AddOutputParameter(new ParameterUint("Blue"));
     iDelegateGetColorComponents = new ActionDelegate(DoGetColorComponents);
     EnableAction(action, iDelegateGetColorComponents, GCHandle.ToIntPtr(iGch));
 }
開發者ID:nterry,項目名稱:ohNet,代碼行數:16,代碼來源:DvOpenhomeOrgTestLights1.cs

示例15: setTimer

 protected Timer setTimer(int interval, ActionDelegate action)
 {
     var timer = new Timer();
     timer.Elapsed += delegate
     {
         action.Invoke();
     };
     timer.Interval = interval;
     timer.Start();
     return timer;
 }
開發者ID:andrefsantos,項目名稱:gta-iv-multiplayer,代碼行數:11,代碼來源:Gamemode.cs


注:本文中的ActionDelegate類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。