C# (CSharp) Action, 0 примеры использования

C# (CSharp) Action - 30 примеров найдено. Это лучшие примеры C# (CSharp) кода для Action, полученные из open source проектов. Вы можете ставить оценку каждому примеру, чтобы помочь нам улучшить качество примеров.
Пример #1
0
    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;
    }
            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
0
    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
0
        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
0
		public void OnCompleted (Action continuation)
		{
			if (continuation == null)
				throw new ArgumentNullException ("continuation");

			HandleOnCompleted (task, continuation, true);
		}
Пример #6
0
 /**
  * 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
0
	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
0
 private void animateToColor(Color color, float waitDuration, Action completion)
 {
     LeanTween.
         color(gameObject, color, duration).
             setEase(LeanTweenType.easeInOutQuad).
             setOnComplete(completion).setDelay(waitDuration);
 }
Пример #9
0
	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
0
    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
0
 protected Actor(DrawTag drawTag, string name)
     : base(drawTag, name)
 {
     nextAction = null;
     canOpenDoors = false;
     energy = 0;
 }
Пример #12
0
 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
0
        private static void ProcessAction(Action action)
        {
            var target = GetInstance(action.Type);

              var targetMethod = target.GetType().GetMethod(action.Method);
              targetMethod.Invoke(target, action.Params);
        }
Пример #14
0
    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;
    }
    //-------------------------------------------------------------------------
    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);
        }
    }
    public SCAnimationInfo(Action callback, float time)
    {
        mCallback = callback;
        mTime = time;

        mStatus = Status.NOT_STARTED;
    }
Пример #17
0
 public Animation(Action action, int row, int frames)
 {
     Action = action;
     Row = row;
     Frames = frames;
     FrameLength = 150;
 }
Пример #18
0
 public virtual void Draw(Action<Graphics> drawAction)
 {
     if (!IsDisposed && this.offGr != null)
     {
         drawAction(this.offGr);
     }
 }
Пример #19
0
 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;
 }
Пример #20
0
 public PathRequest(Vector3 _start, Vector3 _end, Action<Vector3[], bool> _callback, GameObject unitGObj)
 {
     pathStart = _start;
     pathEnd = _end;
     callback = _callback;
     unitGObjRequesting = unitGObj;
 }
Пример #21
0
    void OnGUI()
    {
        if (Pause.IsPaused)
        {
            if (_action == Action.None)
            {
                if (ResumeButton())
                {
                    _selection = Action.Resume;
                    Pause.Resume();
                    _action = Action.None;

                }
                else if (ExitButton())
                {
                    selectSound.Play();
                    _action = Action.Exit;
                    _selection = Action.Exit;
                }
            }
            else
            {
                if (_action == Action.Resume)
                {
                    ResumeButton();
                }
                else if (_action == Action.Exit)
                {
                    ExitButton();
                }
            }
        }
    }
Пример #22
0
    public void FadeInBlack(Action callback)
    {
        if (_fading)
            return;

        StartCoroutine(FadeInAsync(callback));
    }
Пример #23
0
			public void OnCompleted (Action continuation)
			{
				if (continuation == null)
					throw new ArgumentNullException ("continuation");

				TaskAwaiter.HandleOnCompleted (task, continuation, continueOnSourceContext);
			}
Пример #24
0
 private TeredoHelper(Action<object> callback, object state)
 {
     this.callback = callback;
     this.state = state;
     this.onStabilizedDelegate = new StableUnicastIpAddressTableDelegate(OnStabilized);
     this.runCallbackCalled = false;
 }
Пример #25
0
    public static void GetEmail(GameObject sender, Action<bool, string> callback)
    {
        if (sender != null)
        {
            //sender.renderer.enabled = false;
        }

        Facebook.instance.graphRequest("/me?fields=email", (e, o) =>
        {
            if (e == null)
            {
                Dictionary<string, object> dic = (Dictionary<string, object>)o;
                string email = (string)dic["email"];

                if (callback != null)
                {
                    callback(true, email);
                }
            }
            else
            {
                if (callback != null)
                {
                    callback(false, "");
                }
            }
            //sender.renderer.enabled = true;
        });
    }
Пример #26
0
 public static void ShowAlertBox(string message, string title, Action onFinished = null)
 {
     var alertPanel = GameObject.Find("Canvas").transform.Find("AlertBox");
     if (alertPanel == null)
     {
         alertPanel = (Instantiate(Resources.Load("AlertBox")) as GameObject).transform;
         alertPanel.gameObject.name = "AlertBox";
         alertPanel.SetParent(GameObject.Find("Canvas").transform);
         alertPanel.localPosition = new Vector3(-6f, -6f, 0f);
     }
     alertPanel.Find("title").GetComponent<Text>().text = title;
     alertPanel.Find("message").GetComponent<Text>().text = message;
     alertPanel.gameObject.SetActive(true);
     if (onFinished != null)
     {
         var button = alertPanel.Find("alertBtn").GetComponent<Button>();
         UnityAction onclick = null;
         onclick = () =>
         {
             onFinished();
             alertPanel.gameObject.SetActive(false);
             button.onClick.RemoveListener(onclick);
         };
         button.onClick.RemoveAllListeners();
         button.onClick.AddListener(onclick);
     }
 }
Пример #27
0
    public void RemoveVoxelAnimation(bool hasPreviousBlock, Voxel voxel, Action finishCallback)
    {
        if (_animDic.ContainsKey(voxel.Pos))
        {
            AnimTuple anim = _animDic[voxel.Pos];
            anim.Trans.GetComponent<MeshRenderer>().material.color = voxel.Color;
            anim.Trans.GetComponent<DummyBehavior>().StopAllCoroutines();
            anim.Cor = anim.Trans.GetComponent<DummyBehavior>().StartCoroutine(RemoveVoxelAnimationCor(voxel.Pos, anim.Trans, () =>
            {
                finishCallback();
            }));
        }
        else
        {
            if (hasPreviousBlock)
            {
                AnimTuple anim = new AnimTuple();
                _animDic[voxel.Pos] = anim;
                anim.Trans = CreateAnimTransform(voxel);
                anim.Trans.localScale = Vector3.one;
                anim.Cor = anim.Trans.GetComponent<DummyBehavior>().StartCoroutine(RemoveVoxelAnimationCor(voxel.Pos, anim.Trans, () =>
                {
                    finishCallback();
                }));

            }
        }
    }
Пример #28
0
    public void OnEntityAct(Action act)
    {
        switch(act) {
        case Action.start:
            break;

        case Action.idle:
            //revived!
            if(prevAction == Entity.Action.die) {
                Invulnerable(hurtInvulDelay);
                mController.enabled = true;
            }

            planetAttach.ResetMotion();
            break;

        case Action.hurt:
            _SetActionDisablePlayer();
            Invulnerable(hurtInvulDelay);
            break;

        case Action.die:
            _SetActionDisablePlayer();
            break;

        case Action.victory:
            _SetActionDisablePlayer();
            break;
        }
    }
Пример #29
0
    public void PostJSON( string inURL, JsonObject inJSON, Action< string, JsonObject > inCallback )
    {
        var headers = new Dictionary< string, string >();
        headers[ "Content-Type" ] = "application/json";

        var jsonString = SimpleJson.SimpleJson.SerializeObject( inJSON );
        Post( inURL, System.Text.Encoding.UTF8.GetBytes( jsonString ), headers, ( string inError, WWW inWWW ) =>
        {
            if( inCallback != null )
            {
                JsonObject obj = null;
                if ( string.IsNullOrEmpty( inError ) && ! string.IsNullOrEmpty( inWWW.text ) )
                {
                    Debug.Log("Response: " + inWWW.text );

                    object parsedObj = null;
                    if ( SimpleJson.SimpleJson.TryDeserializeObject( inWWW.text, out parsedObj ) )
                    {
                        obj = ( JsonObject ) parsedObj;
                    }
                }

                inCallback( inError, obj );
            }
        } );
    }
Пример #30
0
 private void When(Action when)
 {
     using (_mocks.Playback())
     {
         when.Invoke();
     }
 }