private bool _matchesIgnoreMethod(IgnoresV1Entry entry) { // Check connection state if (!this.Active) { return(false); } // Check IgnoreMethod switch (this._context.Options.IgnoreMethod) { case IgnoreMethod.None: return(false); case IgnoreMethod.Dimension: return(entry.Dimension == this._context.Dimension); case IgnoreMethod.Account: if (entry.Dimension != this._context.Dimension) { return(false); } return(entry.Account == this._context.Account); case IgnoreMethod.Character: if (entry.Dimension != this._context.Dimension) { return(false); } // Character id's are unique per dimension, // so there is no need to check the account value return(entry.ID == this._context.CharacterID); default: return(false); } }
public void Add(string character) { if (!this.Active) { throw new InvalidOperationException("The ignore list cannot be modified in the current state"); } // Find the character id character = Format.UppercaseFirst(character); UInt32 characterID = this._context.Chat.GetCharacterID(character); // Can't ignore that which does not exist if (characterID == 0) { return; } // And now, the action! lock (this) { // Remove previous conflicting entries bool changed; do { changed = false; foreach (IgnoresV1Entry entry in this._data.Entries) { if (entry.Dimension != this._context.Dimension) { continue; } if (entry.Account != this._context.Account) { continue; } if (entry.ID != this._context.CharacterID) { continue; } if (entry.CharacterID != characterID) { continue; } changed = true; this._data.Entries.Remove(entry); break; } }while (changed); // Add new entry IgnoresV1Entry newEntry = new IgnoresV1Entry(); newEntry.Dimension = this._context.Dimension; newEntry.Account = this._context.Account; newEntry.ID = this._context.CharacterID; newEntry.Character = character; newEntry.CharacterID = characterID; this._data.Entries.Add(newEntry); // Update cache if (this._ignored.ContainsKey(characterID)) { this._ignored[characterID] = character; } else { this._ignored.Add(characterID, character); } // Save changes this._save(); } // Fire event if (this.AddedEvent != null) { this.AddedEvent(this._context, new IgnoreEventArgs(character, characterID, true)); } }