private void OnEventHandled(TraceEvent e)
 {
     if (EventHandled != null)
     {
         EventHandled(new TraceEventArgs {Event = e});
     }
 }
 public void HandleEvent(TraceEvent traceEvent)
 {
     throw new NotImplementedException
         (
         "Client method of the TraceEventHandlerWrapper called!" +
         "Setup remoting logging correctly and try again!"
         );
 }
 public string Format(TraceEvent traceEvent)
 {
     var sb = new StringBuilder();
     sb.Append("ContextHolderId:" + traceEvent.ContextIdentifier.ContextHolderId + Environment.NewLine);
     sb.Append("ExternalId:" + traceEvent.ContextIdentifier.ExternalId + Environment.NewLine);
     sb.Append("ExternalReference:" + traceEvent.ContextIdentifier.ExternalReference + Environment.NewLine);
     sb.Append("ExternalParentId:" + traceEvent.ContextIdentifier.ExternalParentId + Environment.NewLine);
     sb.Append("InternalId:" + traceEvent.ContextIdentifier.InternalId + Environment.NewLine);
     sb.Append("InternalParentId:" + traceEvent.ContextIdentifier.InternalParentId + Environment.NewLine);
     sb.Append("ContextGuid:" + traceEvent.ContextIdentifier.ContextGuid + Environment.NewLine);
     sb.Append("Host:" + traceEvent.Location.HostName + Environment.NewLine);
     sb.Append("Module:" + traceEvent.Location.ModulePath + Environment.NewLine);
     sb.Append("Principal:" + traceEvent.Principal.Name + Environment.NewLine);
     sb.Append("ThreadName:" + traceEvent.Location.ThreadName + Environment.NewLine);
     sb.Append("**Message:" + Environment.NewLine + traceEvent.Message);
     return sb.ToString();
 }
        /// <summary>
        /// Just proof of concept implementation. Iteration 0.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="ae"></param>
        /// <returns></returns>
        private string getMappedEventValue(string path, TraceEvent ae)
        {
            if (path == "TraceEvent::Location.AppDomainName") return ae.Location.AppDomainName;
            if (path == "TraceEvent::Location.HostName") return ae.Location.HostName;
            if (path == "TraceEvent::Location.ModulePath") return ae.Location.ModulePath;
            if (path == "TraceEvent::Location.ClassName") return ae.Location.ClassName;
            if (path == "TraceEvent::Location.ThreadName") return ae.Location.ThreadName;
            if (path == "TraceEvent::Location.MethodName") return ae.Location.MethodName;
            if (path == "TraceEvent::Location.ProcessId") return ae.Location.ProcessId;
            //
            if (path == "TraceEvent::Principal.Name") return ae.Principal.Name;
            //
            if (path == "TraceEvent::LifeCycleType") return ae.LifeCycleType.ToString();
            //
            if (path == "TraceEvent::Message") return ae.Message;
            //
            if (path == "TraceEvent::Time") return ae.Time.ToString();
            //
            if (path == "TraceEvent::Type") return ae.Type.ToString();
            //
            if (path == "TraceEvent::EventId") return ae.EventId.ToString();
            //
            if (path == "TraceEvent::EventIdText") return ae.EventIdText;
            //
            if (path == "TraceEvent::ContextIdentifier.ContextHolderId")
                return ae.ContextIdentifier.ContextHolderId.ToString();
            if (path == "TraceEvent::ContextIdentifier.ExternalId") return ae.ContextIdentifier.ExternalId.ToString();
            if (path == "TraceEvent::ContextIdentifier.ExternalParentId")
                return ae.ContextIdentifier.ExternalParentId.ToString();
            if (path == "TraceEvent::ContextIdentifier.ExternalReference")
                return ae.ContextIdentifier.ExternalReference.ToString();
            if (path == "TraceEvent::ContextIdentifier.InternalId") return ae.ContextIdentifier.InternalId.ToString();
            if (path == "TraceEvent::ContextIdentifier.InternalParentId")
                return ae.ContextIdentifier.InternalParentId.ToString();
            if (path == "TraceEvent::ContextIdentifier.AuthenticationTokenId")
                return ae.ContextIdentifier.AuthenticationTokenId.ToString();

            return null;
        }
 /// <summary>
 /// <para>Copies the elements of an array to the end of the <see cref='Tools.Core.configuration.ApplicationEventCollection'/>.</para>
 /// </summary>
 /// <param name='value'>
 ///    An array of type <see cref='Tools.Core.configuration.ApplicationEvent'/> containing the objects to add to the collection.
 /// </param>
 /// <returns>
 ///   <para>None.</para>
 /// </returns>
 /// <seealso cref='Tools.Core.configuration.ApplicationEventCollection.Add'/>
 public void AddRange(TraceEvent[] value)
 {
     for (int i = 0; (i < value.Length); i = (i + 1))
     {
         Add(value[i]);
     }
 }
 /// <summary>
 ///    <para>Adds a <see cref='Tools.Core.configuration.ApplicationEvent'/> with the specified value to the 
 ///    <see cref='Tools.Core.configuration.ApplicationEventCollection'/> .</para>
 /// </summary>
 /// <param name='value'>The <see cref='Tools.Core.configuration.ApplicationEvent'/> to add.</param>
 /// <returns>
 ///    <para>The index at which the new element was inserted.</para>
 /// </returns>
 /// <seealso cref='Tools.Core.configuration.ApplicationEventCollection.AddRange'/>
 public int Add(TraceEvent value)
 {
     return List.Add(value);
 }
 /// <summary>
 ///     <para>
 ///       Initializes a new instance of <see cref='Tools.Core.configuration.ApplicationEventCollection'/> containing any array of <see cref='Tools.Core.configuration.ApplicationEvent'/> objects.
 ///    </para>
 /// </summary>
 /// <param name='value'>
 ///       A array of <see cref='Tools.Core.configuration.ApplicationEvent'/> objects with which to intialize the collection
 /// </param>
 public TraceEventCollection(TraceEvent[] value)
 {
     AddRange(value);
 }
 /// <summary>
 ///    <para> Removes a specific <see cref='Tools.Core.configuration.ApplicationEvent'/> from the 
 ///    <see cref='Tools.Core.configuration.ApplicationEventCollection'/> .</para>
 /// </summary>
 /// <param name='value'>The <see cref='Tools.Core.configuration.ApplicationEvent'/> to remove from the <see cref='Tools.Core.configuration.ApplicationEventCollection'/> .</param>
 /// <returns><para>None.</para></returns>
 /// <exception cref='System.ArgumentException'><paramref name='value'/> is not found in the Collection. </exception>
 public void Remove(TraceEvent value)
 {
     List.Remove(value);
 }
 public TraceRecord(TraceEvent e)
     : this()
 {
     _e = e;
 }
 /// <summary>
 /// <para>Copies the <see cref='Tools.Core.configuration.ApplicationEventCollection'/> values to a one-dimensional <see cref='System.Array'/> instance at the 
 ///    specified index.</para>
 /// </summary>
 /// <param name='array'><para>The one-dimensional <see cref='System.Array'/> that is the destination of the values copied from <see cref='Tools.Core.configuration.ApplicationEventCollection'/> .</para></param>
 /// <param name='index'>The index in <paramref name='array'/> where copying begins.</param>
 /// <returns>
 ///   <para>None.</para>
 /// </returns>
 /// <exception cref='System.ArgumentException'><para><paramref name='array'/> is multidimensional.</para> <para>-or-</para> <para>The number of elements in the <see cref='Tools.Core.configuration.ApplicationEventCollection'/> is greater than the available space between <paramref name='arrayIndex'/> and the end of <paramref name='array'/>.</para></exception>
 /// <exception cref='System.ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception>
 /// <exception cref='System.ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception>
 /// <seealso cref='System.Array'/>
 public void CopyTo(TraceEvent[] array, int index)
 {
     List.CopyTo(array, index);
 }
 /// <summary>
 /// <para>Gets a value indicating whether the 
 ///    <see cref='Tools.Core.configuration.ApplicationEventCollection'/> contains the specified <see cref='Tools.Core.configuration.ApplicationEvent'/>.</para>
 /// </summary>
 /// <param name='value'>The <see cref='Tools.Core.configuration.ApplicationEvent'/> to locate.</param>
 /// <returns>
 /// <para><see langword='true'/> if the <see cref='Tools.Core.configuration.ApplicationEvent'/> is contained in the collection; 
 ///   otherwise, <see langword='false'/>.</para>
 /// </returns>
 /// <seealso cref='Tools.Core.configuration.ApplicationEventCollection.IndexOf'/>
 public bool Contains(TraceEvent value)
 {
     return List.Contains(value);
 }
        public void HandleEvent(TraceEvent e)
        {
            #region Locals

            XmlDocument xd = null;
            TraceEvent tempEvent = e;

            #endregion

            try
            {
                if (TracingOptions.EnableFilter)
                {
                    if (!Filter.Test(e))
                    {
                        showFilteredOutMessagesCount(++filteredMessagesCount);
                        return;
                    }
                }

                #region If pre-cache - Add to xEventsCache

                if (TracingOptions.PreCacheEvents)
                {
                    // Combines both proof of concepts, one for objects and one for xdoc repreentation;
                    // _eventsCache.Add(e);

                    //xd = new XmlDocument();

                    //xd.LoadXml
                    //    (
                    //    SerializationUtility.Serialize2String
                    //    (
                    //    tempEvent
                    //    ));
                }

                #endregion
            }
            catch (Exception ex)
            {
                tempEvent = new TraceEvent
                    (
                    999999,
                    "Event Rendering Error: " + ex +
                    Environment.NewLine +
                    "Original message: " + e.Message
                    );
                if (TracingOptions.PreCacheEvents)
                {
                    xd = new XmlDocument();
                    xd.LoadXml
                        (
                        SerializationUtility.Serialize2String
                            (
                            tempEvent
                            ));
                }
            }
            currentCount++; //xEventsCache.DocumentElement.ChildNodes.Count;
            if (TracingOptions.PreCacheEvents)
            {
                //XmlNode nd = xEventsCache.ImportNode
                //    (
                //    xd.DocumentElement,
                //    true
                //    );
                //xEventsCache.DocumentElement.AppendChild
                //    (
                //    nd
                //    );
                navigator.AppendChild
                    (
                    SerializationUtility.Serialize2String
                        (
                        tempEvent
                        ));
                showCachedMessagesCount(currentCount);
            }

            #region add record to the list view

            if (!filtered)
            {
                addApplicationEventToListView(tempEvent, true);
                showShownMessagesCount(currentCount);
            }

            #endregion add record to the list view
        }
        public void addApplicationEventToListView(TraceEvent e, bool addsToCount)
        {
            if (addsToCount)
            {
                monitorPanel.MessagesCount++;
            }

            var li = new ListViewItem
                (
                (new TraceRecord(e)).PropertiesArray
                );
            li.Tag = e;

            Invoke
                (
                new AddListViewDelegate
                    (
                    addListItem
                    ),
                new object[]
                    {
                        li
                    }
                );
        }
        private void handleEvent(TraceEvent e)
        {
            //
            if (workspaceConfiguration.TracingOptions.LogToTraceControl)
            {
                eventTracerControl.Invoke
                    (
                    new Action<TraceEvent>(eventTracerControl.HandleEvent),
                    new object[] {e}
                    );
            }

            //***TraceEventHandler.Instance.HandleEvent
            //    (
            //    e
            //    );
        }
 public bool Test(TraceEvent ae)
 {
     // TODO: Very temporary and non-optimized algorithm in place, subject to change (SD)
     for (int i = 0; i < FilterEntries.Count; i ++)
     {
         FilterEntry feCandidate = FilterEntries[i];
         if (!feCandidate.Enabled) continue;
         //if (feCandidate == null) continue;
         // TODO: change from the implicitely AND.
         if (!feCandidate.Test(getMappedEventValue(feCandidate.Path, ae))) return false;
     }
     return true;
 }
 public TraceRecord()
 {
     _e = new TraceEvent();
 }
 /// <summary>
 ///    <para>Returns the index of a <see cref='Tools.Core.configuration.ApplicationEvent'/> in 
 ///       the <see cref='Tools.Core.configuration.ApplicationEventCollection'/> .</para>
 /// </summary>
 /// <param name='value'>The <see cref='Tools.Core.configuration.ApplicationEvent'/> to locate.</param>
 /// <returns>
 /// <para>The index of the <see cref='Tools.Core.configuration.ApplicationEvent'/> of <paramref name='value'/> in the 
 /// <see cref='Tools.Core.configuration.ApplicationEventCollection'/>, if found; otherwise, -1.</para>
 /// </returns>
 /// <seealso cref='Tools.Core.configuration.ApplicationEventCollection.Contains'/>
 public int IndexOf(TraceEvent value)
 {
     return List.IndexOf(value);
 }
 public static string GetFieldValueByName(string traceFieldName, TraceEvent ae)
 {
     switch (traceFieldName)
     {
         case "Time":
             return new TraceRecord(ae).Time;
         case "ContextHolderId":
             return new TraceRecord(ae).ContextHolderId;
         case "InternalId":
             return new TraceRecord(ae).InternalId;
         case "InternalParentId":
             return new TraceRecord(ae).InternalParentId;
         case "ExternalId":
             return new TraceRecord(ae).ExternalId;
         case "ExternalReference":
             return new TraceRecord(ae).ExternalReference;
         case "EventId":
             return new TraceRecord(ae).EventId;
         case "EventName":
             return new TraceRecord(ae).EventName;
         case "EventType":
             return new TraceRecord(ae).EventType;
         case "Message":
             return new TraceRecord(ae).Message;
         case "ThreadName":
             return new TraceRecord(ae).ThreadName;
         case "HostName":
             return new TraceRecord(ae).HostName;
         case "Guid":
             return new TraceRecord(ae).Guid;
         case "Source":
             return new TraceRecord(ae).Source;
         default:
             throw new ArgumentException
                 (
                 "Can't map value of " + traceFieldName + "to any of the TraceEvent fields."
                 );
     }
 }
 /// <summary>
 /// <para>Inserts a <see cref='Tools.Core.configuration.ApplicationEvent'/> into the <see cref='Tools.Core.configuration.ApplicationEventCollection'/> at the specified index.</para>
 /// </summary>
 /// <param name='index'>The zero-based index where <paramref name='value'/> should be inserted.</param>
 /// <param name=' value'>The <see cref='Tools.Core.configuration.ApplicationEvent'/> to insert.</param>
 /// <returns><para>None.</para></returns>
 /// <seealso cref='Tools.Core.configuration.ApplicationEventCollection.Add'/>
 public void Insert(int index, TraceEvent value)
 {
     List.Insert(index, value);
 }