本文整理汇总了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);
}
}
示例2: RegisterActionImplementation
public void RegisterActionImplementation(string action, ActionDelegate actionDelegate)
{
Guard.ArgumentNotNullOrEmptyString(action, "action");
Guard.ArgumentNotNull(actionDelegate, "actionDelegate");
_actionImplementations[action] = actionDelegate;
}
示例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;
}
示例4: StartAction
/// <summary>start action</summary>
/// <param name="_func">action 종료 시 실행할 delegate</param>
public void StartAction(ActionDelegate _func)
{
IsStoped = false;
mStopActionDelegate = _func;
InitAction();
ProcAction();
}
示例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));
}
示例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));
}
示例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));
}
示例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;
}
示例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();
}
示例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));
}
示例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;
}
示例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));
}
示例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;
}
示例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));
}
示例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;
}