public void AddFilter(Filter filter) { if (!_filters.Contains(filter)) { _filters.Add(filter); } }
public Filter RemoveFilter(Filter filter) { if (_filters.Contains(filter)) { _filters.Remove(filter); return filter; } else { return null; } }
/// <summary> /// Override the Equal method. /// </summary> /// <param name="other">The Filter to compare to.</param> /// <returns>true if the other Filter is a Extension Filter and have the same pattern and <see cref="FilterMode"/> </returns> public override bool Equals(Filter other) { ExtensionFilter filter = other as ExtensionFilter; if (filter == null) { return false; } bool parentEqual = base.Equals(filter); if (parentEqual) { if (!filter.Pattern.ToLower().Equals(_pattern.ToLower())) { return false; } } else { return false; } return true; }
/// <summary> /// Removes the filter that is passed as parameter from the existing list of filters /// </summary> /// <param name="filter">The Filter object that represents the fitler to be removed</param> /// <param name="updated">The long value that represents the updated date of the filter list</param> /// <returns>the filter that is removed if it exists in the list of filters; otherwise, null</returns> public Filter RemoveFilter(Filter filter, long updated) { if (_filters.Contains(filter)) { _filters.Remove(filter); _filtersUpdatedDate = updated; _lastUpdatedDate = TaggingHelper.GetCurrentTime(); return filter; } else { return null; } }
/// <summary> /// Adds a filter to the list of filters /// </summary> /// <param name="filter">The Filter object that represents the filter to be added</param> /// <param name="updated">The long value that represents the updated date of the filter list</param> public void AddFilter(Filter filter, long updated) { if (!_filters.Contains(filter)) { _filters.Add(filter); _filtersUpdatedDate = updated; _lastUpdatedDate = TaggingHelper.GetCurrentTime(); } }
/// <summary> /// This checks for duplicate filters by supplying in filter to check for and the index of which it is in the list /// </summary> /// <param name="f">Filter to check duplicates with</param> /// <param name="indexOfCurrentSelectedFilter">Current Selected Filter index</param> /// <returns></returns> private bool CheckDuplicateFilters(Filter f, int indexOfCurrentSelectedFilter) { for (int i = 0; i < filters.Count; i++) { Filter tempFilter = filters[i]; // if duplicate filter found if (tempFilter.Equals(f)) { // if duplicate filter found is not the filter supplied if (indexOfCurrentSelectedFilter != i) return true; } } return false; }
/// <summary> /// Selects the filter in ListBoxFilter by Filter /// </summary> /// <param name="f">Filter to select</param> private void SelectFilterInListBoxFilter(Filter f) { int index = filters.IndexOf(f); ListBoxFilters.SelectedIndex = index; TxtBoxPattern.Focus(); }
/// <summary> /// Check if two Filter is equals. /// </summary> /// <param name="other">the Filter to compare to</param> /// <returns>true if it matches, false otherwise</returns> public virtual bool Equals(Filter other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Equals(other.Mode, Mode); }
/// <summary> /// Initializes a new instance of the FilterAlreadyExistException class with its message string /// set to message that is given by <see cref="ErrorMessage.FILTER_ALREADY_EXISTS_EXCEPTION"> /// ErrorMessage.FILTER_ALREADY_EXISTS_EXCEPTION</see> string value and the filter property to the /// filter that is passed as parameter /// </summary> /// <param name="filter">The <see cref="Filter">Filter</see> object that represents the filter /// that already exists</param> public FilterAlreadyExistException(Filter filter) : base(ErrorMessage.FILTER_ALREADY_EXISTS_EXCEPTION) { _filter = filter; }
/// <summary> /// Creates a filter Xml element from the filter that is passed as parameter /// </summary> /// <param name="xmlDoc">The Xmldocument object that represents the Xml document that the /// Xml element to be created belongs to</param> /// <param name="filter">The <see cref="Filter">Filter</see> object that /// represents the filter to be used to create the Xml element</param> /// <returns></returns> private static XmlElement CreateFilterElement(XmlDocument xmlDoc, Filter filter) { XmlElement filterElement = xmlDoc.CreateElement(ELE_FILTER_CHILD_FILTER); string mode = filter.Mode == FilterMode.INCLUDE ? VALUE_FILTER_MODE_INCLUDE : VALUE_FILTER_MODE_EXCLUDE; filterElement.SetAttribute(ATTR_FILTER_MODE, mode); if (filter is ExtensionFilter) { string type = VALUE_FILTER_TYPE_EXT; filterElement.SetAttribute(ATTR_FILTER_TYPE, type); XmlElement ext = xmlDoc.CreateElement(ELE_FILTER_TYPE_EXT_PATTERN); ext.InnerText = ((ExtensionFilter)filter).Pattern; filterElement.AppendChild(ext); } return filterElement; }
/// <summary> /// Initializes a new instance of the FilterNotFoundException class with its message string /// set to message that is given by <see cref="ErrorMessage.FILTER_NOT_FOUND_EXCEPTION"> /// ErrorMessage.FILTER_NOT_FOUND_EXCEPTION</see> string value and the filter property to the /// filter that is passed as parameter /// </summary> /// <param name="filter">The <see cref="Filter">Filter</see> object that represents the filter /// that is not found</param> public FilterNotFoundException(Filter filter) : base(ErrorMessage.FILTER_NOT_FOUND_EXCEPTION) { _filter = filter; }