예제 #1
0
 /// <summary>
 /// Checks that the two filters functionally are the same. That is they match the same set of expenses.
 /// The name is left out during this comparison.
 /// </summary>
 /// <param name="f">Filter to compare against.</param>
 /// <returns>True if the filters are functionaly equal. False if not.</returns>
 public bool FunctionalEquals(ExpenseFilter f)
 {
     return((this.MinValue == f.MinValue) &&
            (this.MaxValue == f.MaxValue) &&
            (this.MinDate == f.MinDate) &&
            (this.MaxDate == f.MaxDate) &&
            this.Place.SetEquals(f.Place) &&
            this.Tag.SetEquals(f.Tag) &&
            this.Keywords.SetEquals(f.Keywords) &&
            ExpenseFilter.MethodEqual(this.Method, f.Method));
 }
예제 #2
0
        /// <inheritdoc/>
        public override bool Equals(object obj)
        {
            ExpenseFilter f = (ExpenseFilter)obj;

            return((this.Name == f.Name) &&
                   (this.MinValue == f.MinValue) &&
                   (this.MaxValue == f.MaxValue) &&
                   (this.MinDate == f.MinDate) &&
                   (this.MaxDate == f.MaxDate) &&
                   this.Place.SetEquals(f.Place) &&
                   this.Tag.SetEquals(f.Tag) &&
                   this.Keywords.SetEquals(f.Keywords) &&
                   ExpenseFilter.MethodEqual(this.Method, f.Method));
        }
예제 #3
0
        /// <summary>
        /// computes union of two filters and returns a new filter.
        /// </summary>
        /// <param name="f1">First Filter to intersect with.</param>
        /// <param name="f2">Second Filter to intersect with.</param>
        /// <param name="filterName">Name to be given to the new filter. Defaults to "f1.Name|f2.Name".</param>
        /// <returns>ExpenseFilter containing the union.</returns>
        public static ExpenseFilter Union(ExpenseFilter f1, ExpenseFilter f2, string filterName = "")
        {
            if (filterName == string.Empty)
            {
                filterName = f1.Name + '|' + f2.Name;
            }

            return(new ExpenseFilter(
                       name: filterName,
                       maxValue: new[] { f1.MaxValue, f2.MaxValue }.Max(),
                       minValue: new[] { f1.MinValue, f2.MinValue }.Min(),
                       maxDate: new[] { f1.MaxDate, f2.MaxDate }.Max(),
                       minDate: new[] { f1.MinDate, f2.MinDate }.Min(),
                       place: new HashSet <string>(f1.Place.Union(f2.Place)),
                       tag: new HashSet <string>(f1.Tag.Union(f2.Tag)),
                       keywords: new HashSet <string>(f1.Keywords.Union(f2.Keywords)),
                       method: ExpenseFilter.MethodEqual(f1.Method, f2.Method) ? f1.Method : null));
        }