3 // Copyright (c) Microsoft Corporation. All rights reserved.
6 // <OWNER>Microsoft</OWNER>
9 namespace System
.Reflection
.Emit
12 using System
.Reflection
;
13 using System
.Collections
;
14 using System
.Globalization
;
15 using System
.Diagnostics
.Contracts
;
17 internal sealed class MethodBuilderInstantiation
: MethodInfo
19 #region Static Members
20 internal static MethodInfo
MakeGenericMethod(MethodInfo method
, Type
[] inst
)
22 if (!method
.IsGenericMethodDefinition
)
23 throw new InvalidOperationException();
24 Contract
.EndContractBlock();
26 return new MethodBuilderInstantiation(method
, inst
);
31 #region Private Data Mebers
32 internal MethodInfo m_method
;
33 private Type
[] m_inst
;
37 internal MethodBuilderInstantiation(MethodInfo method
, Type
[] inst
)
44 internal override Type
[] GetParameterTypes()
46 return m_method
.GetParameterTypes();
50 public override MemberTypes MemberType { get { return m_method.MemberType; }
}
51 public override String Name { get { return m_method.Name; }
}
52 public override Type DeclaringType { get { return m_method.DeclaringType; }
}
53 public override Type ReflectedType { get { return m_method.ReflectedType; }
}
54 public override Object
[] GetCustomAttributes(bool inherit
) { return m_method.GetCustomAttributes(inherit); }
55 public override Object
[] GetCustomAttributes(Type attributeType
, bool inherit
) { return m_method.GetCustomAttributes(attributeType, inherit); }
56 public override bool IsDefined(Type attributeType
, bool inherit
) { return m_method.IsDefined(attributeType, inherit); }
57 public override Module Module { get { return m_method.Module; }
}
58 public new Type
GetType() { return base.GetType(); }
61 #region MethodBase Members
63 public override ParameterInfo
[] GetParameters() { throw new NotSupportedException(); }
64 public override MethodImplAttributes
GetMethodImplementationFlags() { return m_method.GetMethodImplementationFlags(); }
65 public override RuntimeMethodHandle MethodHandle { get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); }
}
66 public override MethodAttributes Attributes { get { return m_method.Attributes; }
}
67 public override Object
Invoke(Object obj
, BindingFlags invokeAttr
, Binder binder
, Object
[] parameters
, CultureInfo culture
)
69 throw new NotSupportedException();
71 public override CallingConventions CallingConvention { get { return m_method.CallingConvention; }
}
72 public override Type
[] GetGenericArguments() { return m_inst; }
73 public override MethodInfo
GetGenericMethodDefinition() { return m_method; }
74 public override bool IsGenericMethodDefinition { get { return false; }
}
75 public override bool ContainsGenericParameters
79 for (int i
= 0; i
< m_inst
.Length
; i
++)
81 if (m_inst
[i
].ContainsGenericParameters
)
85 if (DeclaringType
!= null && DeclaringType
.ContainsGenericParameters
)
92 public override MethodInfo
MakeGenericMethod(params Type
[] arguments
)
94 throw new InvalidOperationException(Environment
.GetResourceString("Arg_NotGenericMethodDefinition"));
97 public override bool IsGenericMethod { get { return true; }
}
101 #region Public Abstract\Virtual Members
102 public override Type ReturnType
106 return m_method
.ReturnType
;
110 public override ParameterInfo ReturnParameter { get { throw new NotSupportedException(); }
}
111 public override ICustomAttributeProvider ReturnTypeCustomAttributes { get { throw new NotSupportedException(); }
}
112 public override MethodInfo
GetBaseDefinition() { throw new NotSupportedException(); }