本文整理汇总了C#中Action类的典型用法代码示例。如果您正苦于以下问题:C# Action类的具体用法?C# Action怎么用?C# Action使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Action类属于命名空间,在下文中一共展示了Action类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PosTest1
public bool PosTest1()
{
bool retVal = true;
TestLibrary.TestFramework.BeginScenario("PosTest1: The generic type is int");
try
{
int[] iArray = { 1, 9, 3, 6, -1, 8, 7, 1, 2, 4 };
List<int> listObject = new List<int>(iArray);
MyClass myClass = new MyClass();
Action<int> action = new Action<int>(myClass.sumcalc);
listObject.ForEach(action);
if (myClass.sum != 40)
{
TestLibrary.TestFramework.LogError("001", "The result is not the value as expected,sum is: " + myClass.sum);
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
retVal = false;
}
return retVal;
}
示例2: OnActionExecuted
public void OnActionExecuted(HttpContext httpContext, Action baseAction)
{
DetermineRequestType(HttpContext.Current.Request);
switch (_requestType)
{
case CrossOriginRequestType.Cors:
// If the Origin header is in the request, then process this as a CORS request
// Let the default filter process the request
baseAction();
// Add response headers for the CORS request
var response = httpContext.Response;
// Allow all origins
response.AppendHeader(AccessControlAllowOriginHeader, _origin);
response.AppendHeader(AccessControlAllowCredentials, "true");
break;
default:
baseAction();
break;
}
}
示例3: RepositoryScope
string RepositoryScope(ExecuteCore executeCore = null, Action<EmptyRepositoryFixture, VersionVariables> fixtureAction = null)
{
// Make sure GitVersion doesn't trigger build server mode when we are running the tests
Environment.SetEnvironmentVariable("APPVEYOR", null);
var infoBuilder = new StringBuilder();
Action<string> infoLogger = s => { infoBuilder.AppendLine(s); };
executeCore = executeCore ?? new ExecuteCore(fileSystem);
Logger.SetLoggers(infoLogger, s => { }, s => { });
using (var fixture = new EmptyRepositoryFixture(new Config()))
{
fixture.Repository.MakeACommit();
var vv = executeCore.ExecuteGitVersion(null, null, null, null, false, fixture.RepositoryPath, null);
vv.AssemblySemVer.ShouldBe("0.1.0.0");
vv.FileName.ShouldNotBeNullOrEmpty();
if (fixtureAction != null)
{
fixtureAction(fixture, vv);
}
}
return infoBuilder.ToString();
}
示例4: AddAction
public static void AddAction(string actionName, float delayMs)
{
if (ActionDelayList.Any(a => a.Name == actionName)) return; // Id is in list already
var nAction = new Action {Name = actionName, Delay = delayMs};
ActionDelayList.Add(nAction);
}
示例5: OnCompleted
public void OnCompleted (Action continuation)
{
if (continuation == null)
throw new ArgumentNullException ("continuation");
HandleOnCompleted (task, continuation, true);
}
示例6: Node
/**
* Constructs a node with the specified state, parent, action, and path
* cost.
*
* @param state
* the state in the state space to which the node corresponds.
* @param parent
* the node in the search tree that generated the node.
* @param action
* the action that was applied to the parent to generate the
* node.
* @param pathCost
* full pathCost from the root node to here, typically
* the root's path costs plus the step costs for executing
* the the specified action.
*/
public Node(System.Object state, Node parent, Action action, double stepCost)
: this(state)
{
this.parent = parent;
this.action = action;
this.pathCost = parent.pathCost + stepCost;
}
示例7: Create
public static void Create (Action done)
{
const string section = "PTestPlaytomic.PlayerLevels.Create";
Debug.Log(section);
var level = new PlayerLevel {
name = "create level" + rnd,
playername = "ben" + rnd,
playerid = "0",
data = "this is the level data",
fields = new Dictionary<string,object> {
{"rnd", rnd}
}
};
Playtomic.PlayerLevels.Save (level, (l, r) => {
l = l ?? new PlayerLevel ();
AssertTrue (section + "#1", "Request succeeded", r.success);
AssertEquals (section + "#1", "No errorcode", r.errorcode, 0);
AssertTrue (section + "#1", "Returned level is not null", l.Keys.Count > 0);
AssertTrue (section + "#1", "Returned level has levelid", l.ContainsKey ("levelid"));
AssertEquals (section + "#1", "Level names match", level.name, l.name);
Playtomic.PlayerLevels.Save (level, (l2, r2) => {
AssertTrue (section + "#2", "Request succeeded", r2.success);
AssertEquals (section + "#2", "Duplicate level errorcode", r2.errorcode, 405);
done ();
});
});
}
示例8: animateToColor
private void animateToColor(Color color, float waitDuration, Action completion)
{
LeanTween.
color(gameObject, color, duration).
setEase(LeanTweenType.easeInOutQuad).
setOnComplete(completion).setDelay(waitDuration);
}
示例9: SlowDown
private void SlowDown(BindingList<DebugLine> bindedList, Action<BindingList<DebugLine>> action)
{
var uiSynchronyzer = new UISynchronyzer<IList<IEvent<ListChangedEventArgs>>>();
Observable.FromEvent<ListChangedEventArgs>(bindedList, "ListChanged").BufferWithTime(TimeSpan.FromSeconds(1)).
Subscribe(uiSynchronyzer);
uiSynchronyzer.Subscribe(ev => action(bindedList));
}
示例10: ChooseAction
public override IEnumerator ChooseAction(Action Finish)
{
System.Random r = new System.Random();
GameObject player = GameObject.FindWithTag("Player");
singleAttackTarget = player.transform.parent.gameObject.GetComponent<Battler>();
List<statusEffect> playerStatusEffects = singleAttackTarget.battleState.statusEffects;
if (playerStatusEffects.Exists(se => se.name == "Shapeshifter Toxin"))
{
DoAction = DoubleAttack;
}
else
{
int n = r.Next(3);
if (n == 2) //33% of time
{
DoAction = Toxin;
}
else //66% of time
{
DoAction = BasicAttack;
}
}
Finish();
yield break;
}
示例11: Actor
protected Actor(DrawTag drawTag, string name)
: base(drawTag, name)
{
nextAction = null;
canOpenDoors = false;
energy = 0;
}
示例12: StartCountdown
public void StartCountdown(int hours, int minutes, int seconds, Action callback)
{
countFrom = new TimeSpan(hours, minutes, seconds);
stopWatch = new Stopwatch();
cb = callback;
stopWatch.Start();
}
示例13: ProcessAction
private static void ProcessAction(Action action)
{
var target = GetInstance(action.Type);
var targetMethod = target.GetType().GetMethod(action.Method);
targetMethod.Invoke(target, action.Params);
}
示例14: PosTest2
public bool PosTest2()
{
bool retVal = true;
TestLibrary.TestFramework.BeginScenario("PosTest2: The generic type is type of string");
try
{
string[] strArray = { "Hello", "wor", "l", "d" };
List<string> listObject = new List<string>(strArray);
MyClass myClass = new MyClass();
Action<string> action = new Action<string>(myClass.joinstr);
listObject.ForEach(action);
if (myClass.result != "Helloworld")
{
TestLibrary.TestFramework.LogError("003", "The result is not the value as expected,sum is: " + myClass.sum);
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
retVal = false;
}
return retVal;
}
示例15: createAssetLoad
//-------------------------------------------------------------------------
public override void createAssetLoad(string asset_path, string asset_name, AsyncAssetLoadGroup async_assetloadgroup, Action<UnityEngine.Object> loaded_action)
{
AssetPath = asset_path;
RequestLoadAssetInfo request_loadassetinfo = new RequestLoadAssetInfo();
request_loadassetinfo.AssetName = asset_name;
request_loadassetinfo.LoadedAction = loaded_action;
List<RequestLoadAssetInfo> list_requestloadasssetinfo = null;
MapRequestLoadAssetInfo.TryGetValue(async_assetloadgroup, out list_requestloadasssetinfo);
if (list_requestloadasssetinfo == null)
{
list_requestloadasssetinfo = new List<RequestLoadAssetInfo>();
}
list_requestloadasssetinfo.Add(request_loadassetinfo);
MapRequestLoadAssetInfo[async_assetloadgroup] = list_requestloadasssetinfo;
if (mAssetBundleCreateRequest == null)
{
mAssetBundleCreateRequest = AssetBundle.LoadFromFileAsync(asset_path);
}
}