/// <summary>
 /// Initializes a new instance of the <see cref="Configuration"/> class. Uses the passed
 /// configuration storage to populate its settings.
 /// </summary>
 /// <param name="storage">The storage to use for settings.</param>
 public Configuration(IConfigurationStorage storage)
 {
     Storage = storage;
     Metadata = new Metadata();
     BeforeNotifyCallbacks = new List<Func<Event, bool>>();
     InternalBeforeNotifyCallbacks = new List<Action<Event>>();
 }
Exemplo n.º 2
0
        private void AddFormattedMessageToMetadata(ref Metadata metadata, string formattedMessage)
        {
            if (string.IsNullOrWhiteSpace(formattedMessage))
            {
                return;
            }

            if (metadata == null)
            {
                metadata = new Metadata();
            }

            if (!string.IsNullOrWhiteSpace(FormattedMessageTab))
            {
                metadata.AddToTab(FormattedMessageTab, FormattedMessageKey, formattedMessage);
            }
            else
            {
                metadata.AddToTab(FormattedMessageKey, formattedMessage);
            }
        }
        /// <summary>
        /// Finalises the event info by adding final metadata 
        /// </summary>
        /// <param name="eventInfo">The event info to finalise</param>
        /// <param name="error">The responsible event</param>
        /// <param name="lastException">The root exception of the event info</param>
        private void FinaliseEventInfo(EventInfo eventInfo, Event error, Exception lastException)
        {
            var expMetaData = new Metadata();

            expMetaData.AddToTab(ExpDetailsTabName, "runtimeEnding", error.IsRuntimeEnding);

            if (lastException.HelpLink != null)
                expMetaData.AddToTab(ExpDetailsTabName, "helpLink", lastException.HelpLink);

            if (lastException.Source != null)
                expMetaData.AddToTab(ExpDetailsTabName, "source", lastException.Source);

            if (lastException.TargetSite != null)
                expMetaData.AddToTab(ExpDetailsTabName, "targetSite", lastException.TargetSite);

            var metaData = Metadata.CombineMetadata(Config.Metadata, error.Metadata, expMetaData);
            metaData.FilterEntries(Config.IsEntryFiltered);
            eventInfo.Metadata = metaData.MetadataStore;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new event instance, ensures the right number of initial call stack frames are ignored
 /// </summary>
 /// <param name="exception">The exception to report on</param>
 /// <param name="runtimeEnding">True if the runtime is ending otherwise false</param>
 protected void Intialise(Exception exception, bool runtimeEnding)
 {
     Exception = exception;
     IsRuntimeEnding = runtimeEnding;
     Severity = Severity.Error;
     Metadata = new Metadata();
 }
Exemplo n.º 5
0
 /// <summary>
 /// Adds an existing metadata
 /// </summary>
 /// <param name="data">The metadata to add</param>
 public void AddMetadata(Metadata data)
 {
     Merge(this, data);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Merge two metadata objects into one. The first metadata object will be returned
        /// with the other metadata's data merged into it.
        /// </summary>
        /// <param name="currentData">The first (base) metadata object to merge</param>
        /// <param name="dataToAdd">The second metadata object to merge</param>
        /// <returns>The merged metadata</returns>
        private static Metadata Merge(Metadata currentData, Metadata dataToAdd)
        {
            if (dataToAdd == null || dataToAdd.MetadataStore.Count == 0)
                return currentData;

            var currStore = currentData.MetadataStore;
            var storeToAdd = dataToAdd.MetadataStore;

            // Loop through all the tabs that are in the data to add...
            foreach (var newTab in storeToAdd)
            {
                // If the tab doesn't exist in current data, add a blank tab
                if (!currStore.ContainsKey(newTab.Key))
                    currStore.Add(newTab.Key, new Dictionary<string, object>());

                var currTab = currStore[newTab.Key];

                foreach (var newTabEntry in newTab.Value)
                {
                    // Only add the entry if its a new tab entry, otherwise overwrite the existing entry
                    if (!currTab.ContainsKey(newTabEntry.Key))
                        currTab.Add(newTabEntry.Key, newTabEntry.Value);
                    else
                        currTab[newTabEntry.Key] = newTabEntry.Value;
                }
            }
            return currentData;
        }