mscorlib(4.0.0.0) API with additions
Delegate.cs
1 using System.Reflection;
5 using System.Security;
6 using System.Threading;
7 
8 namespace System
9 {
11  [Serializable]
12  [ClassInterface(ClassInterfaceType.AutoDual)]
13  [ComVisible(true)]
14  [__DynamicallyInvokable]
15  public abstract class Delegate : ICloneable, ISerializable
16  {
17  [SecurityCritical]
18  internal object _target;
19 
20  [SecurityCritical]
21  internal object _methodBase;
22 
23  [SecurityCritical]
24  internal IntPtr _methodPtr;
25 
26  [SecurityCritical]
27  internal IntPtr _methodPtrAux;
28 
32  [__DynamicallyInvokable]
33  public MethodInfo Method
34  {
35  [__DynamicallyInvokable]
36  get
37  {
38  return GetMethodImpl();
39  }
40  }
41 
44  [__DynamicallyInvokable]
45  public object Target
46  {
47  [__DynamicallyInvokable]
48  get
49  {
50  return GetTarget();
51  }
52  }
53 
61  [SecuritySafeCritical]
62  protected Delegate(object target, string method)
63  {
64  if (target == null)
65  {
66  throw new ArgumentNullException("target");
67  }
68  if (method == null)
69  {
70  throw new ArgumentNullException("method");
71  }
72  if (!BindToMethodName(target, (RuntimeType)target.GetType(), method, (DelegateBindingFlags)10))
73  {
74  throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth"));
75  }
76  }
77 
87  [SecuritySafeCritical]
88  protected Delegate(Type target, string method)
89  {
90  if (target == null)
91  {
92  throw new ArgumentNullException("target");
93  }
94  if (target.IsGenericType && target.ContainsGenericParameters)
95  {
96  throw new ArgumentException(Environment.GetResourceString("Arg_UnboundGenParam"), "target");
97  }
98  if (method == null)
99  {
100  throw new ArgumentNullException("method");
101  }
102  RuntimeType runtimeType = target as RuntimeType;
103  if (runtimeType == null)
104  {
105  throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), "target");
106  }
107  BindToMethodName(null, runtimeType, method, (DelegateBindingFlags)37);
108  }
109 
110  private Delegate()
111  {
112  }
113 
121  [__DynamicallyInvokable]
122  public object DynamicInvoke(params object[] args)
123  {
124  return DynamicInvokeImpl(args);
125  }
126 
134  [SecuritySafeCritical]
135  protected virtual object DynamicInvokeImpl(object[] args)
136  {
137  RuntimeMethodInfo runtimeMethodInfo = (RuntimeMethodInfo)RuntimeType.GetMethodBase(methodHandle: new RuntimeMethodHandleInternal(GetInvokeMethod()), reflectedType: (RuntimeType)GetType());
138  return runtimeMethodInfo.UnsafeInvoke(this, BindingFlags.Default, null, args, null);
139  }
140 
146  [SecuritySafeCritical]
147  [__DynamicallyInvokable]
148  public override bool Equals(object obj)
149  {
150  if (obj == null || !InternalEqualTypes(this, obj))
151  {
152  return false;
153  }
154  Delegate @delegate = (Delegate)obj;
155  if (_target == @delegate._target && _methodPtr == @delegate._methodPtr && _methodPtrAux == @delegate._methodPtrAux)
156  {
157  return true;
158  }
159  if (_methodPtrAux.IsNull())
160  {
161  if (!@delegate._methodPtrAux.IsNull())
162  {
163  return false;
164  }
165  if (_target != @delegate._target)
166  {
167  return false;
168  }
169  }
170  else
171  {
172  if (@delegate._methodPtrAux.IsNull())
173  {
174  return false;
175  }
176  if (_methodPtrAux == @delegate._methodPtrAux)
177  {
178  return true;
179  }
180  }
181  if (_methodBase == null || @delegate._methodBase == null || !(_methodBase is MethodInfo) || !(@delegate._methodBase is MethodInfo))
182  {
183  return InternalEqualMethodHandles(this, @delegate);
184  }
185  return _methodBase.Equals(@delegate._methodBase);
186  }
187 
190  [__DynamicallyInvokable]
191  public override int GetHashCode()
192  {
193  return GetType().GetHashCode();
194  }
195 
201  [__DynamicallyInvokable]
202  public static Delegate Combine(Delegate a, Delegate b)
203  {
204  if ((object)a == null)
205  {
206  return b;
207  }
208  return a.CombineImpl(b);
209  }
210 
215  [ComVisible(true)]
216  [__DynamicallyInvokable]
217  public static Delegate Combine(params Delegate[] delegates)
218  {
219  if (delegates == null || delegates.Length == 0)
220  {
221  return null;
222  }
223  Delegate @delegate = delegates[0];
224  for (int i = 1; i < delegates.Length; i++)
225  {
226  @delegate = Combine(@delegate, delegates[i]);
227  }
228  return @delegate;
229  }
230 
233  [__DynamicallyInvokable]
234  public virtual Delegate[] GetInvocationList()
235  {
236  return new Delegate[1]
237  {
238  this
239  };
240  }
241 
245  [SecuritySafeCritical]
246  protected virtual MethodInfo GetMethodImpl()
247  {
248  if (_methodBase == null || !(_methodBase is MethodInfo))
249  {
250  IRuntimeMethodInfo runtimeMethodInfo = FindMethodHandle();
251  RuntimeType runtimeType = RuntimeMethodHandle.GetDeclaringType(runtimeMethodInfo);
252  if ((RuntimeTypeHandle.IsGenericTypeDefinition(runtimeType) || RuntimeTypeHandle.HasInstantiation(runtimeType)) && (RuntimeMethodHandle.GetAttributes(runtimeMethodInfo) & MethodAttributes.Static) == MethodAttributes.PrivateScope)
253  {
254  if (_methodPtrAux == (IntPtr)0)
255  {
256  Type type = _target.GetType();
257  Type genericTypeDefinition = runtimeType.GetGenericTypeDefinition();
258  while (type != null)
259  {
260  if (type.IsGenericType && type.GetGenericTypeDefinition() == genericTypeDefinition)
261  {
262  runtimeType = (type as RuntimeType);
263  break;
264  }
265  type = type.BaseType;
266  }
267  }
268  else
269  {
270  MethodInfo method = GetType().GetMethod("Invoke");
271  runtimeType = (RuntimeType)method.GetParameters()[0].ParameterType;
272  }
273  }
274  _methodBase = (MethodInfo)RuntimeType.GetMethodBase(runtimeType, runtimeMethodInfo);
275  }
276  return (MethodInfo)_methodBase;
277  }
278 
285  [SecuritySafeCritical]
286  [__DynamicallyInvokable]
287  public static Delegate Remove(Delegate source, Delegate value)
288  {
289  if ((object)source == null)
290  {
291  return null;
292  }
293  if ((object)value == null)
294  {
295  return source;
296  }
297  if (!InternalEqualTypes(source, value))
298  {
299  throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTypeMis"));
300  }
301  return source.RemoveImpl(value);
302  }
303 
310  [__DynamicallyInvokable]
311  public static Delegate RemoveAll(Delegate source, Delegate value)
312  {
313  Delegate @delegate = null;
314  do
315  {
316  @delegate = source;
317  source = Remove(source, value);
318  }
319  while (@delegate != source);
320  return @delegate;
321  }
322 
327  protected virtual Delegate CombineImpl(Delegate d)
328  {
329  throw new MulticastNotSupportedException(Environment.GetResourceString("Multicast_Combine"));
330  }
331 
336  protected virtual Delegate RemoveImpl(Delegate d)
337  {
338  if (!d.Equals(this))
339  {
340  return this;
341  }
342  return null;
343  }
344 
347  public virtual object Clone()
348  {
349  return MemberwiseClone();
350  }
351 
368  public static Delegate CreateDelegate(Type type, object target, string method)
369  {
370  return CreateDelegate(type, target, method, ignoreCase: false, throwOnBindFailure: true);
371  }
372 
390  public static Delegate CreateDelegate(Type type, object target, string method, bool ignoreCase)
391  {
392  return CreateDelegate(type, target, method, ignoreCase, throwOnBindFailure: true);
393  }
394 
414  [SecuritySafeCritical]
415  public static Delegate CreateDelegate(Type type, object target, string method, bool ignoreCase, bool throwOnBindFailure)
416  {
417  if (type == null)
418  {
419  throw new ArgumentNullException("type");
420  }
421  if (target == null)
422  {
423  throw new ArgumentNullException("target");
424  }
425  if (method == null)
426  {
427  throw new ArgumentNullException("method");
428  }
429  RuntimeType runtimeType = type as RuntimeType;
430  if (runtimeType == null)
431  {
432  throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), "type");
433  }
434  if (!runtimeType.IsDelegate())
435  {
436  throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"), "type");
437  }
438  Delegate @delegate = InternalAlloc(runtimeType);
439  if (!@delegate.BindToMethodName(target, (RuntimeType)target.GetType(), method, (DelegateBindingFlags)(0x1A | (ignoreCase ? 32 : 0))))
440  {
441  if (throwOnBindFailure)
442  {
443  throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth"));
444  }
445  @delegate = null;
446  }
447  return @delegate;
448  }
449 
468  public static Delegate CreateDelegate(Type type, Type target, string method)
469  {
470  return CreateDelegate(type, target, method, ignoreCase: false, throwOnBindFailure: true);
471  }
472 
492  public static Delegate CreateDelegate(Type type, Type target, string method, bool ignoreCase)
493  {
494  return CreateDelegate(type, target, method, ignoreCase, throwOnBindFailure: true);
495  }
496 
518  [SecuritySafeCritical]
519  public static Delegate CreateDelegate(Type type, Type target, string method, bool ignoreCase, bool throwOnBindFailure)
520  {
521  if (type == null)
522  {
523  throw new ArgumentNullException("type");
524  }
525  if (target == null)
526  {
527  throw new ArgumentNullException("target");
528  }
529  if (target.IsGenericType && target.ContainsGenericParameters)
530  {
531  throw new ArgumentException(Environment.GetResourceString("Arg_UnboundGenParam"), "target");
532  }
533  if (method == null)
534  {
535  throw new ArgumentNullException("method");
536  }
537  RuntimeType runtimeType = type as RuntimeType;
538  RuntimeType runtimeType2 = target as RuntimeType;
539  if (runtimeType == null)
540  {
541  throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), "type");
542  }
543  if (runtimeType2 == null)
544  {
545  throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), "target");
546  }
547  if (!runtimeType.IsDelegate())
548  {
549  throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"), "type");
550  }
551  Delegate @delegate = InternalAlloc(runtimeType);
552  if (!@delegate.BindToMethodName(null, runtimeType2, method, (DelegateBindingFlags)(5 | (ignoreCase ? 32 : 0))))
553  {
554  if (throwOnBindFailure)
555  {
556  throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth"));
557  }
558  @delegate = null;
559  }
560  return @delegate;
561  }
562 
579  [MethodImpl(MethodImplOptions.NoInlining)]
580  [SecuritySafeCritical]
581  public static Delegate CreateDelegate(Type type, MethodInfo method, bool throwOnBindFailure)
582  {
583  if (type == null)
584  {
585  throw new ArgumentNullException("type");
586  }
587  if (method == null)
588  {
589  throw new ArgumentNullException("method");
590  }
591  RuntimeType runtimeType = type as RuntimeType;
592  if (runtimeType == null)
593  {
594  throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), "type");
595  }
596  RuntimeMethodInfo runtimeMethodInfo = method as RuntimeMethodInfo;
597  if (runtimeMethodInfo == null)
598  {
599  throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), "method");
600  }
601  if (!runtimeType.IsDelegate())
602  {
603  throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"), "type");
604  }
605  StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
606  Delegate @delegate = CreateDelegateInternal(runtimeType, runtimeMethodInfo, null, (DelegateBindingFlags)132, ref stackMark);
607  if ((object)@delegate == null && throwOnBindFailure)
608  {
609  throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth"));
610  }
611  return @delegate;
612  }
613 
629  [__DynamicallyInvokable]
630  public static Delegate CreateDelegate(Type type, object firstArgument, MethodInfo method)
631  {
632  return CreateDelegate(type, firstArgument, method, throwOnBindFailure: true);
633  }
634 
652  [MethodImpl(MethodImplOptions.NoInlining)]
653  [SecuritySafeCritical]
654  public static Delegate CreateDelegate(Type type, object firstArgument, MethodInfo method, bool throwOnBindFailure)
655  {
656  if (type == null)
657  {
658  throw new ArgumentNullException("type");
659  }
660  if (method == null)
661  {
662  throw new ArgumentNullException("method");
663  }
664  RuntimeType runtimeType = type as RuntimeType;
665  if (runtimeType == null)
666  {
667  throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), "type");
668  }
669  RuntimeMethodInfo runtimeMethodInfo = method as RuntimeMethodInfo;
670  if (runtimeMethodInfo == null)
671  {
672  throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), "method");
673  }
674  if (!runtimeType.IsDelegate())
675  {
676  throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"), "type");
677  }
678  StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
679  Delegate @delegate = CreateDelegateInternal(runtimeType, runtimeMethodInfo, firstArgument, DelegateBindingFlags.RelaxedSignature, ref stackMark);
680  if ((object)@delegate == null && throwOnBindFailure)
681  {
682  throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth"));
683  }
684  return @delegate;
685  }
686 
692  [__DynamicallyInvokable]
693  public static bool operator ==(Delegate d1, Delegate d2)
694  {
695  return d1?.Equals(d2) ?? ((object)d2 == null);
696  }
697 
703  [__DynamicallyInvokable]
704  public static bool operator !=(Delegate d1, Delegate d2)
705  {
706  if ((object)d1 == null)
707  {
708  return (object)d2 != null;
709  }
710  return !d1.Equals(d2);
711  }
712 
717  [SecurityCritical]
718  public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
719  {
720  throw new NotSupportedException();
721  }
722 
723  [SecurityCritical]
724  internal static Delegate CreateDelegateNoSecurityCheck(Type type, object target, RuntimeMethodHandle method)
725  {
726  if (type == null)
727  {
728  throw new ArgumentNullException("type");
729  }
730  if (method.IsNullHandle())
731  {
732  throw new ArgumentNullException("method");
733  }
734  RuntimeType runtimeType = type as RuntimeType;
735  if (runtimeType == null)
736  {
737  throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), "type");
738  }
739  if (!runtimeType.IsDelegate())
740  {
741  throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"), "type");
742  }
743  Delegate @delegate = InternalAlloc(runtimeType);
744  if (!@delegate.BindToMethodInfo(target, method.GetMethodInfo(), RuntimeMethodHandle.GetDeclaringType(method.GetMethodInfo()), (DelegateBindingFlags)192))
745  {
746  throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth"));
747  }
748  return @delegate;
749  }
750 
751  [SecurityCritical]
752  internal static Delegate CreateDelegateNoSecurityCheck(RuntimeType type, object firstArgument, MethodInfo method)
753  {
754  if (type == null)
755  {
756  throw new ArgumentNullException("type");
757  }
758  if (method == null)
759  {
760  throw new ArgumentNullException("method");
761  }
762  RuntimeMethodInfo runtimeMethodInfo = method as RuntimeMethodInfo;
763  if (runtimeMethodInfo == null)
764  {
765  throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), "method");
766  }
767  if (!type.IsDelegate())
768  {
769  throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"), "type");
770  }
771  Delegate @delegate = UnsafeCreateDelegate(type, runtimeMethodInfo, firstArgument, (DelegateBindingFlags)192);
772  if ((object)@delegate == null)
773  {
774  throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth"));
775  }
776  return @delegate;
777  }
778 
794  [__DynamicallyInvokable]
795  public static Delegate CreateDelegate(Type type, MethodInfo method)
796  {
797  return CreateDelegate(type, method, throwOnBindFailure: true);
798  }
799 
800  [SecuritySafeCritical]
801  internal static Delegate CreateDelegateInternal(RuntimeType rtType, RuntimeMethodInfo rtMethod, object firstArgument, DelegateBindingFlags flags, ref StackCrawlMark stackMark)
802  {
803  bool flag = (rtMethod.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != INVOCATION_FLAGS.INVOCATION_FLAGS_UNKNOWN;
804  bool flag2 = (rtType.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != INVOCATION_FLAGS.INVOCATION_FLAGS_UNKNOWN;
805  if (flag | flag2)
806  {
807  RuntimeAssembly executingAssembly = RuntimeAssembly.GetExecutingAssembly(ref stackMark);
808  if (executingAssembly != null && !executingAssembly.IsSafeForReflection())
809  {
810  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", flag ? rtMethod.FullName : rtType.FullName));
811  }
812  }
813  return UnsafeCreateDelegate(rtType, rtMethod, firstArgument, flags);
814  }
815 
816  [SecurityCritical]
817  internal static Delegate UnsafeCreateDelegate(RuntimeType rtType, RuntimeMethodInfo rtMethod, object firstArgument, DelegateBindingFlags flags)
818  {
819  Delegate @delegate = InternalAlloc(rtType);
820  if (@delegate.BindToMethodInfo(firstArgument, rtMethod, rtMethod.GetDeclaringTypeInternal(), flags))
821  {
822  return @delegate;
823  }
824  return null;
825  }
826 
827  [MethodImpl(MethodImplOptions.InternalCall)]
828  [SecurityCritical]
829  private extern bool BindToMethodName(object target, RuntimeType methodType, string method, DelegateBindingFlags flags);
830 
831  [MethodImpl(MethodImplOptions.InternalCall)]
832  [SecurityCritical]
833  private extern bool BindToMethodInfo(object target, IRuntimeMethodInfo method, RuntimeType methodType, DelegateBindingFlags flags);
834 
835  [MethodImpl(MethodImplOptions.InternalCall)]
836  [SecurityCritical]
837  private static extern MulticastDelegate InternalAlloc(RuntimeType type);
838 
839  [MethodImpl(MethodImplOptions.InternalCall)]
840  [SecurityCritical]
841  internal static extern MulticastDelegate InternalAllocLike(Delegate d);
842 
843  [MethodImpl(MethodImplOptions.InternalCall)]
844  [SecurityCritical]
845  internal static extern bool InternalEqualTypes(object a, object b);
846 
847  [MethodImpl(MethodImplOptions.InternalCall)]
848  [SecurityCritical]
849  private extern void DelegateConstruct(object target, IntPtr slot);
850 
851  [MethodImpl(MethodImplOptions.InternalCall)]
852  [SecurityCritical]
853  internal extern IntPtr GetMulticastInvoke();
854 
855  [MethodImpl(MethodImplOptions.InternalCall)]
856  [SecurityCritical]
857  internal extern IntPtr GetInvokeMethod();
858 
859  [MethodImpl(MethodImplOptions.InternalCall)]
860  internal extern IRuntimeMethodInfo FindMethodHandle();
861 
862  [MethodImpl(MethodImplOptions.InternalCall)]
863  [SecurityCritical]
864  internal static extern bool InternalEqualMethodHandles(Delegate left, Delegate right);
865 
866  [MethodImpl(MethodImplOptions.InternalCall)]
867  [SecurityCritical]
868  internal extern IntPtr AdjustTarget(object target, IntPtr methodPtr);
869 
870  [MethodImpl(MethodImplOptions.InternalCall)]
871  [SecurityCritical]
872  internal extern IntPtr GetCallStub(IntPtr methodPtr);
873 
874  [SecuritySafeCritical]
875  internal virtual object GetTarget()
876  {
877  if (!_methodPtrAux.IsNull())
878  {
879  return null;
880  }
881  return _target;
882  }
883 
884  [MethodImpl(MethodImplOptions.InternalCall)]
885  [SecurityCritical]
886  internal static extern bool CompareUnmanagedFunctionPtrs(Delegate d1, Delegate d2);
887  }
888 }
abstract Type BaseType
Gets the type from which the current T:System.Type directly inherits.
Definition: Type.cs:180
virtual Type GetGenericTypeDefinition()
Returns a T:System.Type object that represents a generic type definition from which the current gener...
Definition: Type.cs:2443
MethodAttributes
Specifies flags for method attributes. These flags are defined in the corhdr.h file.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
static Delegate CreateDelegate(Type type, Type target, string method, bool ignoreCase)
Creates a delegate of the specified type that represents the specified static method of the specified...
Definition: Delegate.cs:492
virtual object Clone()
Creates a shallow copy of the delegate.
Definition: Delegate.cs:347
virtual Delegate CombineImpl(Delegate d)
Concatenates the invocation lists of the specified multicast (combinable) delegate and the current mu...
Definition: Delegate.cs:327
Discovers the attributes of a method and provides access to method metadata.
Definition: MethodInfo.cs:13
static Delegate CreateDelegate(Type type, Type target, string method)
Creates a delegate of the specified type that represents the specified static method of the specified...
Definition: Delegate.cs:468
BindingFlags
Specifies flags that control binding and the way in which the search for members and types is conduct...
Definition: BindingFlags.cs:10
Definition: __Canon.cs:3
object Target
Gets the class instance on which the current delegate invokes the instance method.
Definition: Delegate.cs:46
static Delegate CreateDelegate(Type type, object target, string method, bool ignoreCase)
Creates a delegate of the specified type that represents the specified instance method to invoke on t...
Definition: Delegate.cs:390
Represents a type using an internal metadata token.
virtual bool IsGenericType
Gets a value indicating whether the current type is a generic type.
Definition: Type.cs:566
virtual bool ContainsGenericParameters
Gets a value indicating whether the current T:System.Type object has type parameters that have not be...
Definition: Type.cs:631
virtual MethodInfo GetMethodImpl()
Gets the static method represented by the current delegate.
Definition: Delegate.cs:246
virtual Delegate [] GetInvocationList()
Returns the invocation list of the delegate.
Definition: Delegate.cs:234
static Delegate CreateDelegate(Type type, object firstArgument, MethodInfo method, bool throwOnBindFailure)
Creates a delegate of the specified type that represents the specified static or instance method,...
Definition: Delegate.cs:654
Describes the source and destination of a given serialized stream, and provides an additional caller-...
static Delegate Remove(Delegate source, Delegate value)
Removes the last occurrence of the invocation list of a delegate from the invocation list of another ...
Definition: Delegate.cs:287
static Delegate Combine(Delegate a, Delegate b)
Concatenates the invocation lists of two delegates.
Definition: Delegate.cs:202
static Delegate CreateDelegate(Type type, Type target, string method, bool ignoreCase, bool throwOnBindFailure)
Creates a delegate of the specified type that represents the specified static method of the specified...
Definition: Delegate.cs:519
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
static Delegate CreateDelegate(Type type, object firstArgument, MethodInfo method)
Creates a delegate of the specified type that represents the specified static or instance method,...
Definition: Delegate.cs:630
T:System.RuntimeMethodHandle is a handle to the internal metadata representation of a method.
virtual void GetObjectData(SerializationInfo info, StreamingContext context)
Not supported.
Definition: Delegate.cs:718
static bool operator !=(Delegate d1, Delegate d2)
Determines whether the specified delegates are not equal.
Definition: Delegate.cs:704
virtual Delegate RemoveImpl(Delegate d)
Removes the invocation list of a delegate from the invocation list of another delegate.
Definition: Delegate.cs:336
object DynamicInvoke(params object[] args)
Dynamically invokes (late-bound) the method represented by the current delegate.
Definition: Delegate.cs:122
override int GetHashCode()
Returns a hash code for the delegate.
Definition: Delegate.cs:191
A platform-specific type that is used to represent a pointer or a handle.
Definition: IntPtr.cs:14
Supports cloning, which creates a new instance of a class with the same value as an existing instance...
Definition: ICloneable.cs:7
Represents a delegate, which is a data structure that refers to a static method or to a class instanc...
Definition: Delegate.cs:15
virtual object DynamicInvokeImpl(object[] args)
Dynamically invokes (late-bound) the method represented by the current delegate.
Definition: Delegate.cs:135
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
static Delegate RemoveAll(Delegate source, Delegate value)
Removes all occurrences of the invocation list of a delegate from the invocation list of another dele...
Definition: Delegate.cs:311
static Delegate CreateDelegate(Type type, MethodInfo method, bool throwOnBindFailure)
Creates a delegate of the specified type to represent the specified static method,...
Definition: Delegate.cs:581
MethodImplOptions
Defines the details of how a method is implemented.
Stores all the data needed to serialize or deserialize an object. This class cannot be inherited.
static Delegate CreateDelegate(Type type, MethodInfo method)
Creates a delegate of the specified type to represent the specified static method.
Definition: Delegate.cs:795
static bool operator==(Delegate d1, Delegate d2)
Determines whether the specified delegates are equal.
Definition: Delegate.cs:693
MethodInfo Method
Gets the method represented by the delegate.
Definition: Delegate.cs:34
The exception that is thrown when one of the arguments provided to a method is not valid.
static Delegate CreateDelegate(Type type, object target, string method, bool ignoreCase, bool throwOnBindFailure)
Creates a delegate of the specified type that represents the specified instance method to invoke on t...
Definition: Delegate.cs:415
Allows an object to control its own serialization and deserialization.
Definition: ISerializable.cs:8
override bool Equals(object obj)
Determines whether the specified object and the current delegate are of the same type and share the s...
Definition: Delegate.cs:148
Specifies that the class can be serialized.
virtual Type ParameterType
Gets the Type of this parameter.
The exception that is thrown when a method call is invalid for the object's current state.
static Delegate Combine(params Delegate[] delegates)
Concatenates the invocation lists of an array of delegates.
Definition: Delegate.cs:217
static Type GetType(string typeName, bool throwOnError, bool ignoreCase)
Gets the T:System.Type with the specified name, specifying whether to throw an exception if the type ...
Definition: Type.cs:853
ClassInterfaceType
Identifies the type of class interface that is generated for a class.
Delegate(Type target, string method)
Initializes a delegate that invokes the specified static method from the specified class.
Definition: Delegate.cs:88
The exception that is thrown when there is an attempt to combine two delegates based on the T:System....
The exception that is thrown when an invoked method is not supported, or when there is an attempt to ...
Delegate(object target, string method)
Initializes a delegate that invokes the specified instance method on the specified class instance.
Definition: Delegate.cs:62
static Delegate CreateDelegate(Type type, object target, string method)
Creates a delegate of the specified type that represents the specified instance method to invoke on t...
Definition: Delegate.cs:368
abstract ParameterInfo [] GetParameters()
When overridden in a derived class, gets the parameters of the specified method or constructor.