Example #1
0
        private void NewPrinterHelper(PrinterConnEventArgs e)
        {
            var comPort = e.com_port;
            var printer = new PrinterConnection(comPort);

            lock (printer.SerialPort.ThreadSync)
            {
                if (!printer.ConnectTo())
                {
                    // ISSUE: reference to a compiler-generated field
                    if (LogEventHandler == null)
                    {
                        return;
                    }
                    // ISSUE: reference to a compiler-generated field
                    LogEventHandler(this, new LogMessageEventArgs("Could not connect to printer on port " + comPort));
                }
                else
                {
                    // ISSUE: reference to a compiler-generated field
                    // ISSUE: reference to a compiler-generated field
                    LogEventHandler?.Invoke(this, new LogMessageEventArgs("Successfully connected to printer on port " + comPort));
                    printers.TryAdd(comPort, printer);
                    // ISSUE: reference to a compiler-generated field
                    if (PrinterConnectedEventHandler == null)
                    {
                        return;
                    }
                    // ISSUE: reference to a compiler-generated field
                    PrinterConnectedEventHandler(this, new PrinterConnEventArgs(printer, comPort, e.vid_pid));
                }
            }
        }
Example #2
0
 private void RemovePrinterHelper(PrinterConnection printerToRemove)
 {
     try
     {
         if (printerToRemove.SerialPort != null)
         {
             // ISSUE: reference to a compiler-generated field
             // ISSUE: reference to a compiler-generated field
             LogEventHandler?.Invoke(this, new LogMessageEventArgs("Disconnecting from printer " + printerToRemove.SerialNumber + " on port " + printerToRemove.ComPort + "..."));
             printerToRemove.SerialPort.Dispose();
             // ISSUE: reference to a compiler-generated field
             // ISSUE: reference to a compiler-generated field
             LogEventHandler?.Invoke(this, new LogMessageEventArgs("Disconnected from printer " + printerToRemove.SerialNumber + " on port " + printerToRemove.ComPort ?? ""));
         }
     }
     catch (Exception ex)
     {
         // ISSUE: reference to a compiler-generated field
         // ISSUE: reference to a compiler-generated field
         LogEventHandler?.Invoke(this, new LogMessageEventArgs("Error: " + ex.Message));
     }
     // ISSUE: reference to a compiler-generated field
     if (PrinterDisconnectedEventHandler == null)
     {
         return;
     }
     // ISSUE: reference to a compiler-generated field
     PrinterDisconnectedEventHandler(this, new PrinterConnEventArgs(printerToRemove));
 }
Example #3
0
 // Wrap event invocations inside a protected virtual method
 protected virtual void OnLogEventHandler(LogEventArgs e)
 {
     // Make a temporary copy of the event to avoid possibility of
     // a race condition if the last subscriber unsubscribes
     // immediately after the null check and before the event is raised.
     LogEventHandler?.Invoke(this, e);
 }
Example #4
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="socket"></param>
        /// <param name="logHandler"></param>
        public SocketLogger(Socket socket, LogEventHandler logHandler)
        {
            m_pSocket     = socket;
            m_pLogHandler = logHandler;

            m_pEntries = new List <SocketLogEntry>();
        }
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="socket"></param>
        /// <param name="logHandler"></param>
        public SocketLogger(Socket socket,LogEventHandler logHandler)
        {
            m_pSocket         = socket;
            m_pLogHandler     = logHandler;

            m_pEntries = new List<SocketLogEntry>();
        }
