本文整理汇总了C#中System.Reflection.Emit.SignatureHelper类的典型用法代码示例。如果您正苦于以下问题:C# SignatureHelper类的具体用法?C# SignatureHelper怎么用?C# SignatureHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SignatureHelper类属于System.Reflection.Emit命名空间,在下文中一共展示了SignatureHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SymbolMethod
//***********************************************
//
// Constructor
//
//***********************************************
internal SymbolMethod(
ModuleBuilder mod,
MethodToken token,
Type arrayClass,
String methodName,
CallingConventions callingConvention,
Type returnType,
Type[] parameterTypes)
{
m_module = mod;
m_containingType = arrayClass;
m_name = methodName;
m_callingConvention = callingConvention;
m_returnType = returnType;
m_mdMethod = token;
if (parameterTypes != null)
{
m_parameterTypes = new Type[parameterTypes.Length];
Array.Copy(parameterTypes, m_parameterTypes, parameterTypes.Length);
}
else
m_parameterTypes = null;
m_signature = SignatureHelper.GetMethodSigHelper(mod, callingConvention, returnType, parameterTypes);
}
示例2: SymbolMethod
internal SymbolMethod(ModuleBuilder mod, MethodToken token, Type arrayClass, String methodName,
CallingConventions callingConvention, Type returnType, Type[] parameterTypes)
{
// This is a kind of MethodInfo to represent methods for array type of unbaked type
// Another way to look at this class is as a glorified MethodToken wrapper. At the time of this comment
// this class is only constructed inside ModuleBuilder.GetArrayMethod and the only interesting thing
// passed into it is this MethodToken. The MethodToken was forged using a TypeSpec for an Array type and
// the name of the method on Array.
// As none of the methods on Array have CustomModifiers their is no need to pass those around in here.
m_mdMethod = token;
// The ParameterTypes are also a bit interesting in that they may be unbaked TypeBuilders.
m_returnType = returnType;
if (parameterTypes != null)
{
m_parameterTypes = new Type[parameterTypes.Length];
Array.Copy(parameterTypes, 0, m_parameterTypes, 0, parameterTypes.Length);
}
else
{
m_parameterTypes = EmptyArray<Type>.Value;
}
m_module = mod;
m_containingType = arrayClass;
m_name = methodName;
m_callingConvention = callingConvention;
m_signature = SignatureHelper.GetMethodSigHelper(
mod, callingConvention, returnType, null, null, parameterTypes, null, null);
}
示例3: PropertyBuilder
// Constructs a PropertyBuilder.
//
internal PropertyBuilder(
ModuleBuilder mod, // the module containing this PropertyBuilder
String name, // property name
SignatureHelper sig, // property signature descriptor info
PropertyAttributes attr, // property attribute such as DefaultProperty, Bindable, DisplayBind, etc
Type returnType, // return type of the property.
PropertyToken prToken, // the metadata token for this property
TypeBuilder containingType) // the containing type
{
if (name == null)
throw new ArgumentNullException("name");
if (name.Length == 0)
throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
if (name[0] == '\0')
throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), "name");
Contract.EndContractBlock();
m_name = name;
m_moduleBuilder = mod;
m_signature = sig;
m_attributes = attr;
m_returnType = returnType;
m_prToken = prToken;
m_tkProperty = prToken.Token;
m_containingType = containingType;
}
示例4: GetMethodSpecSigHelper
internal static SignatureHelper GetMethodSpecSigHelper(Module scope, Type[] inst)
{
SignatureHelper sigHelp = new SignatureHelper(scope, MdSigCallingConvention.GenericInst);
sigHelp.AddData(inst.Length);
foreach(Type t in inst)
sigHelp.AddArgument(t);
return sigHelp;
}
示例5: PropertyBuilder
internal PropertyBuilder(ModuleBuilder mod, string name, SignatureHelper sig, PropertyAttributes attr, Type returnType, System.Reflection.Emit.PropertyToken prToken, TypeBuilder containingType)
{
if (name == null)
{
throw new ArgumentNullException("name");
}
if (name.Length == 0)
{
throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
}
if (name[0] == '\0')
{
throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), "name");
}
this.m_name = name;
this.m_moduleBuilder = mod;
this.m_signature = sig;
this.m_attributes = attr;
this.m_returnType = returnType;
this.m_prToken = prToken;
this.m_tkProperty = prToken.Token;
this.m_containingType = containingType;
}
示例6: ILGenerator
internal ILGenerator(MethodInfo methodBuilder, int size)
{
if (size < 0x10)
{
this.m_ILStream = new byte[0x10];
}
else
{
this.m_ILStream = new byte[size];
}
this.m_length = 0;
this.m_labelCount = 0;
this.m_fixupCount = 0;
this.m_labelList = null;
this.m_fixupData = null;
this.m_exceptions = null;
this.m_exceptionCount = 0;
this.m_currExcStack = null;
this.m_currExcStackCount = 0;
this.m_RelocFixupList = new int[0x40];
this.m_RelocFixupCount = 0;
this.m_RVAFixupList = new int[0x40];
this.m_RVAFixupCount = 0;
this.m_ScopeTree = new ScopeTree();
this.m_LineNumberInfo = new LineNumberInfo();
this.m_methodBuilder = methodBuilder;
this.m_localCount = 0;
MethodBuilder builder = this.m_methodBuilder as MethodBuilder;
if (builder == null)
{
this.m_localSignature = SignatureHelper.GetLocalVarSigHelper(null);
}
else
{
this.m_localSignature = SignatureHelper.GetLocalVarSigHelper(builder.GetTypeBuilder().Module);
}
}
示例7: GetSignatureToken
public SignatureToken GetSignatureToken (SignatureHelper sigHelper)
{
if (sigHelper == null)
throw new ArgumentNullException ("sigHelper");
return new SignatureToken (GetToken (sigHelper));
}
示例8: GetPropertySigHelper
/// <include file='doc\SignatureHelper.uex' path='docs/doc[@for="SignatureHelper.GetPropertySigHelper"]/*' />
public static SignatureHelper GetPropertySigHelper(Module mod, Type returnType, Type[] parameterTypes)
{
SignatureHelper sigHelp;
if (returnType == null)
{
returnType = typeof(void);
}
sigHelp = new SignatureHelper(mod, IMAGE_CEE_CS_CALLCONV_PROPERTY, (Type)returnType);
if (parameterTypes != null)
{
for (int i=0; i<parameterTypes.Length; i++)
{
sigHelp.AddArgument(parameterTypes[i]);
}
}
return sigHelp;
}
示例9: GetMethodSigHelper
/// <include file='doc\SignatureHelper.uex' path='docs/doc[@for="SignatureHelper.GetMethodSigHelper2"]/*' />
public static SignatureHelper GetMethodSigHelper(
Module mod,
CallingConvention unmanagedCallConv,
Type returnType)
{
SignatureHelper sigHelp;
int intCall;
if (returnType == null)
{
returnType = typeof(void);
}
if (unmanagedCallConv == CallingConvention.Cdecl)
intCall = IMAGE_CEE_UNMANAGED_CALLCONV_C;
else if (unmanagedCallConv == CallingConvention.StdCall)
intCall = IMAGE_CEE_UNMANAGED_CALLCONV_STDCALL;
else if (unmanagedCallConv == CallingConvention.ThisCall)
intCall = IMAGE_CEE_UNMANAGED_CALLCONV_THISCALL;
else if (unmanagedCallConv == CallingConvention.FastCall)
intCall = IMAGE_CEE_UNMANAGED_CALLCONV_FASTCALL;
else
throw new ArgumentException(Environment.GetResourceString("Argument_UnknownUnmanagedCallConv"), "unmanagedCallConv");
sigHelp = new SignatureHelper(mod, intCall, (Type)returnType);
return sigHelp;
}
示例10: GetToken
public int GetToken (SignatureHelper helper) {
return m.AddRef (helper);
}
示例11: VarArgMethod
internal VarArgMethod(RuntimeMethodInfo method, SignatureHelper signature)
{
m_method = method;
m_signature = signature;
}
示例12: Emit
public virtual void Emit (OpCode opcode, SignatureHelper signature)
{
int token = token_gen.GetToken (signature);
make_room (6);
ll_emit (opcode);
emit_int (token);
}
示例13: Init
private void Init(String name, MethodAttributes attributes, CallingConventions callingConvention,
Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers,
Module mod, TypeBuilder type, bool bIsGlobalMethod)
{
if (name == null)
throw new ArgumentNullException("name");
if (name.Length == 0)
throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
if (name[0] == '\0')
throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), "name");
if (mod == null)
throw new ArgumentNullException("mod");
if (parameterTypes != null)
{
foreach(Type t in parameterTypes)
{
if (t == null)
throw new ArgumentNullException("parameterTypes");
}
}
m_link = type.m_currentMethod;
type.m_currentMethod = this;
m_strName = name;
m_module = mod;
m_containingType = type;
m_localSignature = SignatureHelper.GetLocalVarSigHelper(mod);
//
//if (returnType == null)
//{
// m_returnType = typeof(void);
//}
//else
{
m_returnType = returnType;
}
if ((attributes & MethodAttributes.Static) == 0)
{
// turn on the has this calling convention
callingConvention = callingConvention | CallingConventions.HasThis;
}
else if ((attributes & MethodAttributes.Virtual) != 0)
{
// A method can't be both static and virtual
throw new ArgumentException(Environment.GetResourceString("Arg_NoStaticVirtual"));
}
if ((attributes & MethodAttributes.SpecialName) != MethodAttributes.SpecialName)
{
if ((type.Attributes & TypeAttributes.Interface) == TypeAttributes.Interface)
{
// methods on interface have to be abstract + virtual except special name methods such as type initializer
if ((attributes & (MethodAttributes.Abstract | MethodAttributes.Virtual)) !=
(MethodAttributes.Abstract | MethodAttributes.Virtual) &&
(attributes & MethodAttributes.Static) == 0)
throw new ArgumentException(Environment.GetResourceString("Argument_BadAttributeOnInterfaceMethod"));
}
}
m_callingConvention = callingConvention;
if (parameterTypes != null)
{
m_parameterTypes = new Type[parameterTypes.Length];
Array.Copy(parameterTypes, m_parameterTypes, parameterTypes.Length);
}
else
{
m_parameterTypes = null;
}
m_returnTypeRequiredCustomModifiers = returnTypeRequiredCustomModifiers;
m_returnTypeOptionalCustomModifiers = returnTypeOptionalCustomModifiers;
m_parameterTypeRequiredCustomModifiers = parameterTypeRequiredCustomModifiers;
m_parameterTypeOptionalCustomModifiers = parameterTypeOptionalCustomModifiers;
// m_signature = SignatureHelper.GetMethodSigHelper(mod, callingConvention,
// returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
// parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers);
m_iAttributes = attributes;
m_bIsGlobalMethod = bIsGlobalMethod;
m_bIsBaked = false;
m_fInitLocals = true;
m_localSymInfo = new LocalSymInfo();
m_ubBody = null;
m_ilGenerator = null;
// Default is managed IL. Manged IL has bit flag 0x0020 set off
m_dwMethodImplFlags = MethodImplAttributes.IL;
//int i = MetadataTokenInternal;
//.........这里部分代码省略.........
示例14: GetMethodSignature
internal SignatureHelper GetMethodSignature()
{
if (m_parameterTypes == null)
m_parameterTypes = new Type[0];
m_signature = SignatureHelper.GetMethodSigHelper (m_module, m_callingConvention, m_inst != null ? m_inst.Length : 0,
m_returnType == null ? typeof(void) : m_returnType, m_returnTypeRequiredCustomModifiers, m_returnTypeOptionalCustomModifiers,
m_parameterTypes, m_parameterTypeRequiredCustomModifiers, m_parameterTypeOptionalCustomModifiers);
return m_signature;
}
示例15: GetMethodSigHelper
public static SignatureHelper GetMethodSigHelper(Module mod, CallingConvention unmanagedCallConv, Type returnType)
{
SignatureHelper sigHelp;
MdSigCallingConvention intCall;
if (returnType == null)
returnType = typeof(void);
if (unmanagedCallConv == CallingConvention.Cdecl)
{
intCall = MdSigCallingConvention.C;
}
else if (unmanagedCallConv == CallingConvention.StdCall || unmanagedCallConv == CallingConvention.Winapi)
{
intCall = MdSigCallingConvention.StdCall;
}
else if (unmanagedCallConv == CallingConvention.ThisCall)
{
intCall = MdSigCallingConvention.ThisCall;
}
else if (unmanagedCallConv == CallingConvention.FastCall)
{
intCall = MdSigCallingConvention.FastCall;
}
else
{
throw new ArgumentException(Environment.GetResourceString("Argument_UnknownUnmanagedCallConv"), nameof(unmanagedCallConv));
}
sigHelp = new SignatureHelper(mod, intCall, returnType, null, null);
return sigHelp;
}