/// <summary> /// Copia mensagens entre diários. /// </summary> /// <param name="source">O diário de origem.</param> /// <param name="destination">O diário de destino.</param> private void CopyErrors( ILogStatus <string, EParseErrorLevel> source, ILogStatus <string, EParseErrorLevel> destination) { foreach (var kvp in source.GetLogs()) { destination.AddLog(kvp.Value, kvp.Key); } }
/// <summary> /// Copia todos os erros registados do diário proporcionado. /// </summary> /// <param name="other">O diário do qual se pretende copiar os erros.</param> public void CopyFrom(ILogStatus <Log, Level> other) { if (other != null) { var otherEnum = other.GetLogs().GetEnumerator(); if (otherEnum.MoveNext()) { // Início da cópia var previousLevel = otherEnum.Current.Key; var messageList = default(List <Log>); if (!this.logs.TryGetValue(previousLevel, out messageList)) { messageList = new List <Log>(); this.logs.Add(previousLevel, messageList); } messageList.Add(otherEnum.Current.Value); // Restantes elementos while (otherEnum.MoveNext()) { var currentLevel = otherEnum.Current.Key; if (this.logs.Comparer.Equals( previousLevel, currentLevel)) { messageList.Add(otherEnum.Current.Value); } else { // O nível poderá existir antes do início da cópia if (!this.logs.TryGetValue(currentLevel, out messageList)) { messageList = new List <Log>(); this.logs.Add(currentLevel, messageList); } messageList.Add(otherEnum.Current.Value); } } } } }