Example #6
0
 private async Task <Device> TryGetDeviceAsync(AccessProvider accessProvider, string hostName, CancellationToken cancellationToken = new CancellationToken(), InformationCategory[] informationCategories = null, params InformationType[] informationTypes)
 {
     return(await Task.Run(async() =>
     {
         try
         {
             if (accessProvider != null)
             {
                 var wmiAccessService = await accessProvider.GetAccessAsync(hostName).ConfigureAwait(false);
                 if (wmiAccessService != null)
                 {
                     return await TryGetDeviceAsync(wmiAccessService, cancellationToken, informationCategories, informationTypes).ConfigureAwait(false);
                 }
             }
         }
         catch (OperationCanceledException operationCanceledException)
         {
             LogEventHandler.TaskIncompleted(operationCanceledException);
         }
         catch (Exception exception)
         {
             var wmiException = new WMIGeneralException(hostName, exception);
             LogEventHandler.Exception(wmiException);
         }
         return null;
     }, cancellationToken).ConfigureAwait(false));
 }
Example #7
0
 public void RemoveHandler(LogEventHandler handler)
 {
     lock (m_sync)
     {
         LogEvent -= handler;
     }
 }
Example #8
0
        private void Parse(int sourceID, string message)
        {
            NMEAIncomingMessageReceived.Rise(this, new NMEAMessageEventArgs(sourceID, message));

            try
            {
                var pResult = NMEAParser.Parse(message);

                if (pResult is NMEAStandartSentence)
                {
                    NMEAStandartSentence sentence = (NMEAStandartSentence)pResult;
                    if (standardSenteceParsers.ContainsKey(sentence.SentenceID))
                    {
                        standardSenteceParsers[sentence.SentenceID](sourceID, sentence.TalkerID, sentence.parameters);
                    }
                    else
                    {
                        NMEAStandartUnsupportedSentenceParsed.Rise(this, new NMEAUnsupportedStandartEventArgs(sourceID, sentence));
                    }
                }
                else
                {
                    NMEAProprietaryUnsupportedSentenceParsed.Rise(this, new NMEAUnsupportedProprietaryEventArgs(sourceID, (pResult as NMEAProprietarySentence)));
                }
            }
            catch (Exception ex)
            {
                LogEventHandler.Rise(this, new LogEventArgs(LogLineType.ERROR, ex));
            }
        }
Example #9
0
 private Task <WMIAccessService> TryGetAccessAsync(WMIConnectionOption wmiConnectionOption)
 {
     return(Task.Run(async() =>
     {
         WMIAccessService connectedWMIConnectedAccessService = null;
         if (wmiConnectionOption != null)
         {
             try
             {
                 var wmiAccessService = new WMIAccessService();
                 var connected = await wmiAccessService.TryConnectAsync(wmiConnectionOption).ConfigureAwait(false);
                 if (connected)
                 {
                     connectedWMIConnectedAccessService = wmiAccessService;
                 }
             }
             catch (Exception exception)
             {
                 var endPoint = string.IsNullOrEmpty(wmiConnectionOption.EndPoint)
                     ? wmiConnectionOption.DeviceName
                     : wmiConnectionOption.EndPoint;
                 var wmiException = new WMIGeneralException(endPoint, exception);
                 LogEventHandler.Exception(wmiException);
             }
         }
         return connectedWMIConnectedAccessService;
     }));
 }
Example #10
0
 public void AddHandler(LogEventHandler handler)
 {
     lock (m_sync)
     {
         LogEvent += handler;
     }
 }
Example #11
0
 private void TrySetValue(object objectInstance, PropertyInfo propertyInfo, PropertyData propertyData)
 {
     try
     {
         propertyInfo.SetValue(objectInstance, propertyData?.Value);
     }
     catch (Exception)
     {
         try
         {
             if (propertyInfo != null)
             {
                 if (propertyInfo.ReflectedType != null && propertyData?.Type != null)
                 {
                     LogEventHandler.Warning($"{objectInstance.GetType().FullName}.{propertyData.Name} : should be type of {propertyData.Type}. Failed with value: {propertyData.Value}");
                 }
                 propertyInfo.SetValue(objectInstance, propertyData?.Value?.ToString());
             }
         }
         catch (Exception exception)
         {
             var wmiException = new WMIGeneralException(EndPoint, exception);
             LogEventHandler.Exception(wmiException);
         }
     }
 }
