/// <summary> /// Check that both breaks have same types and same Duration, To and From values. /// </summary> /// <param name="breakObject">Brake to compare with this.</param> /// <returns>'True' if breaks types and Duration, To and From /// values are the same, 'false' otherwise.</returns> internal override bool EqualsByValue(Break breakObject) { TimeWindowBreak breakToCompare = breakObject as TimeWindowBreak; return(breakToCompare != null && base.EqualsByValue(breakObject) && breakToCompare.From == this.From && breakToCompare.To == this.To); }
/// <summary> /// Clones the <c>TimeWindowBreak</c> object. /// </summary> /// <returns>Cloned object.</returns> public override object Clone() { var obj = new TimeWindowBreak(); obj.To = this.To; obj.From = this.From; obj.Duration = this.Duration; obj.Day = this.Day; return(obj); }
/// <summary> /// Parses string and splits it to properties values. /// </summary> /// <param name="value">DB order custom properties string.</param> /// <returns>Parsed capacities.</returns> internal static Breaks CreateFromDBString(string value) { var breaks = new Breaks(); if (null != value) { var valuesSeparator = new string[1] { CommonHelpers.SEPARATOR_ALIAS }; string[] values = value.Split(valuesSeparator, StringSplitOptions.RemoveEmptyEntries); var separator = new string[1] { PART_SPLITTER }; for (int index = 0; index < values.Length; ++index) { string currValue = values[index]; Break instBreak = null; if (-1 == currValue.IndexOf(PART_SPLITTER)) { // support old version instBreak = new TimeWindowBreak(); instBreak.InitFromString(currValue); } else { // current version string[] breakValues = currValue.Split(separator, StringSplitOptions.RemoveEmptyEntries); Debug.Assert(2 == breakValues.Length); Type type = Type.GetType(breakValues[0]); instBreak = (Break)Activator.CreateInstance(type); instBreak.InitFromString(breakValues[1]); // init state } Debug.Assert(null != instBreak); breaks.Add(instBreak); } } return(breaks); }
/// <summary> /// Clones the <c>TimeWindowBreak</c> object. /// </summary> /// <returns>Cloned object.</returns> public override object Clone() { var obj = new TimeWindowBreak(); obj.To = this.To; obj.From = this.From; obj.Duration = this.Duration; obj.Day = this.Day; return obj; }
/// <summary> /// Comparer for two <c>TimeWindowBrakes</c>. /// </summary> /// <param name="break1">First <c>Brake</c>.</param> /// <param name="break2">Second <c>Brake</c>.</param> /// <returns>Result of comparing. Breaks are compared by EffectiveFrom property.</returns> private static int _TimeWindowBreakComparer(TimeWindowBreak break1, TimeWindowBreak break2) { if (break1.EffectiveFrom > break2.EffectiveFrom) return 1; else if (break1.EffectiveFrom < break2.EffectiveFrom) return -1; else return 0; }