public dFunction(DateTime date, e_direction direction) { if (!Enum.IsDefined(typeof(e_direction), direction)) throw new ArgumentException(nameof(direction)); data = new dfData(date, direction); _sender = this; _binded = null; }
public static KeyValuePair<DateTime, DateTime>? getIntersectionST(dfData data1, dfData data2) { if (isIntersectST(data1, data2)) { if (data1.direction == e_direction.Fixed) return new KeyValuePair<DateTime, DateTime>(data1.date, data1.date); else if (data2.direction == e_direction.Fixed) return new KeyValuePair<DateTime, DateTime>(data2.date, data2.date); else if (data1.date > data2.date) return new KeyValuePair<DateTime, DateTime>(data2.date, data1.date); else if (data1.date < data2.date) return new KeyValuePair<DateTime, DateTime>(data1.date, data2.date); else return null; } else return null; }
public static bool inRangeST(dfData instance, dfData data) { switch(instance.direction) { case e_direction.Fixed: return data.date == instance.date && data.direction == e_direction.Fixed ? true : false; case e_direction.Left: return data.date <= instance.date && (data.direction == e_direction.Fixed || data.direction == e_direction.Left) ? true : false; case e_direction.Right: return data.date >= instance.date && (data.direction == e_direction.Fixed || data.direction == e_direction.Right) ? true : false; default: throw new ArgumentException(nameof(inRange)); } }
public static bool isIntersectST(dfData data1, dfData data2) { if (data1.date == data2.date) return true; switch(data1.direction) { case e_direction.Fixed: return (data2.date > data1.date && data2.direction == e_direction.Left) || (data2.date < data1.date && data2.direction == e_direction.Right) ? true : false; case e_direction.Left: return (data2.date > data1.date && data2.direction == e_direction.Left) || (data2.date < data1.date) ? true : false; case e_direction.Right: return (data2.date < data1.date && data2.direction == e_direction.Right) || (data2.date > data1.date) ? true : false; default: throw new ApplicationException(nameof(isIntersect)); } }
public bool isDiapason(dfData data) { return isDiapasonST(this, data); }
public KeyValuePair<DateTime, DateTime>? getIntersection(dfData data) { return getIntersectionST(this, data); }
public bool isIntersect(dfData data) { return isIntersectST(this, data); }
public bool inRange(dfData data) { return inRangeST(this, data); }
public static bool isDiapasonST(dfData data1, dfData data2) { switch (data1.direction) { case e_direction.Fixed: return false; case e_direction.Left: return data2.date <= data1.date && data2.direction == e_direction.Right ? true : false; case e_direction.Right: return data2.date >= data1.date && data2.direction == e_direction.Left ? true : false; default: throw new ApplicationException("Unknown error"); } }