예제 #1
0
        public void MultiMethod_Wrappers_Will_Dispatch_To_Correct_Target()
        {
            Circle c1 = new Circle(1);
            Circle c2 = new Circle(2);

            MultiMethod.Func <IShape, string> f1 = Dispatcher.Func <IShape, string>(c1.Intersect);
            MultiMethod.Func <IShape, string> f2 = Dispatcher.Func <IShape, string>(c2.Intersect);

            Assert.AreEqual("Circle(1) x Rectangle", f1(new Rectangle()).ReturnValue);
            Assert.AreEqual("Circle(2) x Rectangle", f2(new Rectangle()).ReturnValue);
        }
        public DispatchTestHelper()
        {
            _mm1 = Dispatcher.Action<A>(this.MM1);
            _mm2 = Dispatcher.Action<A, A>(this.MM2);
            _mm3 = Dispatcher.Action<A, A, A>(this.MM3);
            _mm4 = Dispatcher.Action<A, A, A, A>(this.MM4);

            _ff1 = Dispatcher.Func<A, string>(this.FF1);
            _ff2 = Dispatcher.Func<A, A, string>(this.FF2);
            _ff3 = Dispatcher.Func<A, A, A, string>(this.FF3);
            _ff4 = Dispatcher.Func<A, A, A, A, string>(this.FF4);
        }
예제 #3
0
 public Shape()
 {
     _intersect = Dispatcher.Func <IShape, string>(this.Intersect);
 }