Exemplo n.º 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;
        }
Exemplo n.º 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;
 }
Exemplo n.º 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));
            }
        }
Exemplo n.º 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));
            }
        }
Exemplo n.º 5
0
 public bool isDiapason(dfData data)
 {
     return isDiapasonST(this, data);
 }
Exemplo n.º 6
0
 public KeyValuePair<DateTime, DateTime>? getIntersection(dfData data)
 {
     return getIntersectionST(this, data);
 }
Exemplo n.º 7
0
 public bool isIntersect(dfData data)
 {
     return isIntersectST(this, data);
 }
Exemplo n.º 8
0
 public bool inRange(dfData data)
 {
     return inRangeST(this, data);
 }
Exemplo n.º 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");
     }            
 }