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


C# Action類代碼示例

本文整理匯總了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;
    }
開發者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


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