Esempio n. 1
0
        public static ICell <TResult> Derived <T1, T2, T3, T4, TResult>(ICell <T1> c1, ICell <T2> c2, ICell <T3> c3, ICell <T4> c4, Func <T1, T2, T3, T4, TResult> function)
        {
            if (c1 == null)
            {
                throw new ArgumentNullException(nameof(c1));
            }
            if (c2 == null)
            {
                throw new ArgumentNullException(nameof(c2));
            }
            if (c3 == null)
            {
                throw new ArgumentNullException(nameof(c3));
            }
            if (c4 == null)
            {
                throw new ArgumentNullException(nameof(c4));
            }

            var derived = new ManualCell <TResult>(() => function(c1.Value, c2.Value, c3.Value, c4.Value));

            RegisterObserver(derived, c1);
            RegisterObserver(derived, c2);
            RegisterObserver(derived, c3);
            RegisterObserver(derived, c4);

            return(derived);
        }
Esempio n. 2
0
        internal static ICell <TResult> Derived <T, TResult>(ICell <T> cell, Func <T, TResult> function)
        {
            var derived = new ManualCell <TResult>(() => function(cell.Value));

            RegisterObserver(derived, cell);

            return(derived);
        }
Esempio n. 3
0
        public static ICell <TResult> Derived <T, TResult>(IEnumerable <ICell <T> > cells, Func <IEnumerable <T>, TResult> function)
        {
            if (cells == null)
            {
                throw new ArgumentNullException(nameof(cells));
            }

            var derived = new ManualCell <TResult>(() => function(cells.Select(cell => cell.Value)));

            foreach (var cell in cells)
            {
                RegisterObserver(derived, cell);
            }

            return(derived);
        }
Esempio n. 4
0
 private static void RegisterObserver <T, R>(ManualCell <R> derived, ICell <T> cell)
 {
     cell.ValueChanged += derived.Refresh;
 }