Example #12
0
 public void Send(string message)
 {
     if ((port != null) && port.IsOpen)
     {
         port.SendData(message);
         LogEventHandler.Rise(this, new LogEventArgs(LogLineType.INFO, string.Format("{0} ({1}) << {2}", PortName, PortDescription, message)));
     }
 }
Example #13
0
 public static int Subscribe(LogEventHandler func, LogLevel level)
 {
     handlers.Add(new LogHandler()
     {
         ID = ++number, Level = level, Handler = func
     });
     return(number);
 }
Example #14
0
        /// <summary>
        /// Event which indicates Informational or Error event
        /// </summary>
        /// <param name="level">Event level</param>
        /// <param name="description">The description</param>
        public void LogEvent(LogEvent.Level level, string description)
        {
            LogEventHandler handler = Event;

            if (handler != null)
            {
                handler(level, description);
            }
        }
Example #15
0
        private void OnLogEvent(LogEventType eventType, string message)
        {
            LogEventHandler handler = LogEvent;

            if (handler != null)
            {
                handler(this, new LogEventArgs(eventType, message));
            }
        }
Example #16
0
        protected virtual void OnLog(LogEventArgs e)
        {
            LogEventHandler handler = OperationStatus;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Example #17
0
        public OrderedConsumersProcessor(OrderedConsumersProcessorOptions options)
        {
            _disruptor = new Disruptor <Event>(() => new Event(), options.BufferLength, TaskScheduler.Default);

            var logHandler = new LogEventHandler();
            var zipHandler = new ZipEventHandler();

            _disruptor.HandleEventsWith(logHandler).Then(zipHandler);
        }
Example #18
0
        static void Main(string[] args)
        {
            LogEventHandler logEventHandlerFile   = new LogEventHandler(FileLogger.WriteLog);
            LogEventHandler logEventHandlerScreen = ScreenLogger.ShowLog;

            logEventHandlerFile("File");
            logEventHandlerScreen("Screen");
            Console.ReadLine();
        }
Example #19
0
        public void Test()
        {
            string       message = "This is a test of serialized event data.";
            Exception    myError = new PlatformNotSupportedException("Error.Message", new InsufficientMemoryException());
            LogEventArgs arg1    = null;

            LogEventHandler eh = new LogEventHandler(delegate(object s, LogEventArgs e) { arg1 = e; });

            string[] stack = new string[] { "step 1", "step 2" };
            using (Log.Start(stack[0]))
                using (Log.Start(stack[1]))
                {
                    Log.LogWrite += eh;
                    Log.Error(myError, message);
                    Log.LogWrite -= eh;
                }
            Assert.IsNotNull(arg1);
            Assert.AreEqual(1, arg1.Count);
            Assert.AreEqual(1, arg1.ToArray().Length);

            EventData data = arg1.ToArray()[0];

            Assert.IsNotNull(data);
            BasicLogTest.AssertMessage(GetType(), stack, data, LogLevels.Error, message, myError.GetType());
            Assert.AreEqual(String.Join("::", stack), data.ToString("{LogStack}"));

            BinaryFormatter ser = new BinaryFormatter();
            MemoryStream    ms  = new MemoryStream();

            ser.Serialize(ms, arg1);
            Assert.Greater((int)ms.Position, 0);

            ms.Position = 0;
            object restored = ser.Deserialize(ms);

            Assert.IsNotNull(restored);
            Assert.AreEqual(typeof(LogEventArgs), restored.GetType());
            LogEventArgs arg2 = restored as LogEventArgs;

            Assert.IsNotNull(arg2);
            Assert.AreEqual(1, arg2.Count);
            Assert.AreEqual(1, arg2.ToArray().Length);

            data = arg2.ToArray()[0];
            Assert.IsNotNull(data);

            Assert.IsNotNull(data.Exception);
            Assert.AreNotEqual(myError.GetType(), data.Exception.GetType());
            Assert.AreEqual(typeof(Log).Assembly, data.Exception.GetType().Assembly);
            Assert.AreEqual(myError.Message, data.Exception.Message);
            Assert.AreEqual(myError.StackTrace, data.Exception.StackTrace);
            Assert.AreEqual(myError.Source, data.Exception.Source);
            Assert.AreEqual(myError.ToString(), data.Exception.ToString());

            BasicLogTest.AssertMessage(GetType(), stack, data, LogLevels.Error, message, data.Exception.GetType());
        }
Example #20
0
        private async Task InitializeEventHandlers()
        {
            Log.Information("Initializing Event Handlers");
            MessageHandler messageHandler = new MessageHandler(_discordClient);
            await messageHandler.InitializeMessageDependentServices();

            LogEventHandler logEventHandler = new LogEventHandler(_discordClient);

            logEventHandler.InitializeLogDependentServices();
        }
Example #21
0
        private void riseLogEvent(DateTime dateTime, string text, bool error)
        {
            LogEventHandler handler = LogEvent;
            LogEventArgs    args    = new LogEventArgs();

            args.dateTime = dateTime;
            args.text     = text;
            args.error    = error;
            handler?.Invoke(args);
        }
Example #22
0
        private static void OnNewLogAdded(string t, string c)
        {
            LogEventHandler handler = LogAddedEvent;
            LogEventArgs    e       = new LogEventArgs(t, c, DateTime.Now.ToString());

            if (handler != null)
            {
                handler(e);
            }
        }
Example #23
0
        public void Stop()
        {
            StopTimer();
            SafelyClosePort(false);

            detected = false;
            IsActive = false;

            OnClosed();
            LogEventHandler.Rise(this, new LogEventArgs(LogLineType.INFO, string.Format("{0} Stopped", PortDescription)));
        }
Example #24
0
 public ExternalTool()
 {
     try
     {
         OnInfoMsg += new InfoEventHandler(EmptyEventHandler);
         OnLogMsg  += new LogEventHandler(EmptyEventHandler);
     }
     catch (Exception)
     {
     }
 }
Example #25
0
        private static void LogMessage(LogEventArgs e)
        {
            Debug.WriteLine(e.Message);

            LogEventHandler handler = OnLogMessage;

            if (handler != null)
            {
                handler(null, e);
            }
        }
Example #26
0
 public ExternalTool()
 {
     try
     {
         OnInfoMsg += new InfoEventHandler(EmptyEventHandler);
         OnLogMsg += new LogEventHandler(EmptyEventHandler);
     }
     catch (Exception)
     {
     }
 }
Example #27
0
        private void OnLog(LogEventArgs e)
        {
            LogEventHandler handler = Logged;

            // Event will be null if there are no subscribers
            if (handler != null)
            {
                // Use the () operator to raise the event.
                handler(this, e);
            }
        }
Example #28
0
 public static void AddLogEvent(LoggingType logType, LogEventHandler e)
 {
     if (_logEvents == null)
     {
         _logEvents = new RealDictionary();
     }
     if (!_logEvents.ContainsKey(logType))
     {
         _logEvents.Add(logType, new List <LogEventHandler>());
     }
     ((List <LogEventHandler>)_logEvents[logType]).Add(e);
 }
		public void Test()
		{
			string message = "This is a test of serialized event data.";
			Exception myError = new PlatformNotSupportedException("Error.Message", new InsufficientMemoryException());
			LogEventArgs arg1 = null;

			LogEventHandler eh = new LogEventHandler(delegate(object s, LogEventArgs e) { arg1 = e; });
			string[] stack = new string[] { "step 1", "step 2" };
			using (Log.Start(stack[0]))
			using (Log.Start(stack[1]))
			{
				Log.LogWrite += eh;
				Log.Error(myError, message);
				Log.LogWrite -= eh;
			}
			Assert.IsNotNull(arg1);
			Assert.AreEqual(1, arg1.Count);
			Assert.AreEqual(1, arg1.ToArray().Length);

			EventData data = arg1.ToArray()[0];
			Assert.IsNotNull(data);
			BasicLogTest.AssertMessage(GetType(), stack, data, LogLevels.Error, message, myError.GetType());
			Assert.AreEqual(String.Join("::", stack), data.ToString("{LogStack}"));

			BinaryFormatter ser = new BinaryFormatter();
			MemoryStream ms = new MemoryStream();
			
			ser.Serialize(ms, arg1);
			Assert.Greater((int)ms.Position, 0);

			ms.Position = 0;
			object restored = ser.Deserialize(ms);
			Assert.IsNotNull(restored);
			Assert.AreEqual(typeof(LogEventArgs), restored.GetType());
			LogEventArgs arg2 = restored as LogEventArgs;

			Assert.IsNotNull(arg2);
			Assert.AreEqual(1, arg2.Count);
			Assert.AreEqual(1, arg2.ToArray().Length);

			data = arg2.ToArray()[0];
			Assert.IsNotNull(data);

			Assert.IsNotNull(data.Exception);
			Assert.AreNotEqual(myError.GetType(), data.Exception.GetType());
			Assert.AreEqual(typeof(Log).Assembly, data.Exception.GetType().Assembly);
			Assert.AreEqual(myError.Message, data.Exception.Message);
			Assert.AreEqual(myError.StackTrace, data.Exception.StackTrace);
			Assert.AreEqual(myError.Source, data.Exception.Source);
			Assert.AreEqual(myError.ToString(), data.Exception.ToString());

			BasicLogTest.AssertMessage(GetType(), stack, data, LogLevels.Error, message, data.Exception.GetType());
		}
Example #30
0
 public static void AddLogEvent(LoggingType logType, LogEventHandler e)
 {
     if (_logEvents == null)
     {
         _logEvents = new RealDictionary();
     }
     if (!_logEvents.ContainsKey(logType))
     {
         _logEvents.Add(logType, new List<LogEventHandler>());
     }
     ((List<LogEventHandler>)_logEvents[logType]).Add(e);
 }
Example #31
0
        static void Main(string[] args)
        {
            LogEventHandler logEventHandler = new LogEventHandler();

            TCPServer server = new TCPServer("197.167.1.24", 8037);

            Project37Service service = new Project37Service(server);

            service.Startup();

            for (; ; ) ;
        }
Example #32
0
        protected virtual void OnHandleLogEvent(object sender, LogEventArgs e)
        {
            // Make a temporary copy of the event to avoid possibility of
            // a race condition if the last subscriber unsubscribes
            // immediately after the null check and before the event is raised.
            LogEventHandler handler = HandleLog;

            // Event will be null if there are no subscribers
            if (handler != null)
            {
                // Use the () operator to raise the event.
                handler(sender, e);
            }
        }
Example #33
0
        /*
         * Complete Setup
         * url: location of obs-websocket (ip+port)
         * password: password
         * statusCallback: Method to call in case of a Status-Update
         * warningCallback: Method to call in case of a Warning-Message
         * infoCallback: Method to call in case of a Info-Message
         */
        public Kontrol2OBS(string url, string password, LogEventHandler statusCallback, LogEventHandler warningCallback, LogEventHandler infoCallback)
        {
            this.OnStatusLog  = statusCallback;
            this.OnWarningLog = warningCallback;
            this.OnInfoLog    = infoCallback;

            this.UpdateLogStatus("Loading Bindings...");
            this.bindingConfig = new Config(this, @".\config.xml");

            this.UpdateLogStatus("Connecting to websocket...");
            this.obsSocket = new OBSConnector(url, password);
            this.obsSocket.OnOBSWebsocketInfo += (s, e) => { this.OnInfoLog?.Invoke(s, new LogEventArgs()
                {
                    text = e.text
                }); };
            this.obsSocket.OnOBSWebsocketWarning += (s, e) => { this.OnWarningLog?.Invoke(s, new LogEventArgs()
                {
                    text = e.text
                }); };

            this.UpdateLogStatus("Setting up audio (This might take a while)...");
            this.SetupAudio();

            this.UpdateLogStatus("Connecting nanoKontrol2...");
            this.nanoController = new Controller(GetNanoKontrolInputDeviceName(), GetNanoKontrolOutputDeviceName());

            for (byte cc = 16; cc < 70; cc++)//Fancy Animation (Seems like it also helps debugging stuff lol)
            {
                this.nanoController.ToggleLED(cc, false);
            }
            for (byte cc = 16; cc < 70; cc++)
            {
                this.nanoController.ToggleLED(cc, true);
                Thread.Sleep(25);
            }
            for (byte cc = 16; cc < 70; cc++)
            {
                this.nanoController.ToggleLED(cc, false);
            }

            this.nanoController.OnMidiMessageReceived += OnNanoControllerInput;
            this.SetupNanoController();

            this.UpdateLogStatus("Setup Event Handlers...");
            this.SetupOBSEventHandlers();

            this.eventBuffer = new EventClock(this, 20);
            this.UpdateLogStatus("Connected and Ready!");
        }
Example #34
0
 private async Task <Device> TryGetDeviceAsync(WMIAccessService wmiAccessService, CancellationToken cancellationToken = new CancellationToken(), InformationCategory[] informationCategories = null, params InformationType[] informationTypes)
 {
     if (wmiAccessService != null)
     {
         try
         {
             return(await Task.Run(async() =>
             {
                 try
                 {
                     if (wmiAccessService.Connected)
                     {
                         var device = await new Device()
                                      .WithWMIAccessService(wmiAccessService)
                                      .WithInformationCategories(informationCategories)
                                      .WithInformationTypes(informationTypes)
                                      .WithQueries(Queries)
                                      .InitializeAsync(cancellationToken)
                                      .ConfigureAwait(false);
                         return device;
                     }
                 }
                 catch (OperationCanceledException operationCanceledException)
                 {
                     LogEventHandler.TaskIncompleted(operationCanceledException);
                 }
                 catch (Exception exception)
                 {
                     var wmiException = new WMIGeneralException(wmiAccessService.EndPoint, exception);
                     LogEventHandler.Exception(wmiException);
                 }
                 return null;
             }, cancellationToken).ConfigureAwait(false));
         }
         catch (OperationCanceledException operationCanceledException)
         {
             LogEventHandler.TaskIncompleted(operationCanceledException);
         }
         catch (Exception)
         {
             if (!cancellationToken.IsCancellationRequested)
             {
                 throw;
             }
         }
     }
     return(null);
 }
Example #35
0
 public void Open()
 {
     foreach (var port in ports)
     {
         try
         {
             port.Value.Open();
             port.Value.DataReceived  += dataReceivedHandler;
             port.Value.ErrorReceived += errorReceivedHandler;
         }
         catch (Exception ex)
         {
             LogEventHandler.Rise(this, new LogEventArgs(LogLineType.ERROR, ex));
         }
     }
 }
 internal RedirectedLog( LogEventHandler updateHandler )
 {
     m_LogStream = new StringWriter();
     UpdateEvent += updateHandler;
 }
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="logHandler"></param>
 public _LogWriter(LogEventHandler logHandler)
 {
     m_LogHandler = logHandler;
 }
Example #38
0
		public void TestBadMessageData()
		{
			Log.LogWrite += BreakIn_LogWrite;
			try
			{

				string message = "Bad {500} Data: {0}";
				Exception myError = i_blow_up;
				LogEventArgs arg1 = null;

				LogEventHandler eh = new LogEventHandler(delegate(object s, LogEventArgs e) { arg1 = e; });
				Log.LogWrite += eh;
				Log.LogWrite += BreakIn_LogWrite;
				Log.Error(myError, message, i_blow_up);
				Log.LogWrite -= eh;
				Log.LogWrite -= BreakIn_LogWrite;

				Assert.IsNotNull(arg1);
				Assert.AreEqual(1, arg1.Count);
				Assert.AreEqual(1, arg1.ToArray().Length);

				EventData data = arg1.ToArray()[0];
				Assert.IsNotNull(data);
				BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, myError.GetType());

				Assert.IsTrue(data.ToString().Contains(message));
				Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message));
				Assert.IsTrue(data.ToString("{Exception}").Contains(myError.GetType().FullName));

				data.Write((System.Xml.XmlTextWriter)null);
				System.Xml.XmlTextWriter wtr = new System.Xml.XmlTextWriter(new MemoryStream(new byte[10]), System.Text.Encoding.UTF32);
				data.Write(wtr);

				data.Write(new StreamWriter(new MemoryStream(new byte[10])));
				foreach (string format in badFormats)
					data.Write(new StreamWriter(new MemoryStream(new byte[10])), format);

				BinaryFormatter ser = new BinaryFormatter();
				MemoryStream ms = new MemoryStream();

				ser.Serialize(ms, arg1);
				Assert.Greater((int)ms.Position, 0);

				ms.Position = 0;
				object restored = ser.Deserialize(ms);
				Assert.IsNotNull(restored);
				Assert.AreEqual(typeof(LogEventArgs), restored.GetType());
				LogEventArgs arg2 = restored as LogEventArgs;

				Assert.IsNotNull(arg2);
				Assert.AreEqual(1, arg2.Count);
				Assert.AreEqual(1, arg2.ToArray().Length);

				data = arg2.ToArray()[0];
				Assert.IsNotNull(data);

				Assert.IsNotNull(data.Exception);
				Assert.AreNotEqual(myError.GetType(), data.Exception.GetType());
				Assert.AreEqual(typeof(Log).Assembly, data.Exception.GetType().Assembly);
				Assert.IsTrue(data.Exception.Message.Contains(myError.GetType().FullName));
				Assert.IsNotNull(data.Exception.ToString());
				Assert.AreNotEqual(String.Empty, data.Exception.ToString());
				Assert.IsTrue(data.Exception.ToString().Contains(myError.GetType().FullName));

				BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, data.Exception.GetType());

				System.Runtime.Serialization.SerializationInfo info = new System.Runtime.Serialization.SerializationInfo(data.Exception.GetType(), new myconverter());
				System.Runtime.Serialization.StreamingContext ctx = new System.Runtime.Serialization.StreamingContext();

				Exception err = (Exception)
					data.Exception.GetType().InvokeMember(null, System.Reflection.BindingFlags.CreateInstance,
					null, null, new object[] { info, ctx });

				Assert.IsNotNull(err.Message);
				Assert.IsNotEmpty(err.Message);
				Assert.IsNotNull(err.ToString());
				Assert.IsNotEmpty(err.ToString());
			}
			finally
			{
				Log.LogWrite -= BreakIn_LogWrite;
				Log.LogWrite -= BreakIn_LogWrite;
				Log.LogWrite -= BreakIn_LogWrite;
			}
		}
Example #39
0
 /// <summary>
 /// Detach a listening observer logging device from logger.
 /// </summary>
 /// <param name="observer">Observer (listening device).</param>
 public void Detach(ILog observer)
 {
     Log -= new LogEventHandler(observer.Log);
 }
Example #40
0
 /// <summary>
 /// Attach a listening observer logging device to logger.
 /// </summary>
 /// <param name="observer">Observer (listening device).</param>
 public void Attach(ILog observer)
 {
     Log += new LogEventHandler(observer.Log);
 }