private static bool MethodEqual(PurchaseMethod m1, PurchaseMethod m2) { if (m1 == null && m2 == null) { return(true); } else if ((m1 == null && m2 != null) || (m1 != null && m2 == null)) { return(false); } else { if (m1 is Cash && m2 is Cash) { return(((Cash)m1).Equals((Cash)m2)); } if (m1 is Card && m2 is Card) { return(((Card)m1).Equals((Card)m2)); } if (m1 is DirectDeposit && m2 is DirectDeposit) { return(((DirectDeposit)m1).Equals((DirectDeposit)m2)); } // If they have differing types they arent equal. return(false); } }
/// <summary> /// Initializes a new instance of the <see cref="ExpenseFilter"/> class. /// Used to declare an instance which matches a required exact value, with /// ranged date arguments. Filters created in this way will not be able to /// specify exact date values. /// </summary> /// <param name="name">The name to give to the expense filter.</param> /// <param name="valueExact">Exact value that we want to match. Required.</param> /// <param name="maxDate">High value for date range, defaults to DateTime.MaxValue.</param> /// <param name="minDate">Min value for date range, defaults to DateTime.MinValue.</param> /// <param name="place">Expression for places we want to match, defaults to match all strings.</param> /// <param name="tag">Expression for tag we want to match, defaults to match all strings.</param> /// <param name="keywords">Expression for keywords we want to match, defaults to match all strings.</param> /// <param name="method">Method we want to match. This is always an exact matcher unless none is specified, then purchase method is disregarded when filtering.</param> public ExpenseFilter( string name, float valueExact, DateTime maxDate = default(DateTime), DateTime minDate = default(DateTime), HashSet <string> place = null, HashSet <string> tag = null, HashSet <string> keywords = null, PurchaseMethod method = null) { // initialize name this.Name = name; // initialize value filters this.ExactValue = valueExact; // initialize date filters this.MaxDate = (maxDate == default(DateTime)) ? DateTime.MaxValue : maxDate; this.MinDate = (minDate == default(DateTime)) ? DateTime.MinValue : minDate; // initialize HashSet<string> arguments this.Place = place ?? new HashSet <string>(); this.Tag = tag ?? new HashSet <string>(); this.Keywords = keywords ?? new HashSet <string>(); // initialize method this.Method = method; }
/// <summary> /// Initializes a new instance of the <see cref="ExpenseFilter"/> class. /// Used to declare an instance which matches a required exact date, with /// ranged value arguments. Filters created in this way will not be able /// to specify exact value values. /// </summary> /// <param name="name">The name to give to the expense filter.</param> /// <param name="dateExact">Exact date to match. Required.</param> /// <param name="maxValue">High value for value range, defaults to float.MaxValue.</param> /// <param name="minValue">Low value for value range, defaults to float.MinValue.</param> /// <param name="place">Expression for places we want to match, defaults to match all strings.</param> /// <param name="tag">Expression for tag we want to match, defaults to match all strings.</param> /// <param name="keywords">Expression for keywords we want to match, defaults to match all strings.</param> /// <param name="method">Method we want to match. This is always an exact matcher unless none is specified, then purchase method is disregarded when filtering.</param> public ExpenseFilter( string name, DateTime dateExact, float maxValue = float.MaxValue, float minValue = float.MinValue, HashSet <string> place = null, HashSet <string> tag = null, HashSet <string> keywords = null, PurchaseMethod method = null) { // initialize name this.Name = name; // initialize value filters this.maxValue = maxValue; this.minValue = minValue; this.minDate = DateTime.MinValue; this.maxDate = DateTime.MaxValue; // initialize date filters this.ExactDate = dateExact; // initialize HashSet<string> arguments this.Place = place ?? new HashSet <string>(); this.Tag = tag ?? new HashSet <string>(); this.Keywords = keywords ?? new HashSet <string>(); // initialize method this.Method = method; }
/// <summary> /// Initializes a new instance of the <see cref="Expense"/> class. /// </summary> /// <param name="value">The monetary value of the currency.</param> /// <param name="date">Date the expense was incurred.</param> /// <param name="place">Place expense was incurred.</param> /// <param name="method">Information about how expense was incurred.</param> /// <param name="tag">Tags categorizing expense.</param> /// <param name="notes">Other miscellaneous information.</param> public Expense( float value, DateTime date, string place, PurchaseMethod method, HashSet <string> tag, string notes) { this.id = -1; this.value = value; this.date = date; this.place = place; this.purchaseMethod = method; this.tag = tag ?? new HashSet <string>(); this.notes = notes; }