private static bool Do(ref int use, ref object first, ref object second, DoAction callback) { #if DEBUG // NOTICE this method has no null check in the public build as an optimization, this is just to appease the dragons if (callback == null) { throw new ArgumentNullException(nameof(callback)); } #endif var foundFirst = Interlocked.CompareExchange(ref first, null, null); if (foundFirst == null) { return(false); } try { Interlocked.Increment(ref use); return(callback(ref first)); } finally { DoLeave(ref use, ref first, ref second); } }
private IEnumerator createData() { bool exist = true; if (DoAction.getInstance().findFiles("monster01") == false) { MonsterCreate.getInstance().m01Create(); MonsterCreate.getInstance().m02Create(); MonsterCreate.getInstance().m03Create(); MonsterCreate.getInstance().m04Create(); MonsterCreate.getInstance().m05Create(); } if (DoAction.getInstance().findFiles("skill01") == false) { SkillCreat.getInstance().skill01Create(); SkillCreat.getInstance().skill02Create(); SkillCreat.getInstance().skill03Create(); SkillCreat.getInstance().skill04Create(); SkillCreat.getInstance().skill05Create(); SkillCreat.getInstance().skill06Create(); SkillCreat.getInstance().skill07Create(); SkillCreat.getInstance().skill08Create(); } if (DoAction.getInstance().findFiles("player") == false) { PlayerCreate.getInstance().playerCreate(); } if (DoAction.getInstance().findFiles("usingskill") == false) { OtherCreate.getInstance().usingSkill(1, 2, 3, 4); } yield return(0); }
public bool Do(int index, DoAction callback) { if (_level == 1) { var subIndex = SubIndex(index); return(Do ( ref _arrayUse[subIndex], ref _arrayFirst[subIndex], ref _arraySecond[subIndex], callback )); } else { var subIndex = SubIndex(index); return(Do ( ref _arrayUse[subIndex], ref _arrayFirst[subIndex], ref _arraySecond[subIndex], (ref object target) => { try { return ((BucketCore)target).Do(index, callback); } catch (NullReferenceException) { return false; } } )); } }
public bool DoMayIncrement(int index, DoAction callback) { // Assume anything could have been set to null, start no sync operation, this could be running during DomainUnload var arrayFirst = Volatile.Read(ref _arrayFirst); var arraySecond = Volatile.Read(ref _arraySecond); var arrayUse = Volatile.Read(ref _arrayUse); var childFactory = _childFactory; if (arrayFirst == null || arraySecond == null || arrayUse == null || childFactory == null) { return(false); } var subIndex = SubIndex(index); return(DoMayIncrement ( ref arrayUse[subIndex], ref arrayFirst[subIndex], ref arraySecond[subIndex], childFactory, _level == 1 ? callback : (ref object?target) => target is BucketCore core && core.DoMayIncrement(index, callback) )); }
public bool Do(int index, DoAction callback) { // Assume anything could have been set to null, start no sync operation, this could be running during DomainUnload var arrayFirst = Volatile.Read(ref _arrayFirst); var arraySecond = Volatile.Read(ref _arraySecond); var arrayUse = Volatile.Read(ref _arrayUse); if (arrayFirst == null || arraySecond == null || arrayUse == null) { return(false); } if (_level == 1) { var subIndex = SubIndex(index); return(Do ( ref arrayUse[subIndex], ref arrayFirst[subIndex], ref arraySecond[subIndex], callback )); } else { var subIndex = SubIndex(index); return(Do ( ref arrayUse[subIndex], ref arrayFirst[subIndex], ref arraySecond[subIndex], (ref object target) => target is BucketCore core && core.Do(index, callback) )); } }
// Essentially passing in a function. // Remember to actually call the function to execute it! public void GiveMeAMethod(DoAction tradeAction) { // What we get after actually calling the function var text = tradeAction(); Console.WriteLine($"Basic Delegate -> {text}"); }
public static void TryActionIgnoreException(DoAction action) { try { action.Invoke(); } catch { } }
static public DoAction getInstance() { if (_action == null) { _action = new DoAction(); } return(_action); }
public void missionBlood(int mission) { temp_blood = DoAction.getInstance().bloodAndMission(0, mission, temp_blood); p_blood = temp_blood; p_attack = temp_attack; p_defend = temp_defend; p_speed = temp_speed; //temp_blood = p_blood; }
private static void j() { try { Stack.Push(DoAction.j()); } catch (NfException) { throw new NfException("Trying to retrieve J outside of nested loop"); } }
internal void ActiveMenu() { if (DoAction == null) { DoWhenChosen(); } else { DoAction.Invoke(); } }
public ButtonTexture(Bitmap bitmap, DoAction doAction, bool selected = false) : base(doAction, selected) { Width = 0.3f; Height = 0.2f; texture = TextureLoader.FromBitmap(bitmap); //background clear color //GL.ClearColor(Color.Black); //for transparency in textures we use blending GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); }
public void m05Create() { Monster m = new Monster(); m.Id = 5; m.Blood = 22.5f; m.Attack = 0.45f; m.Defend = 0; m.Speed = 0.8f; DoAction.getInstance().writeData <Monster>(m, "Monster05"); }
public void playerCreate() { Player p = new Player(); p.Id = 1; p.Blood = 30; p.Defend = 10; p.Attack = 10; p.Speed = 1; p.Level = 1; DoAction.getInstance().writeData <Player>(p, "Player"); }
/// <summary> /// Waits the given time. /// </summary> /// <param name="milliseconds">The milliseconds to wait.</param> /// <returns>A combinable Do to be able to append additional actions.</returns> public CombinableDo Wait(uint milliseconds) { _doAction = DoAction.Action; _currentAction = () => { LogPool.Append("Wait {0} milliseconds.", milliseconds); Thread.Sleep((int)milliseconds); }; Execute(); return(new CombinableDo()); }
/// <summary> /// Creates a new <c>UserAction</c> /// </summary> /// <param name="items">The associated UI elements (at least one of them)</param> /// <param name="isActionEnabled">Delegate that can be used to determine if the action should be enabled (null means the /// action will always be enabled)</param> /// <param name="doAction">Delegate that should be called to perform the action (not null)</param> /// <exception cref="ArgumentNullException">If <paramref name="doAction"/> is null, or the associated /// UI elements are empty or null</exception> public UserAction(ToolStripItem[] items, IsActionEnabled isActionEnabled, DoAction doAction) { if (doAction==null) throw new ArgumentNullException(); m_Elements = new UserActionSupport(items); m_IsActionEnabled = isActionEnabled; m_DoAction = doAction; // Wire the supplied UI elements to a suitable handler m_Elements.SetHandler(Do); }
public void skill05Create() { Skill s = new Skill(); s.Skill_id = 5; s.Skill_name = "no.5"; s.Skill_attack = 10; s.Skill_CD = 5; s.Skill_Dir = 10; s.BuffType = new Buff(); s.BuffType.MonsterBuff = Buff.MONSTERBUFF.FIREDAMAGE; s.ResName = @""; DoAction.getInstance().writeData <Skill>(s, "Skill05"); }
/// <summary> /// Load ra khung upload mutils /// </summary> public ActionResult AjaxFormPicture() { var type = Request["Type"]; var categoryId = Request["CategoryID"]; var model = new ModelPictureItem { Type = !string.IsNullOrEmpty(type) ? Convert.ToInt32(type) : 0, CategoryID = !string.IsNullOrEmpty(categoryId) ? Convert.ToInt32(categoryId) : 0, Action = DoAction.ToString(), }; return(View(model)); }
public ActionResult AjaxForm() { var model = new FormDebtItem { ObjItem = (DoAction == ActionType.Edit) ? _api.GetItemByID(ArrId.FirstOrDefault()) : new DebtItem(), Action = DoAction.ToString(), AgencyId = UserItem.AgencyID, UserId = UserItem.UserId, DNSuppliers = supplieAPI.GetList(UserItem.AgencyID) }; return(View(model)); }
public ActionResult AjaxForm() { var model = new FormCashAdvanceItem { ObjItem = (DoAction == ActionType.Edit) ? _api.GetCashAdvanceItem(ArrId.FirstOrDefault()) : new CashAdvanceItem(), Action = DoAction.ToString(), AgencyId = UserItem.AgencyID, UserId = UserItem.UserId, Users = _userApi.GetListAllAgency(UserItem.AgencyID), Users1 = _userApi.GetAll(UserItem.AgencyID) }; return View(model); }
public void skill04Create() { Skill s = new Skill(); s.Skill_id = 4; s.Skill_name = "no.4"; s.Skill_attack = 8; s.Skill_CD = 2; s.Skill_Dir = 10; s.BuffType = new Buff(); s.BuffType.MonsterBuff = Buff.MONSTERBUFF.HARDDAMAGE; s.ResName = @"F:\allprojects\unitypro\Nonstop_Finger\Assets\Data\skill03.jpg"; DoAction.getInstance().writeData <Skill>(s, "Skill04"); }
void Awake() { //Debug.Log(System.IO.Directory.GetCurrentDirectory()); //DoAction.getInstance().writeData<string>(System.IO.Directory.GetCurrentDirectory(), System.IO.Directory.GetCurrentDirectory(), true); //_buff = new PlayerBuff(); //_buff.getBuff().PlayerBuff = Buff.PLAYERBUFF.NONE; gameManager = Camera.main.gameObject; player = new Player(); p_skill01 = new Skill(); p_skill02 = new Skill(); p_skill03 = new Skill(); p_skill04 = new Skill(); setSkill01(1); setSkill02(2); setSkill03(3); setSkill04(4); //try //{ player = DoAction.getInstance().readData <Player>(player); //} //catch (System.Exception e) //{ } //finally //{ // player.Id = 0; // player.Blood = 23; // player.Attack = 10; // player.Defend = 10; // player.Level = 1; // player.Speed = 1; // DoAction.getInstance().writeData<Player>(player); //} p_id = player.Id; p_blood = player.Blood; p_attack = player.Attack; //p_skill = new Skill(); p_defend = player.Defend; p_speed = player.Speed; p_level = player.Level; temp_blood = p_blood; temp_attack = p_attack; temp_defend = p_defend; temp_speed = p_speed; //mission = GameManager.mission; //Debug.Log(p_blood); }
public ActionResult AjaxForm() { var model = new FormReceiptPaymentItem { ObjItem = (DoAction == ActionType.Edit) ? _api.GetPaymentItem(ArrId.FirstOrDefault()) : new ReceiptPaymentItem(), Action = DoAction.ToString(), AgencyId = UserItem.AgencyID, UserId = UserItem.UserId, Users = _userApi.GetListAllAgency(UserItem.AgencyID), CostTypeItems = _costTypeApi.GetList(UserItem.AgencyID, (int)Vouchers.Payment) }; return(View(model)); }
/// <summary> /// Creates a new <c>UserAction</c> /// </summary> /// <param name="items">The associated UI elements (at least one of them)</param> /// <param name="isActionEnabled">Delegate that can be used to determine if the action should be enabled (null means the /// action will always be enabled)</param> /// <param name="doAction">Delegate that should be called to perform the action (not null)</param> /// <exception cref="ArgumentNullException">If <paramref name="doAction"/> is null, or the associated /// UI elements are empty or null</exception> public UserAction(ToolStripItem[] items, IsActionEnabled isActionEnabled, DoAction doAction) { if (doAction == null) { throw new ArgumentNullException(); } m_Elements = new UserActionSupport(items); m_IsActionEnabled = isActionEnabled; m_DoAction = doAction; // Wire the supplied UI elements to a suitable handler m_Elements.SetHandler(Do); }
public ActionResult AjaxForm() { var model = new ModelDiscountItem { Action = DoAction.ToString(), DiscountItem = new DiscountItem() }; if (DoAction == ActionType.Edit) { model.DiscountItem = _api.GetItemById(ArrId.FirstOrDefault()); } return(View(model)); }
public static void Test() { //实际上就是一种表驱动编程方法的实践 Console.WriteLine("【委托的使用,字典的使用,以及[,]多维操作符的自定义】"); ArgsActions aas = new ArgsActions(); DoAction da = new DoAction(); Action a1 = da.PrintAdd; Action a2 = da.PrintMod; aas.SetOption("add", a1); aas.SetOption("mod", a2); ArgsProcessor ap = new ArgsProcessor(aas); ap.Process(new string[] { "add", "mod" }); }
public ButtonText(string buttonText, DoAction doAction, bool selected = false, bool enabled = true) : base(doAction, selected) { this.Text = buttonText; Width = buttonText.Length * boundingBoxWidth / 20; Height = boundingBoxHeight; isEnabled = enabled; if (!enabled) { base.doAction = () => { } } ; }
/// <summary> /// Sau khi upload xong, cập nhật thông tin cho picture /// </summary> /// <returns></returns> public ActionResult AjaxFormPictureUpdate() { var arrFile = Request["fileData"]; var oSerializer = new JavaScriptSerializer(); var ltsFileobj = oSerializer.Deserialize <List <FileObj> >(arrFile); var type = Request["Type"]; var categoryId = Request["CategoryID"]; var model = new ModelFileObj { ListCategoryItem = _categoryDa.GetChildByParentId(false), ListItem = ltsFileobj, Type = !string.IsNullOrEmpty(type) ? Convert.ToInt32(type) : 0, CategoryId = !string.IsNullOrEmpty(categoryId) ? Convert.ToInt32(categoryId) : 0, Action = DoAction.ToString() }; return(View(model)); }
/// <summary> /// Executes the given action. /// </summary> /// <param name="action">The action to execute.</param> /// <returns>A combinable Do to be able to append additional actions.</returns> /// <exception cref="System.Exception">Cannot invoke the given action.</exception> public CombinableDo Action(Action action) { _doAction = DoAction.Action; _currentAction = () => { try { action(); } catch (Exception ex) { throw new LoggedException("Cannot invoke the given action. See inner exception.", ex); } }; Execute(); return(new CombinableDo(this)); }
private static bool Do(ref int use, ref object first, ref object second, DoAction callback) { var foundFirst = Interlocked.CompareExchange(ref first, null, null); if (foundFirst == null) { return(false); } try { Interlocked.Increment(ref use); return(callback(ref first)); } finally { DoLeave(ref use, ref first, ref second); } }
/// <summary> /// Repeats the previous actions the given times. /// </summary> /// <param name="amount">The amount of repeats.</param> /// <returns>A combinable Do to be able to append additional actions.</returns> /// <remarks>The amount is additional to the calls before. That means Do.Action(() => { }).Repeat(2); will result in 3 action calls.</remarks> public CombinableDo Repeat(uint amount) { _currentAction = null; _doAction = DoAction.Repeat; LogPool.Append("Repeat the previous action {0} times.", amount); for (int i = 0; i < amount; i++) { var previousDo = _previousDo; while (previousDo != null && previousDo._doAction != DoAction.Repeat) { previousDo._currentAction(); previousDo = previousDo._previousDo; } } return(new CombinableDo(this)); }
public override void doAction(DoAction tag) { frame.doActions.Add(tag.actionList); }
public override void doAction(DoAction tag) { open(tag); end(); if (showActions) { openCDATA(); printActions(tag.actionList); closeCDATA(); } else { //UPGRADE_TODO: Method 'java.io.PrintWriter.println' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioPrintWriterprintln_javalangString'" out_Renamed.WriteLine("<!-- " + tag.actionList.size() + " action(s) elided -->"); } close(tag); }
public EditingAction(EditingActionId id, ToolStripItem[] items, IsActionEnabled isActionEnabled, DoAction doAction) : base(items, isActionEnabled, doAction) { m_Id = id; }
/// <summary> /// Copy constructor /// </summary> /// <param name="action">The action to copy</param> protected UserAction(UserAction action) { m_Elements = action.m_Elements; m_IsActionEnabled = action.m_IsActionEnabled; m_DoAction = action.m_DoAction; }
/// <summary> /// Creates a <c>UserAction</c> that is invoked by one UI item that is /// always enabled. /// </summary> /// <param name="item">The associated UI element (not null)</param> /// <param name="doAction">Delegate that should be called to perform the action (not null)</param> public UserAction(ToolStripItem item, DoAction doAction) : this(new ToolStripItem[] { item }, null, doAction) { }
public static void DoAction(DoAction action) { s_singleton.Invoke(action); }
/// <summary> /// Creates a new <c>TextSizeAction</c> /// </summary> /// <param name="item">The associated UI element (not null)</param> /// <param name="doAction">Delegate that should be called to perform the action (not null)</param> /// <param name="sizeFactor">The magnification factor associated with the UI element (as a percentage /// of normal size)</param> /// <param name="defaultSizeFactor">The current default magnification factor (this will be compared /// with the supplied <paramref name="sizeFactor"/> to see whether a checkmark should be set alongside /// the supplied UI element)</param> internal TextSizeAction(ToolStripMenuItem item, DoAction doAction, uint sizeFactor, uint defaultSizeFactor) : base(item, doAction) { m_SizeFactor = sizeFactor; item.Checked = (sizeFactor==defaultSizeFactor); }
public override void doAction(DoAction tag) { int adjust = 0; if (Debug) { adjust = writer.Pos + 6; debug.adjust += adjust; } new ActionEncoder(tagw, debug).encode(tag.actionList); tagw.writeUI8(0); encodeTag(tag); if (Debug) { debug.adjust -= adjust; } }