public LogScope(ILogModel logModel, WriteLogDelegate writeLogDelegate) { this.logModel = logModel; this.writeLogDelegate = writeLogDelegate; this.stopwatch = new Stopwatch(); stopwatch.Start(); }
public void WriteLogDelegateCanPointToMethod() //delegate { WriteLogDelegate log = ReturnMessage; //log = new WriteLogDelegate(ReturnMessage); log += ReturnMessage; //means line above log += IncrementCount; var result = log("Hi"); Assert.Equal(3, count); //Assert.Equal("Hi", result); }
public void WriteLogDeleageCantPointToMethod() { WriteLogDelegate log = ReturnMessage; //points to return message and can point to more than one method log += ReturnMessage; log += IncrementCount; var result = log("Hello"); Assert.Equal("Hello", result); AssemblyLoadEventArgs.Equals(3, count); }
public void WriteLogDelegateCanPointToMethod() { WriteLogDelegate Log = ReturnMessage; Log += ReturnMessage; Log += ReturnMessage; var result = Log("Hello"); Assert.Equal(3, count); Assert.Equal("Hello", result); }
public void WriteLogDelegateCanPointToMethod() { WriteLogDelegate log; log = new WriteLogDelegate(ReturnMessage); // or just log = ReturnMessage; log += ReturnMessageToLower; // we can add more functions to log with += log += ReturnMessage; // add more! var result = log("Hello"); Assert.Equal("Hello", result); }
public void WriteLogDelegateCanPointToMethod() { WriteLogDelegate log; log = new WriteLogDelegate(ReturnMessage); // ei invoke, vaan et delegate osoittaa returnmessage funktioon // log = ReturnMessage ois shorthand. // log += ReturnMessage; voi invokata monia metodeja kun tuolleen lisää. var result = log("Hello!"); Assert.Equal("Hello!", result); }
public void WriteLogDelegateCanPointToMethod() { //Delegates are useful because you can take a variable and treat it like a method //Delegates can invoke one or more methods, as long as the return type and the parameters match WriteLogDelegate log = ReturnMessage; log += ReturnMessage; log += IncrementCount; var result = log("Hello"); Assert.Equal("Hello", result); }
public void WriteLogDelegateCanPointToMethod() { //Given WriteLogDelegate log; log = new WriteLogDelegate(ReturnMessage); // log = ReturnMessage; var result = log("hello"); //Then Assert.Equal("hello", result); }
public void WriteLogDelegateCanPointToMethod() { WriteLogDelegate log = ReturnMessage; //log = new WriteLogDelegate(ReturnMessage); log += ReturnMessage; // C# can assume this log += IncrementCount; var result = log("Hello!"); Assert.Equal(3, count); }
public void WriteLogMultiCastDelegate() { WriteLogDelegate log = ReturnMessage; log += this.ReturnMessage; log += this.IncrementCount; var result = log("Hello!"); Assert.Equal("hello!", result); Assert.Equal(3, this.count); }
public void WriteLogDelegateCanPointToMethod() { WriteLogDelegate log = ReturnMsg; // log = new WriteLogDelegate(ReturnMsg); // OR log += ReturnMsg; log += IncrementCount; var result = log("Hello!"); Assert.Equal(3, count); }
public void WriteLogDelegateCanPointToMe() { WriteLogDelegate log = ReturnMessage; log += ReturnMessage; log += IncrementCount; var result = log("Hello"); Assert.Equal(3, count); }
public void WriteLogDelegateCanPointToMethod() { WriteLogDelegate log = ReturnMessage; log += new WriteLogDelegate(ReturnMessage); log += IncrementCount; // can also be initialized: log = ReturnMesage; var result = log("Hello!"); Assert.Equal(3, count); }
[Fact] void WriteLogDelegatePointToMethod() { WriteLogDelegate log = ReturnMessage; log += ReturnMessage; log += IncrementCount; var result = log("Hello"); System.Console.WriteLine(result); Assert.Equal("Hello Hello hello", result); }
public void WriteLogDelegateCanPointToMethod() { WriteLogDelegate log; log = new WriteLogDelegate(ReturnMessage); log += ReturnMessage; var result = log("hi"); Assert.Equal("hi", result); }
public void WriteLogDelegateCanPointToMethod() { WriteLogDelegate log = ReturnMessage; log += ReturnMessage; log += IncrementCount; var result = log("Hello!"); Assert.Equal(count, 3); // Assert.Equal(count, 0); // Assert.Equal(result, "Hello!"); }
public void DelegateCanPointToMetod() { WriteLogDelegate logDelegate = new WriteLogDelegate(ReturnMessage); logDelegate += ReturnMessage; logDelegate += IncrementCount; var result = logDelegate("Hello!"); Assert.Equal("hello!", result); Assert.Equal(3, count); }
public void WriteLogDelegateCanPointToMethod() { WriteLogDelegate log = ReturnMessage; // initialize delegate log += ReturnMessage; log += IncrementCount; // point delegate to method. We could possibly both write to console and file var result = log("Hello!"); Assert.Equal("Hello!", result); Assert.Equal(3, count); }
public void WriteLogDelegateCanPointToMethod() { WriteLogDelegate log = ReturnMessage; //log=new WriteLogDelegate(ReturnMessage);//Long way to intialize deligate short way is down //this needs to be done because we should invoke the method log += ReturnMessage; log += IncrimentcountMessage; var result = log("Hello"); Assert.Equal(1, count); }
public void WriteLogDelegateCanPointToMethod() { // Section 1: Arrange WriteLogDelegate log = ReturnMessage; log += ReturnMessage; log += IncrementCount; // Section 2: Act var result = log("Hello!"); // Section 3: Assert Assert.Equal(3, count); }
public void WriteLogDelegateCanPointToMethod() { WriteLogDelegate log = ReturnMessage; log += ReturnMessage; log += IncreamentCount; log += IncreamentCount; var result = log("Hello Bryan"); Assert.Equal(4, count); }
public void writeLogDelegateCanPointToMethod() { // declare delegate method WriteLogDelegate log = ReturnMessage; //initialize delegate method log += ReturnMessage; log += IncrementCount; var result = log("Hello!"); Assert.Equal(3, count); }
/// <summary> /// 写日志 /// </summary> private void WriteLog(string msg) { if (this.InvokeRequired) { WriteLogDelegate d = new WriteLogDelegate(WriteLog); object arg = msg; this.Invoke(d, arg); } else { WriteLog1(msg); } }
public void WriteLogDelegateCanPointToMethod() { WriteLogDelegate log = ReturnMessage; // log = new WriteLogDelegate(ReturnMessage); // These two lines are equivalent log += ReturnMessage; log += IncrementCount; var result = log("Hello"); Assert.Equal(3, count); }
public void WriteLogDelegateCanPointToMethod() { WriteLogDelegate log = ReturnMessage; //log = new WriteLogDelegate(ReturnMessage); kan skrivas som nedan: log += ReturnMessage; // log = ReturnMessage från början; log += IncrementCount; var result = log("Hello"); //Assert.Equal("Hello", result); Assert.Equal(3, count); }
public NetworkHelper(string ip, int port, string username, string password, WriteLogDelegate callbackMethod) { this.IP = ip; this.Port = port; this.Username = username; this.Password = password; this.WriteLog = callbackMethod; settings.Username = username; settings.PreferredIP = ip; settings.Save(); }
public void WriteLogDelegate_Call_CanPointToMethod() { //Given WriteLogDelegate log = ReturnMessage; log += ReturnMessageToLower; //When var result = log("Hello!"); //Then Assert.Equal(2, count); }
public void WriteLogDelegateCanPointToMethod() { WriteLogDelegate log = ReturnMessage; //log = new WriteLogDelegate(ReturnMessage); - alternative syntax (what happens under the hood) log += ReturnMessage; log += IncrementCount; var result = log("Hello!"); //Assert.Equal("Hello!", result); Assert.Equal(3, count); }
public void WriteLogDelegateCanPointToMethod() { WriteLogDelegate log = ReturnMessage; log += ReturnMessage; log += IncrementCount; // log = new WriteLogDelegate(ReturnMessage); var result = log("Hello!"); AssemblyTraitAttribute.Equals(3, count); }
public void WriteLogDelegateCanPointToAMethod() { WriteLogDelegate log = ReturnMessage; log += ReturnMessage; // also add and invoke IncrementCount; log += IncrementCount; var result = log("Hello"); // check count; Assert.Equal(3, count); // Assert.Equal("Hello", result); // since adding multiple delegates dont need to assert here }
public void WriteLogDelegateReturnMessage() { //initiate the delegate WriteLogDelegate logDelegate = ReturnMessage; // assign delegate logDelegate += ReturnMessage; logDelegate += IncrementCount; var result = logDelegate("Elsie"); Assert.Equal(3, count); }
/// <summary> /// エンコードスレッドメイン処理 /// </summary> private void mainTask() { WriteProcessDelegate process_dlg = new WriteProcessDelegate(WriteProcess); WriteLogDelegate log_dlg = new WriteLogDelegate(WriteLog); try { this.nowEncodeFileLabel.Text = ""; this.nowEncodeProcessLabel.Text = ""; string filePath = ""; string[] address = this.encodeList.Items.Cast<string>().ToArray(); DateTime dtNow; dtNow = DateTime.Now; int encodeFilesCount = address.Length; for (int i = 0; i < encodeFilesCount; ++i) { this.Invoke(process_dlg, new object[] { i, encodeFilesCount }); filePath = address[i]; EncodeProcess ep = new EncodeProcess(); ep.startEndoceProcess(filePath, dtNow.ToString("yyyyMMdd")); } this.Invoke(process_dlg, new object[] { encodeFilesCount, encodeFilesCount }); } catch (Exception) { MessageBox.Show("異常終了しました", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { this.Invoke(log_dlg, new object[] { "全ての処理を終了しました" }); if (ini["use", "shutdown"] == "true") { ShutDownProcess sdp = new ShutDownProcess(); sdp.StartShutDown(); } } }
/// <summary> /// �������� /// </summary> /// <param name="strMsg">��־��Ϣ</param> public static void Fatal(string strMsg) { WriteLogDelegate wld = new WriteLogDelegate(WriteLog); IAsyncResult ar = wld.BeginInvoke(LogLevel.Fatal, "", "", strMsg, new AsyncCallback(CallBackMethod), wld); }
/// <summary> /// һ����� /// </summary> /// <param name="strClassName">����</param> /// <param name="strMethodName">������</param> /// <param name="strMsg">��־��Ϣ</param> public static void Error(string strClassName, string strMethodName, string strMsg) { WriteLogDelegate wld = new WriteLogDelegate(WriteLog); IAsyncResult ar = wld.BeginInvoke(LogLevel.Error, strClassName, strMethodName, strMsg, new AsyncCallback(CallBackMethod), wld); }
public void LOG(string text) { WriteLogDelegate wtlg = new WriteLogDelegate(WriteTortbLog); rtbLog.Invoke(wtlg, text); }
private void WriteToLog(string msg) { if (InvokeRequired) { var d = new WriteLogDelegate(WriteToLog); Invoke(d, msg); return; } if (!_shown) return; txtLog.AppendText(string.Format("[{0}] {1}\r\n", DateTime.Now.ToString("hh:mm:ss.ffff tt"), msg)); }