예제 #1
0
		public void CanCallMethodWithOutParameter()
		{
			int i;
			InvocatingInterceptor interceptor = new InvocatingInterceptor(delegate { });
			WithOut proxy = (WithOut) generator.CreateInterfaceProxyWithoutTarget(typeof(WithOut), interceptor);
			proxy.Do(out i);
		}
예제 #2
0
		public void CanCreateProxyWithRefParam()
		{
			int i = 3;
			InvocatingInterceptor interceptor =
				new InvocatingInterceptor(delegate(IInvocation invocation) { invocation.Arguments[0] = 5; });
			WithOut proxy = (WithOut) generator.CreateInterfaceProxyWithoutTarget(typeof(WithOut), interceptor);
			proxy.Did(ref i);
			Assert.AreEqual(5, i);
		}
예제 #3
0
		public void CanAffectValueOfOutParameter()
		{
			int i;
			InvocatingInterceptor interceptor =
				new InvocatingInterceptor(delegate(IInvocation invocation) { invocation.Arguments[0] = 5; });
			WithOut proxy = (WithOut) generator.CreateInterfaceProxyWithoutTarget(typeof(WithOut), interceptor);
			proxy.Do(out i);
			Assert.AreEqual(5, i);
		}
예제 #4
0
		public void CanCreateComplexOutRefProxyOnClass()
		{
			int i = 3;
			string s1 = "2";
			string s2;
			InvocatingInterceptor interceptor = new InvocatingInterceptor(delegate(IInvocation invocation)
			                                                              	{
			                                                              		invocation.Arguments[0] = 5;
			                                                              		invocation.Arguments[1] = "aaa";
			                                                              		invocation.Arguments[3] = "bbb";
			                                                              	});
			MyClass proxy = (MyClass) generator.CreateClassProxy(typeof(MyClass), interceptor);
			proxy.MyMethod(out i, ref s1, 1, out s2);
			Assert.AreEqual(5, i);
			Assert.AreEqual(s1, "aaa");
			Assert.AreEqual(s2, "bbb");
		}