예제 #1
0
        /// <summary>
        /// Networks the address changed callback.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private static void NetworkAddressChangedCallback(object sender, EventArgs e)
        {
            var adapters = NetworkInterface.GetAllNetworkInterfaces();

            var eventInfo = new List <NetworkAddressChangedEventInformation>(adapters.Count());

            foreach (NetworkInterface adapter in adapters)
            {
                var networkEvent = new NetworkAddressChangedEventInformation
                {
                    Id   = adapter.Id,
                    Name = adapter.Name,
                    OperationalStatus = adapter.OperationalStatus
                };

                eventInfo.Add(networkEvent);
            }

            eventInfo.TrimExcess();

            var eventArgs = new SystemChangedEventArgs
            {
                SystemEventType  = SystemEventType.NetworkAddressChanged,
                EventInformation = eventInfo
            };

            OnSystemChanged(eventArgs);
        }
예제 #2
0
        /// <summary>
        /// Handles the UnhandledException event of the CurrentDomain control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="UnhandledExceptionEventArgs" /> instance containing the event data.</param>
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var eventArgs = new SystemChangedEventArgs {
                SystemEventType = SystemEventType.UnhandledException
            };

            var eventInfo = new UnhandledExceptionEventInformation {
                IsTerminating = e.IsTerminating, Exception = e.ExceptionObject as LoggableException
            };

            eventArgs.EventInformation = new UnhandledExceptionEventInformation[] { eventInfo };

            OnSystemChanged(eventArgs);
        }
예제 #3
0
        /// <summary>
        /// Handles the NetworkAvailabilityChanged event of the NetworkChange control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="NetworkAvailabilityEventArgs" /> instance containing the event data.</param>
        private static void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
        {
            var eventInfo = new List <NetworkAvailabilityChangedEventInformation>(1)
            {
                new NetworkAvailabilityChangedEventInformation {
                    NetworkAvailable = e.IsAvailable
                }
            };

            Trace.Write($"Network availble: {e.IsAvailable}");

            var eventArgs = new SystemChangedEventArgs {
                SystemEventType = SystemEventType.NetworkAvailabilityChanged, EventInformation = eventInfo
            };

            OnSystemChanged(eventArgs);
        }
        /// <summary>
        /// Networks the address changed callback.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private static void NetworkAddressChangedCallback(object sender, EventArgs e)
        {
            var adapters = NetworkInterface.GetAllNetworkInterfaces();

            var eventInfo = new List <NetworkAddressChangedEventInformation>(adapters.Length);

            eventInfo.AddRange(adapters.Select(adapter => new NetworkAddressChangedEventInformation
            {
                Id   = adapter.Id,
                Name = adapter.Name,
                OperationalStatus = adapter.OperationalStatus
            }));

            eventInfo.TrimExcess();

            var eventArgs = new SystemChangedEventArgs
            {
                SystemEventType  = SystemEventType.NetworkAddressChanged,
                EventInformation = eventInfo
            };

            OnSystemChanged(eventArgs);
        }
예제 #5
0
 /// <summary>
 /// Handles the <see cref="E:SystemChanged" /> event.
 /// </summary>
 /// <param name="e">The <see cref="SystemChangedEventArgs" /> instance containing the event data.</param>
 private static void OnSystemChanged(SystemChangedEventArgs e) => SystemChanged?.Invoke(AppDomain.CurrentDomain, e);