Beispiel #1
0
        private void Write(DateTime dtLoggedTime, string strText)
        {
            WriteLogLine(String.Format("[{0}] {1}", dtLoggedTime.ToString("HH:mm:ss"), strText.Replace("{", "{{").Replace("}", "}}")));

            if (WriteConsole != null)
            {
                FrostbiteConnection.RaiseEvent(WriteConsole.GetInvocationList(), dtLoggedTime, strText);
            }
        }
Beispiel #2
0
        public void Write(string strFormat, params object[] arguments)
        {
            DateTime dtLoggedTime = DateTime.UtcNow.ToUniversalTime().AddHours(Client.Game.UtcOffset).ToLocalTime();
            string   strText      = String.Format(strFormat, arguments);

            WriteLogLine(String.Format("[{0}] {1}", dtLoggedTime.ToString("HH:mm:ss"), strText.Replace("{", "{{").Replace("}", "}}")));

            if (WriteConsole != null)
            {
                FrostbiteConnection.RaiseEvent(WriteConsole.GetInvocationList(), dtLoggedTime, strText);
            }
        }
Beispiel #3
0
        static void Main()
        {
            Holder h = new Holder();

            h.OnWriteConsole += (name) => { Console.WriteLine(name + ": this is out Side Message"); return(true); };
            h.OnWriteConsole += (name) => { Console.WriteLine(name + ": this is out Side Message2"); return(true); };
            WriteConsole e2 = (WriteConsole)h.GetType()                                                                           //1.取得物件型別
                              .GetField("OnWriteConsole", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance) //2.取得FieldInfo資訊
                              .GetValue(h);                                                                                       //3.取得值後轉換回宣告的delegate型別
            int          eventCount = e2.GetInvocationList().Length;                                                              //4.執行delegate的GetInvocationList()方法取得註冊事件的數量長度
            WriteConsole e3         = GetDelegate <Holder, WriteConsole>(h, "OnWriteConsole");
            var          s          = e3.Method.Name;                                                                             //.Invoke("KKKKKKKKKKKK");

            Console.WriteLine("註冊事件的數量:" + e3.GetInvocationList().Length);
            Console.WriteLine("註冊事件的數量:" + eventCount);


            h.console("Qoo");
            Console.ReadKey();
        }
Beispiel #4
0
        public void Write(string strFormat, params string[] arguments)
        {
            try {
                DateTime dtLoggedTime = DateTime.UtcNow.ToUniversalTime().AddHours(Client.Game.UtcOffset).ToLocalTime();
                string   strText      = String.Format(strFormat, arguments);

                WriteLogLine(String.Format("[{0}] {1}", dtLoggedTime.ToString("HH:mm:ss"), strText));

                if (WriteConsole != null)
                {
                    FrostbiteConnection.RaiseEvent(WriteConsole.GetInvocationList(), dtLoggedTime, strText);
                }

                LogEntries.Enqueue(new LogEntry(dtLoggedTime, strText));

                while (LogEntries.Count > 100)
                {
                    LogEntries.Dequeue();
                }
            }
            catch (Exception) {
            }
        }