Beispiel #1
0
 static void Main(string[] args)
 {
     Action chapter = () => Console.WriteLine(new string('*', 50));
     dFunction func = new dFunction(new DateTime(2000,1,1), e_direction.Right);
     dFunction func2 = new dFunction(new DateTime(2005, 1, 1), e_direction.Fixed);
     
     Action<DateTime> check = date => Console.WriteLine("{0:dd.MM.yyyy} => check => {1:dd.MM.yyyy}", date, func.check(date));
     Console.WriteLine(func);
     Console.WriteLine("Func is binded {0} with {1}", func.isBinded, func.binded != null ? func.binded.ToString() : "Null");
     chapter();
     check(new DateTime(2010,1,1));
     check(new DateTime(2000, 1, 1));
     check(new DateTime(1910, 1, 1));
     chapter();
     func.setDiapason(func2);
     Console.WriteLine("Func is binded {0} with {1}", func.isBinded, func.binded != null ? func.binded.ToString() : "Null");
     chapter();
     check(new DateTime(1910, 1, 1));
     check(new DateTime(2000, 1, 1));
     check(new DateTime(2003, 1, 1));
     check(new DateTime(2005, 1, 1));
     check(new DateTime(2006, 1, 1));
     chapter();
     func.setDiapason(null);
     Console.WriteLine("Func is binded {0} with {1}", func.isBinded, func.binded != null ? func.binded.ToString() : "Null");
     chapter();
     check(new DateTime(2010, 1, 1));
     check(new DateTime(2000, 1, 1));
     check(new DateTime(1910, 1, 1));
     chapter();
     Console.WriteLine("End");
     Console.ReadLine();
 }
Beispiel #2
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;
        }
Beispiel #3
0
        public void setDiapason(dFunction function)
        {
            if (function == _binded) return;

            dFunction temp = _binded;
            _binded = function;

            bindedChangedPushEvent(temp, _binded);
        }
Beispiel #4
0
        public static dFunction operator -(dFunction dfunc1, dFunction dfunc2)
        {
            dFunction result = new dFunction();
            result.data = dfunc1.data - dfunc2.data;

            return result;
        }
Beispiel #5
0
 protected void bindedChangedPushEvent(dFunction Old, dFunction New)
 {
     event_bindedChanged?.Invoke(_sender, new valueChange<dFunction>(Old, New));
 }