Ejemplo n.º 1
0
        public override void Write(char[] buffer, int index, int count)
        {
            BeforWriteEventArgs arg = OnBeforWrite(new string(buffer));
            string value            = string.Format("[{0}] {1}", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), arg.Value);

            if (arg.WriteToLog)
            {
                _Mutex.WaitOne();
                using (StreamWriter _StreamWriter = new StreamWriter(_path, true))
                {
                    _StreamWriter.Write(value);
                    _StreamWriter.Flush();
                    _StreamWriter.Close();
                }
                _Mutex.ReleaseMutex();
            }

            if (arg.ShowInConsole)
            {
                this._out.Write(value);
            }
            if (arg.WriteToLog || arg.ShowInConsole)
            {
                OnAfterWrite(value);
            }
        }
Ejemplo n.º 2
0
        protected BeforWriteEventArgs OnBeforWrite(string value)
        {
            BeforWriteEventArgs arg = new BeforWriteEventArgs(value);

            if (BeforeWrite != null)
            {
                BeforeWrite(this, arg);
            }
            return(arg);
        }