public void Test() { AnonymousTest at = new AnonymousTest(); at.Test(); LambdaTest lt = new LambdaTest(); lt.LambdaTests(); lt.test(); DelegateAndEvents dae = new DelegateAndEvents(); voidDelegate vd = new voidDelegate(dae.VoidMethod); vd("test delegate again"); dae.Test(); int x = 0; int y = 0; GamePublisher pub = new GamePublisher("Activation"); Player p1 = new Player("zhouwei"); pub.Subscribe += p1.Preorder; p1.Publiser = new WeakReference <GamePublisher>(pub); pub.Publish("COD 4, Morden warfare"); Player p2 = new Player("dengmin"); pub.Subscribe += p2.Preorder; pub.Publish("COD6, Morden warfare II"); Player p3 = new Player("winner"); pub.Subscribe -= p2.Preorder; pub.Subscribe += p3.Preorder; pub.WeakPublish("test Name"); pub.WeakSubscribe += p3.Preorder; Player p4 = new Player("Infinate" + x); pub.WeakSubscribe += p4.Preorder; pub.WeakPublish("test name 2"); //pub.Publish("COD8, Infinte warfare"); // y++; Player p5 = new Player("infinite-loop" + 5); pub.Subscribe += p5.Preorder; pub.Publish("dummy release"); }
private void Terminal_Load(object sender, EventArgs e) { terminalTextBox.Text = firstOpenText + "C:\\Users\\" + username + ">"; terminalTextBox.SelectionStart = terminalTextBox.SelectionLength = 0; terminalTextBox.KeyPress += terminalTextBox_KeyPressed; terminalTextBox.KeyDown += terminalTextBox_KeyDown; onCommandSent += OnCommandReceived; }
public void PerformInTransaction( voidDelegate d, transactiontype_enum mode = transactiontype_enum.TRANSACTION_GENERAL, bool abort = true) { this.projectWasInTransaction = (project.ProjectStatus & 8) != 0; this.projectHasBeenAborted = false; if (this.projectWasInTransaction == false) { BeginTransaction(mode); } if (this.projectWasInTransaction && abort) { CommitTransaction(); BeginTransaction(mode); } try { d(); if (abort) { AbortTransaction(); projectHasBeenAborted = true; if (this.projectWasInTransaction) { BeginTransaction(mode); } } else { if (this.projectWasInTransaction == false) { CommitTransaction(); } } } catch { if (projectHasBeenAborted == false) { AbortTransaction(); } if (this.projectWasInTransaction) { BeginTransaction(mode); } throw; } }
internal void DisableSpreadsheet() { if (this.contentTextBox.InvokeRequired || spreadsheetPanel1.InvokeRequired) { voidDelegate n = new voidDelegate(EnableSpreadsheet); this.Invoke(n); return; } spreadsheetPanel1.UseWaitCursor = true; this.contentTextBox.UseWaitCursor = true; this.Locked = true; }
public static KeyFunction createInstance(KeyCode key, voidDelegate voidFunc) { KeyFunction _instance = new GameObject("KeyFunction_" + keyFunctionList.Count.ToString()).gameObject.AddComponent <KeyFunction>(); moveToKeyFunctionsGroup(_instance); _instance.setKey(key); _instance.setFunction(voidFunc); keyFunctionList.Add(_instance); return(_instance); }
internal void NowConnected() { if (this.InvokeRequired) { voidDelegate n = new voidDelegate(NowConnected); this.Invoke(n); return; } this.connectToolStripMenuItem.Enabled = false; this.newToolStripMenuItem.Enabled = true; this.openToolStripMenuItem.Enabled = true; }
public void PerformInTransaction(voidDelegate d, transactiontype_enum mode = transactiontype_enum.TRANSACTION_GENERAL) { BeginTransaction(mode); try { d(); CommitTransaction(); } finally { AbortTransaction(); } }
public static bool RegisterUpdateMassStatsOverride(voidDelegate dlg) { if (!CheckSpaceCenter()) { return(false); } if (updateMassStatsOverride == null) { updateMassStatsOverride = dlg; return(true); } Log.warn("UpdateMassStats already has an override"); return(false); }
public static bool RegisterUpdateMassStatsOverride(voidDelegate dlg) { if (HighLogic.LoadedScene != GameScenes.SPACECENTER) { print("You can only register on the SPACECENTER scene"); } if (updateMassStatsOverride == null) { updateMassStatsOverride = dlg; return(true); } print("UpdateMassStats already has an override"); return(false); }
internal void EnableSpreadsheet() { if (this.contentTextBox.InvokeRequired || spreadsheetPanel1.InvokeRequired) { voidDelegate n = new voidDelegate(EnableSpreadsheet); this.Invoke(n); return; } spreadsheetPanel1.UseWaitCursor = false; this.contentTextBox.UseWaitCursor = false; this.contentTextBox.Enabled = true; this.Locked = false; SetCellContent(); FocusOnContentTextBox(spreadsheetPanel1); }
public static bool RegistercalculateConstantsAtmosphereOverride(voidDelegate dlg) { if (!CheckSpaceCenter()) { return(false); } if (calculateConstantsAtmosphereOverride == null) { calculateConstantsAtmosphereOverride = dlg; return(true); } Log.warn("CalculateConstantsAtmosphere already has an override"); return(false); }
public static bool RegisterCalculateSunBodyFluxOverride(voidDelegate dlg) { if (!CheckSpaceCenter()) { return(false); } if (calculateSunBodyFluxOverride == null) { calculateSunBodyFluxOverride = dlg; return(true); } Log.warn("CalculateSunBodyFlux already has an override"); return(false); }
public static bool RegisterFixedUpdateOverride(voidDelegate dlg) { if (!CheckSpaceCenter()) { return(false); } if (fixedUpdateOverride == null) { fixedUpdateOverride = dlg; return(true); } Log.warn("FixedUpdate already has an override"); return(false); }
public static bool RegistercalculateConstantsAtmosphereOverride(voidDelegate dlg) { if (HighLogic.LoadedScene != GameScenes.SPACECENTER) { print("You can only register on the SPACECENTER scene"); } if (calculateConstantsAtmosphereOverride == null) { calculateConstantsAtmosphereOverride = dlg; return(true); } print("CalculateConstantsAtmosphere already has an override"); return(false); }
public void receiveMessage(string text, string sender, Color?color) { if (!color.HasValue) { color = Color.Black; } voidDelegate del = delegate() { this.chatBox.SelectionStart = this.chatBox.TextLength; this.chatBox.SelectionLength = 0; this.chatBox.SelectionColor = color.Value; this.chatBox.AppendText(sender + ": " + text + Environment.NewLine); this.chatBox.SelectionColor = this.chatBox.ForeColor; }; chatBox.Invoke(del); }
public void PerformInTransaction( voidDelegate d, transactiontype_enum mode = transactiontype_enum.TRANSACTION_GENERAL) { this.projectWasInTransaction = (project.ProjectStatus & 8) != 0; this.BeginTransaction(mode); try { d(); this.CommitTransaction(); } catch (Exception) { // TODO: What should we do here? throw; } }
public void PerformInTransaction( voidDelegate d, transactiontype_enum mode = transactiontype_enum.TRANSACTION_GENERAL, bool abort = true) { this.projectWasInTransaction = (project.ProjectStatus & 8) != 0; if (this.projectWasInTransaction == false) { BeginTransaction(mode); } if (this.projectWasInTransaction && abort) { CommitTransaction(); BeginTransaction(mode); } try { d(); if (abort) { AbortTransaction(); if (this.projectWasInTransaction) { BeginTransaction(mode); } } else { if (this.projectWasInTransaction == false) { CommitTransaction(); } } } catch (Exception ex) { // TODO: What should we do here? throw ex; } }
public void PerformInTransaction(voidDelegate d, transactiontype_enum mode = transactiontype_enum.TRANSACTION_GENERAL, bool abort = true) { BeginTransaction(mode); try { d(); if (abort) { AbortTransaction(); } else { CommitTransaction(); } } finally { AbortTransaction(); } }
private void performInROTransaction(IMgaProject project, voidDelegate d) { IMgaTerritory territory = project.BeginTransactionInNewTerr(transactiontype_enum.TRANSACTION_READ_ONLY); try { d(); } finally { try { project.AbortTransaction(); } catch { } try { territory.Destroy(); } catch { } } }
public void PerformInTransaction( voidDelegate d, transactiontype_enum mode = transactiontype_enum.TRANSACTION_NON_NESTED, bool abort = true) { this.projectWasInTransaction = (project.ProjectStatus & 8) != 0; this.projectHasBeenAborted = false; if (this.projectWasInTransaction == false) { BeginTransaction(mode); } try { d(); if (this.projectWasInTransaction == false && abort) { projectHasBeenAborted = true; AbortTransaction(); } else if (this.projectWasInTransaction == false) { CommitTransaction(); } } catch { if (this.projectWasInTransaction == false && projectHasBeenAborted == false) { AbortTransaction(); } throw; } }
public static void RegisterCalculateSunBodyFluxPost(voidDelegate dlg) { calculateSunBodyFluxPost += dlg; }
public static void RegisterUpdateThermodynamicsPost(voidDelegate dlg) { updateThermodynamicsPost += dlg; }
public TimeFixedTask(DateTime executeAtTime, voidDelegate handler) : base(executeAtTime) { this._handler = handler; }
public word(string txt) { //parse obj from string //string txt = "言葉 ことば (NGÔN DIỆP) Câu nói"; //txt = "積極 せいこう (THÀNH CÔNG)"; //txt = "心配 (TÂM PHỐI)"; //(~に)関する; \t(~に)かんする; (QUAN); về~, liên quan~ Regex reg = new Regex(@"\s+"); var refine = reg.Replace(txt, " "); {//with separator ";" string part = @";\s*"; Regex regSplit = new Regex(part); var tmp = regSplit.Split(refine); if (tmp.Length == 4) { kanji = tmp[0]; hiragana = tmp[1]; hn = tmp[2]; vn = tmp[3]; return; } } string pattern = @"(\w+) (\w+) (\(.*\)) (.*)"; string pattern2 = @"(\w+) (\w+) (\(.*\))"; string pattern3 = @"(\w+) (\(.*\))"; //string pattern4 = @"(.*); (.*); (.*); (.*)"; Match m = null; var func1 = new voidDelegate(() => { kanji = m.Groups[1].Value; hiragana = m.Groups[2].Value; hn = m.Groups[3].Value; vn = m.Groups[4].Value; }); var func2 = new voidDelegate(() => { kanji = m.Groups[1].Value; hiragana = m.Groups[2].Value; hn = m.Groups[3].Value; vn = ""; }); var func3 = new voidDelegate(() => { kanji = m.Groups[1].Value; hiragana = ""; hn = m.Groups[2].Value; vn = ""; }); //var func4 = new voidDelegate(() => //{ // kanji = m.Groups[1].Value; // hiragana = m.Groups[2].Value; // hn = m.Groups[3].Value; // vn = m.Groups[4].Value; //}); List <myMap> arr = new List <myMap> { //new myMap() {pattern = pattern4, function = func4}, new myMap() { pattern = pattern, function = func1 }, new myMap() { pattern = pattern2, function = func2 }, new myMap() { pattern = pattern3, function = func3 }, }; isEmpty = true; foreach (var i in arr) { reg = new Regex(i.pattern); m = reg.Match(refine); if (m.Success) { i.function(); isEmpty = false; break; } } }
// assign some of the functions (internal ones) public void assignFunction(EMJFUNCTION func) { this.function = func; // define default delegates. onButtonDown = new voidDelegate(voidFunc); onButtonUp = new voidDelegate(voidFunc); actionText = "!NOTHING!"; switch (this.function) { case EMJFUNCTION.KEYBOARD_COMBINATION: onButtonDown = new voidDelegate(hitKey); actionText = "Keyboard: " + keyStroke; break; case EMJFUNCTION.LEFT_MOUSE_BUTTON: onButtonDown = new voidDelegate(leftMouseDown); onButtonUp = new voidDelegate(leftMouseUp); actionText = "Left Mouse Button"; break; case EMJFUNCTION.RIGHT_MOUSE_BUTTON: onButtonDown = new voidDelegate(rightMouseDown); onButtonUp = new voidDelegate(rightMouseUp); actionText = "Right Mouse Button"; break; case EMJFUNCTION.MIDDLE_MOUSE_BUTTON: onButtonDown = new voidDelegate(middleMouseDown); onButtonUp = new voidDelegate(middleMouseUp); actionText = "Middle Mouse Button"; break; case EMJFUNCTION.VOLUME_UP: onButtonDown = new voidDelegate(volumeUp); actionText = "Volume UP"; break; case EMJFUNCTION.VOLUME_DOWN: onButtonDown = new voidDelegate(volumeDown); actionText = "Volume DOWN"; break; case EMJFUNCTION.MUTE_VOLUME: onButtonDown = new voidDelegate(volumeMute); actionText = "MUTE Volume"; break; // The stick functions do not need to be assigned. // They are executed otherwise. case EMJFUNCTION.ARROW_KEYS: actionText = "Arrow Keys"; break; case EMJFUNCTION.WASD_KEYS: actionText = "W A S D Keys"; break; case EMJFUNCTION.MOUSE_MOVEMENT: actionText = "Mouse Movement"; break; case EMJFUNCTION.MOUSE_WHEEL: actionText = "Mouse Wheel"; break; default: break; } }
private IEnumerator transition(string sceneName, float fadeOutTime, float fadeInTime = 0.1f, voidDelegate afterTransDel = null) { float time = 0; while (true) { Color color = m_fadePlane.GetComponent <Image>().color; color.a = time / fadeOutTime; m_fadePlane.GetComponent <Image>().color = color; time += Time.deltaTime; if (color.a > 1f) { break; } yield return(null); } //シーン切替 SceneManager.LoadScene(sceneName); yield return(null); //シーン切り替え後に呼び出される関数 if (afterTransDel != null) { afterTransDel(); } //だんだん明るく time = 0; while (true) { Color color = m_fadePlane.GetComponent <Image>().color; color.a = 1f - time / fadeOutTime; m_fadePlane.GetComponent <Image>().color = color; time += Time.deltaTime; if (color.a < 0f) { break; } yield return(null); } }
public Deletegates() { voidDelegate = new voidDelegate(Count); voidDelegate1 = new voidDelegate(Count); voidDelegate += voidDelegate1; }
private IEnumerator TimerCoroutine(float time, voidDelegate methodToCall) { yield return(new WaitForSeconds(time)); methodToCall.Invoke(); }
//allows 'invoke' type methods to occur without needing a mono behavior public void StartTimer(voidDelegate methodToCall, float time) { StartCoroutine(TimerCoroutine(time, methodToCall)); }
public neigeContainer(int nbFloconPerThread, ref Graphique parent) { m_nbPixelCollision = 30; m_controlParent = parent; delInvalidate = invalidateControl; hideDel = hideControl; lockIMG = new object(); nbFlocon = nbFloconPerThread; m_simThread = new Thread(simulationSequence); m_done = false; rng = new Random(); this.Size = parent.Size; solIMG = new Bitmap(this.Size.Width, this.Size.Height); initSol(); creerFlocons(nbFloconPerThread); }
static void Main(string[] args) { //anonymous method (pre-Lambda) //anonymous method that returns square value of an int intDelegate intInstance = delegate(int input) { return(input * input); }; int value = 5; Console.WriteLine("Square value of 5: {0}", intInstance(value)); Console.WriteLine("---------------------------"); //anonymous method (pre-Lambda) //anonymous method that doesn't return any value but prints given value to console voidDelegate voidInstance = delegate(string text) { Console.WriteLine(text); }; voidInstance("Given text"); Console.WriteLine("---------------------------"); //delagate with Lambda expresion that returns int intDelegate intLambda = (int input) => input * input; value = 6; Console.WriteLine("Square value of 5: {0}", intLambda(value)); Console.WriteLine("---------------------------"); //delegate with extended Lambda expresion that returns int intDelegate intExtLambda = (int input) => { int buffer; buffer = input * input; buffer = (int)Math.PI * buffer; return(buffer); }; Console.WriteLine("Processed value of given input: {0}", intExtLambda(value)); Console.WriteLine("---------------------------"); //delgate with Lambda expression that returns nothing voidDelegate voidLambda = (string text) => Console.WriteLine(text); voidLambda("Given text"); Console.WriteLine("---------------------------"); //delegate with extended Lambda expression that return nothing voidDelegate voidExtLambda = (string text) => { Console.WriteLine("Given text: {0}", text); Console.WriteLine("Length: {0}", text.Length); Console.WriteLine("Capitalizad text: {0}", text.ToUpper()); }; voidExtLambda("input text_XXX"); }
public void PerformInTransaction(voidDelegate d, transactiontype_enum mode = transactiontype_enum.TRANSACTION_GENERAL) { BeginTransaction(mode); try { d(); CommitTransaction(); } catch (Exception) { try { AbortTransaction(); } catch { } throw; } }
private void uart_UartErrorOccured(object sender, EventArgs e) { voidDelegate err = uartError; this.Invoke(err); }
public void setFunction(voidDelegate voidFunc) { this._voidFunc = voidFunc; }
public TimeIntervalTask(int timeInterval_ms, voidDelegate handler) : base(timeInterval_ms) { this._handler = handler; }
//場面反転後に実行したい関数を第4変数にいれよう //ただし、返り値void,引数なし public void transite(string sceneName, float fadeOutTime, float fadeInTime, voidDelegate afterTransDel = null) { StartCoroutine(transition(sceneName, fadeOutTime, fadeInTime, afterTransDel)); }