public static void DynamicInvoke_RefValueTypeParameter(object[] args, object[] expected) { Delegate d = new RefIntDelegate(RefIntMethod); d.DynamicInvoke(args); Assert.Equal(expected, args); }
public static void DynamicInvoke_TypeDoesntExactlyMatchRefValueType_ThrowsArgumentException() { Delegate d = new RefIntDelegate(RefIntMethod); Assert.Throws <ArgumentException>(null, () => d.DynamicInvoke((uint)7)); Assert.Throws <ArgumentException>(null, () => d.DynamicInvoke(IntEnum.One)); }
public static int Static_Void_RefInt(int value) { var dlg = new RefIntDelegate(Static_Void_RefIntImpl); var v = value; dlg(ref v); return(v); }
public static int Instance_Void_RefInt(int value) { var inst = new DelegateTypes(); var dlg = new RefIntDelegate(inst.Instance_Void_RefIntImpl); var v = value; dlg(ref v); return(v); }
public static int Static_Void_RefInt_Multicast(int value) { var dlg1 = new RefIntDelegate(Static_Void_RefIntImpl1); var dlg2 = new RefIntDelegate(Static_Void_RefIntImpl2); dlg1 += dlg2; var v = value; dlg1(ref v); return(v); }
public static void Run() { Console.WriteLine("Testing LINQ Expressions..."); { ParameterExpression pX = Expression.Parameter(typeof(int).MakeByRefType()); RefIntDelegate del = Expression.Lambda <RefIntDelegate>( Expression.Call(null, typeof(TestLinqExpressions).GetMethod(nameof(ModifyByRefAndThrow)), pX), pX).Compile(); int i = 0; try { del(ref i); } catch (Exception) { } if (i != 123) { throw new Exception(); } } }
public static void DynamicInvoke_TypeDoesntExactlyMatchRefValueType_ThrowsArgumentException() { Delegate d = new RefIntDelegate(RefIntMethod); Assert.Throws<ArgumentException>(null, () => d.DynamicInvoke((uint)7)); Assert.Throws<ArgumentException>(null, () => d.DynamicInvoke(IntEnum.One)); }
public void CallRefIntDelegate(RefIntDelegate d, ref int value) { d(ref value); }