本文整理汇总了C#中ActionDelegate类的典型用法代码示例。如果您正苦于以下问题:C# ActionDelegate类的具体用法?C# ActionDelegate怎么用?C# ActionDelegate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActionDelegate类属于命名空间,在下文中一共展示了ActionDelegate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: StartAction
/// <summary>start action</summary>
/// <param name="_actionName">실행할 action name</param>
/// <param name="_func">action 종료 후 실행할 delegate</param>
public void StartAction(string _actionName, ActionDelegate _func)
{
if (mActionDic[_actionName] != null)
{
mActionDic[_actionName].StartAction(_func);
}
else
{
Debug.LogError("can't find action from " + _actionName);
}
}
开发者ID:schellrom,项目名称:freeevening,代码行数:14,代码来源:ActionMgrBase.cs
示例17: after
protected Timer after(int timeout, ActionDelegate action)
{
var timer = new Timer();
timer.Elapsed += delegate
{
action.Invoke();
timer.Stop();
};
timer.Interval = timeout;
timer.Start();
return timer;
}
开发者ID:andrefsantos,项目名称:gta-iv-multiplayer,代码行数:12,代码来源:Gamemode.cs
示例18: EnableActionSubscribe
/// <summary>
/// Signal that the action Subscribe is supported.
/// </summary>
/// <remarks>The action's availability will be published in the device's service.xml.
/// Subscribe must be overridden if this is called.</remarks>
protected void EnableActionSubscribe()
{
OpenHome.Net.Core.Action action = new OpenHome.Net.Core.Action("Subscribe");
List<String> allowedValues = new List<String>();
action.AddInputParameter(new ParameterString("ClientId", allowedValues));
action.AddInputParameter(new ParameterString("Udn", allowedValues));
action.AddInputParameter(new ParameterString("Service", allowedValues));
action.AddInputParameter(new ParameterUint("RequestedDuration"));
action.AddOutputParameter(new ParameterString("Sid", allowedValues));
action.AddOutputParameter(new ParameterUint("Duration"));
iDelegateSubscribe = new ActionDelegate(DoSubscribe);
EnableAction(action, iDelegateSubscribe, GCHandle.ToIntPtr(iGch));
}
开发者ID:MatthewMiddleweek,项目名称:ohNet,代码行数:18,代码来源:DvOpenhomeOrgSubscriptionLongPoll1.cs
示例19: ActionHandler
public ActionHandler(ControllerFactory owner, MethodInfo methodInfo)
{
this.owner = owner;
this.methodInfo = methodInfo;
this.actionDelegate = ActionDelegateFactory.Create(methodInfo);
this.useThreadPool = true;
var utp = (UseThreadPoolAttribute)methodInfo.GetCustomAttributes(typeof(UseThreadPoolAttribute), false).FirstOrDefault();
if (utp != null)
this.useThreadPool = utp.UseThreadPool;
else
this.useThreadPool = owner.UseThreadPool;
}
开发者ID:toptensoftware,项目名称:manos,代码行数:13,代码来源:ActionHandler.cs
示例20: StartingPlayer
public StartingPlayer()
: base()
{
this.Stage = ActionStages.OnBoard;
if( Properties.Settings.Default.GameVersion == Properties.Resources.FamilyGameVersionString )
{
this.ActionDelegate = new ActionDelegate( this.TakeActionFamily );
}
else if( Properties.Settings.Default.GameVersion == Properties.Resources.RegularGameVersionString )
{
this.ActionDelegate = new ActionDelegate( this.TakeActionRegular );
}
}
开发者ID:tylerbutler,项目名称:agricola,代码行数:14,代码来源:StartingPlayer.cs
注:本文中的ActionDelegate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论