mscorlib(4.0.0.0) API with additions
ExceptionHandlingClause.cs
3 
4 namespace System.Reflection
5 {
7  [ComVisible(true)]
9  {
10  private MethodBody m_methodBody;
11 
12  private ExceptionHandlingClauseOptions m_flags;
13 
14  private int m_tryOffset;
15 
16  private int m_tryLength;
17 
18  private int m_handlerOffset;
19 
20  private int m_handlerLength;
21 
22  private int m_catchMetadataToken;
23 
24  private int m_filterOffset;
25 
28  public virtual ExceptionHandlingClauseOptions Flags => m_flags;
29 
32  public virtual int TryOffset => m_tryOffset;
33 
36  public virtual int TryLength => m_tryLength;
37 
40  public virtual int HandlerOffset => m_handlerOffset;
41 
44  public virtual int HandlerLength => m_handlerLength;
45 
49  public virtual int FilterOffset
50  {
51  get
52  {
53  if (m_flags != ExceptionHandlingClauseOptions.Filter)
54  {
55  throw new InvalidOperationException(Environment.GetResourceString("Arg_EHClauseNotFilter"));
56  }
57  return m_filterOffset;
58  }
59  }
60 
64  public virtual Type CatchType
65  {
66  get
67  {
68  if (m_flags != 0)
69  {
70  throw new InvalidOperationException(Environment.GetResourceString("Arg_EHClauseNotClause"));
71  }
72  Type result = null;
73  if (!MetadataToken.IsNullToken(m_catchMetadataToken))
74  {
75  Type declaringType = m_methodBody.m_methodBase.DeclaringType;
76  Module module = (declaringType == null) ? m_methodBody.m_methodBase.Module : declaringType.Module;
77  result = module.ResolveType(m_catchMetadataToken, (declaringType == null) ? null : declaringType.GetGenericArguments(), (m_methodBody.m_methodBase is MethodInfo) ? m_methodBody.m_methodBase.GetGenericArguments() : null);
78  }
79  return result;
80  }
81  }
82 
85  {
86  }
87 
90  public override string ToString()
91  {
93  {
94  return string.Format(CultureInfo.CurrentUICulture, "Flags={0}, TryOffset={1}, TryLength={2}, HandlerOffset={3}, HandlerLength={4}, CatchType={5}", Flags, TryOffset, TryLength, HandlerOffset, HandlerLength, CatchType);
95  }
97  {
98  return string.Format(CultureInfo.CurrentUICulture, "Flags={0}, TryOffset={1}, TryLength={2}, HandlerOffset={3}, HandlerLength={4}, FilterOffset={5}", Flags, TryOffset, TryLength, HandlerOffset, HandlerLength, FilterOffset);
99  }
100  return string.Format(CultureInfo.CurrentUICulture, "Flags={0}, TryOffset={1}, TryLength={2}, HandlerOffset={3}, HandlerLength={4}", Flags, TryOffset, TryLength, HandlerOffset, HandlerLength);
101  }
102  }
103 }
Performs reflection on a module.
Definition: Module.cs:17
virtual Type??? CatchType
Gets the type of exception handled by this clause.
abstract Type DeclaringType
Gets the class that declares this member.
Definition: MemberInfo.cs:36
Discovers the attributes of a method and provides access to method metadata.
Definition: MethodInfo.cs:13
virtual int FilterOffset
Gets the offset within the method body, in bytes, of the user-supplied filter code.
Definition: __Canon.cs:3
virtual int HandlerOffset
Gets the offset within the method body, in bytes, of this exception-handling clause.
virtual int HandlerLength
Gets the length, in bytes, of the body of this exception-handling clause.
static CultureInfo CurrentUICulture
Gets or sets the T:System.Globalization.CultureInfo object that represents the current user interface...
Definition: CultureInfo.cs:174
Provides access to the metadata and MSIL for the body of a method.
Definition: MethodBody.cs:8
virtual Type [] GetGenericArguments()
Returns an array of T:System.Type objects that represent the type arguments of a closed generic type ...
Definition: Type.cs:2433
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
override string ToString()
A string representation of the exception-handling clause.
virtual int TryOffset
The offset within the method, in bytes, of the try block that includes this exception-handling clause...
Type ResolveType(int metadataToken)
Returns the type identified by the specified metadata token.
Definition: Module.cs:331
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
virtual int TryLength
The total length, in bytes, of the try block that includes this exception-handling clause.
virtual Module Module
Gets the module in which the type that declares the member represented by the current T:System....
Definition: MemberInfo.cs:78
The exception that is thrown when a method call is invalid for the object's current state.
Represents a clause in a structured exception-handling block.
ExceptionHandlingClauseOptions
Identifies kinds of exception-handling clauses.
virtual Type [] GetGenericArguments()
Returns an array of T:System.Type objects that represent the type arguments of a generic method or th...
Definition: MethodBase.cs:599
abstract new Module Module
Gets the module (the DLL) in which the current T:System.Type is defined.
Definition: Type.cs:123
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition: CultureInfo.cs:16
virtual ExceptionHandlingClauseOptions Flags
Gets a value indicating whether this exception-handling clause is a finally clause,...
ExceptionHandlingClause()
Initializes a new instance of the T:System.Reflection.ExceptionHandlingClause class.