示例#1
0
        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;
        }
示例#2
0
 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;
 }
示例#3
0
        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));
            }
        }
示例#4
0
        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));
            }
        }
示例#5
0
 public bool isDiapason(dfData data)
 {
     return isDiapasonST(this, data);
 }
示例#6
0
 public KeyValuePair<DateTime, DateTime>? getIntersection(dfData data)
 {
     return getIntersectionST(this, data);
 }
示例#7
0
 public bool isIntersect(dfData data)
 {
     return isIntersectST(this, data);
 }
示例#8
0
 public bool inRange(dfData data)
 {
     return inRangeST(this, data);
 }
示例#9
0
 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");
     }            
 }