/// <summary> /// Constructor /// </summary> /// <param name="entry"> /// A LogConfigEntry instance whose value members must be copied into /// this instance (deep copy) /// </param> protected LogConfigEntry(LogConfigEntry entry) : base(entry) { // Deep copy m_id = entry.m_id; m_logNameMask = entry.m_logNameMask; m_wildcardExpression = null; }
// ****************************************************************** // * * // * ILogConfig Interface * // * * // ****************************************************************** /// <summary> /// Gets the entry that matches the specified log name. If no specific entry /// could be found in <i>Entries</i> collection that matches the specified /// logname, the default entry will be returned /// </summary> /// <param name="logName"> /// A string that specifies the name of a log /// </param> /// <returns> /// A reference to an entry from the <i>Entries</i> collection that matches /// the specified name; if no matching entry could be found the default entry /// will be returned. /// </returns> public virtual LogConfigDefaultEntry GetEntry(string logName) { // By default we use default entry as reference var entry = DefaultEntry; // Check if we can find a specific entry for the given name LogConfigEntry configEntry = null; if (TryGetEntryByName(logName, out configEntry)) { entry = configEntry; } // Return reference of resolved config entry return(entry); }
/// <summary> /// Tries to find a LogConfigEntry whose mask matches the specified log name /// </summary> /// <param name="logName"> /// A string that specifies the name of a log /// </param> /// <param name="entry"> /// A LogConfigEntry reference to a matching entry if one could be resolved; /// otherwise this reference will return <i>null</i> /// </param> /// <returns> /// A bool <i>true</i> if a matching configuration entry could be resolved for /// the specified log name; otherwise a bool <i>false</i> will be returned. /// </returns> public virtual bool TryGetEntryByName(string logName, out LogConfigEntry entry) { // Set default return value entry = null; // Iterate all entries and find one whose mask matches specified name foreach (var e in Entries) { // Does this entry match? if (e.IsMatch(logName)) { // We found a match, now set reference and break loop entry = e; break; } } // Did we find an entry? return(entry != null); }