Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            MyMethodInvoker invoker = Add;

            invoker += new MyMethodInvoker(Subtract);
            int result = invoker.Invoke(38, 4);

            foreach (MyMethodInvoker inv in invoker.GetInvocationList())
            {
                result = inv.Invoke(38, 4);
            }
            Console.WriteLine(result);

            Program p = new Program();

            p.State  = 1;
            invoker += new MyMethodInvoker(p.Foo);

            invoker -= new MyMethodInvoker(Add);
            invoker -= Subtract;
            invoker(11, 22);

            Program p2 = new Program();

            p2.State = 2;

            Bar(Add);


            MyMethodInvoker invoker2 = (int x, int y) =>
            {
                return(x / y);
            };
        }
Ejemplo n.º 2
0
        public void PreparedArgumentsIsNeverNull()
        {
            MyMethodInvoker vkr = new MyMethodInvoker();

            Assert.IsNotNull(vkr.GetPreparedArguments(),
                             "PreparedArguments is null even before Prepare() is called; must NEVER be null.");
            vkr.NullOutPreparedArguments();
            Assert.IsNotNull(vkr.GetPreparedArguments(),
                             "PreparedArguments should revert to the empty object[] when set to null; must NEVER be null.");
        }
Ejemplo n.º 3
0
        public RealtimeWindowOutput(uint width, uint height, Form form)
        {
            Width = width;
              Height = height;

              image = new Bitmap((int)Width, (int)Height);

              this.form = form;
              form.Width = (int)Width;
              form.Height = (int)Height;
              form.FormBorderStyle = FormBorderStyle.FixedSingle;
              form.BackColor = Color.White;
              form.BackgroundImage = image;

              g = form.CreateGraphics();

              func = new MyMethodInvoker(WritePixel);
        }
		public void PreparedArgumentsIsNeverNull()
		{
			MyMethodInvoker vkr = new MyMethodInvoker();
			Assert.IsNotNull(vkr.GetPreparedArguments(),
				"PreparedArguments is null even before Prepare() is called; must NEVER be null.");
			vkr.NullOutPreparedArguments();
			Assert.IsNotNull(vkr.GetPreparedArguments(),
				"PreparedArguments should revert to the empty object[] when set to null; must NEVER be null.");
		}