本文整理汇总了C#中Action类的典型用法代码示例。如果您正苦于以下问题:C# Action类的具体用法?C# Action怎么用?C# Action使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Action类属于命名空间,在下文中一共展示了Action类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:l1183479157,项目名称:coreclr,代码行数:27,代码来源:listforeach.cs
示例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;
}
}
开发者ID:raveller,项目名称:raveller,代码行数:26,代码来源:AllowCrossOriginAttribute.cs
示例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();
}
开发者ID:Exterazzo,项目名称:GitVersion,代码行数:26,代码来源:ExecuteCoreTests.cs
示例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);
}
开发者ID:jayblah,项目名称:KallenSharp,代码行数:7,代码来源:Humanizer.cs
示例5: OnCompleted
public void OnCompleted (Action continuation)
{
if (continuation == null)
throw new ArgumentNullException ("continuation");
HandleOnCompleted (task, continuation, true);
}
开发者ID:kazol4433,项目名称:mono,代码行数:7,代码来源:TaskAwaiter.cs
示例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;
}
开发者ID:youthinkk,项目名称:aima-csharp,代码行数:23,代码来源:Node.cs
示例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 ();
});
});
}
开发者ID:cupsster,项目名称:gameapi-unity3d,代码行数:30,代码来源:PTestPlayerLevels.cs
示例8: animateToColor
private void animateToColor(Color color, float waitDuration, Action completion)
{
LeanTween.
color(gameObject, color, duration).
setEase(LeanTweenType.easeInOutQuad).
setOnComplete(completion).setDelay(waitDuration);
}
开发者ID:Incipia,项目名称:SpaceRace,代码行数:7,代码来源:ObjectColorOscillation.cs
示例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));
}
开发者ID:sheigel,项目名称:DbgView.Net,代码行数:7,代码来源:MainWindow.xaml.cs
示例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;
}
开发者ID:seanlazaro,项目名称:JRPG,代码行数:30,代码来源:ShapeshifterBruiser.cs
示例11: Actor
protected Actor(DrawTag drawTag, string name)
: base(drawTag, name)
{
nextAction = null;
canOpenDoors = false;
energy = 0;
}
开发者ID:ggilbert108,项目名称:ProjectR,代码行数:7,代码来源:Actor.cs
示例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();
}
开发者ID:Reintjuu,项目名称:FastType,代码行数:7,代码来源:Countdown.cs
示例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);
}
开发者ID:goranobradovic,项目名称:CommonCodeSnippets,代码行数:7,代码来源:Program.cs
示例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;
}
开发者ID:l1183479157,项目名称:coreclr,代码行数:27,代码来源:listforeach.cs
示例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);
}
}
开发者ID:CragonGame,项目名称:GameCloud.IM,代码行数:26,代码来源:LocalABAsyncAssetLoader.cs
示例16: SCAnimationInfo
public SCAnimationInfo(Action callback, float time)
{
mCallback = callback;
mTime = time;
mStatus = Status.NOT_STARTED;
}
开发者ID:talham7391,项目名称:President-in-Unity,代码行数:7,代码来源:SCAnimationInfo.cs
示例17: Animation
public Animation(Action action, int row, int frames)
{
Action = action;
Row = row;
Frames = frames;
FrameLength = 150;
}
开发者ID:remy22,项目名称:game-1,代码行数:7,代码来源:Animation.cs
示例18: Draw
public virtual void Draw(Action<Graphics> drawAction)
{
if (!IsDisposed && this.offGr != null)
{
drawAction(this.offGr);
}
}
开发者ID:flts,项目名称:fleux,代码行数:7,代码来源:DoubleBufferedControl.cs
示例19: punish
public Action punish(Action action)
{
switch (pissOffLevel)
{
case 0:
return action;
case 1:
return LevelOneAction(action);
case 2:
return LevelTwoAction(action);
case 3:
return LevelThreeAction(action);
case 4:
return LevelFourAction(action);
case 5:
return LevelFiveAction(action);
case 6:
return LevelSixAction(action);
case 7:
return LevelSevenAction(action);
case 8:
return LevelEightAction(action);
case 9:
return LevelNineAction(action);
case 10:
return LevelTenAction(action);
}
return action;
}
开发者ID:abiaco,项目名称:ggj_2016,代码行数:29,代码来源:God.cs
示例20: PathRequest
public PathRequest(Vector3 _start, Vector3 _end, Action<Vector3[], bool> _callback, GameObject unitGObj)
{
pathStart = _start;
pathEnd = _end;
callback = _callback;
unitGObjRequesting = unitGObj;
}
开发者ID:cesarrac,项目名称:AwayTeam,代码行数:7,代码来源:PathRequestManager.cs
注:本文中的Action类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论