本文整理汇总了C#中IKVM.Reflection.Module类的典型用法代码示例。如果您正苦于以下问题:C# Module类的具体用法?C# Module怎么用?C# Module使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Module类属于IKVM.Reflection命名空间,在下文中一共展示了Module类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPropertySigHelper
public static SignatureHelper GetPropertySigHelper(Module mod, Type returnType, Type[] parameterTypes)
{
SignatureHelper sig = new SignatureHelper(mod as ModuleBuilder, Signature.PROPERTY);
sig.returnType = returnType;
foreach (Type type in parameterTypes)
{
sig.AddArgument(type);
}
return sig;
}
示例2: GetPropertySigHelper
public static SignatureHelper GetPropertySigHelper(Module mod, Type returnType, Type[] parameterTypes)
{
SignatureHelper sig = new SignatureHelper(mod as ModuleBuilder, Signature.PROPERTY);
sig.returnType = returnType;
sig.returnTypeOptionalCustomModifiers = Type.EmptyTypes;
sig.returnTypeRequiredCustomModifiers = Type.EmptyTypes;
foreach (Type type in parameterTypes)
{
sig.AddArgument(type);
}
return sig;
}
示例3: ReadFieldMarshal
internal static bool ReadFieldMarshal(Module module, int token, out FieldMarshal fm)
{
fm = new FieldMarshal();
foreach (int i in module.FieldMarshal.Filter(token))
{
ByteReader blob = module.GetBlob(module.FieldMarshal.records[i].NativeType);
fm.UnmanagedType = (UnmanagedType)blob.ReadCompressedUInt();
if (fm.UnmanagedType == UnmanagedType.LPArray)
{
fm.ArraySubType = (UnmanagedType)blob.ReadCompressedUInt();
if (fm.ArraySubType == NATIVE_TYPE_MAX)
{
fm.ArraySubType = null;
}
if (blob.Length != 0)
{
fm.SizeParamIndex = (short)blob.ReadCompressedUInt();
if (blob.Length != 0)
{
fm.SizeConst = blob.ReadCompressedUInt();
if (blob.Length != 0 && blob.ReadCompressedUInt() == 0)
{
fm.SizeParamIndex = null;
}
}
}
}
else if (fm.UnmanagedType == UnmanagedType.SafeArray)
{
if (blob.Length != 0)
{
fm.SafeArraySubType = (VarEnum)blob.ReadCompressedUInt();
if (blob.Length != 0)
{
fm.SafeArrayUserDefinedSubType = ReadType(module, blob);
}
}
}
else if (fm.UnmanagedType == UnmanagedType.ByValArray)
{
fm.SizeConst = blob.ReadCompressedUInt();
if (blob.Length != 0)
{
fm.ArraySubType = (UnmanagedType)blob.ReadCompressedUInt();
}
}
else if (fm.UnmanagedType == UnmanagedType.ByValTStr)
{
fm.SizeConst = blob.ReadCompressedUInt();
}
else if (fm.UnmanagedType == UnmanagedType.Interface
|| fm.UnmanagedType == UnmanagedType.IDispatch
|| fm.UnmanagedType == UnmanagedType.IUnknown)
{
if (blob.Length != 0)
{
fm.IidParameterIndex = blob.ReadCompressedUInt();
}
}
else if (fm.UnmanagedType == UnmanagedType.CustomMarshaler)
{
blob.ReadCompressedUInt();
blob.ReadCompressedUInt();
fm.MarshalType = ReadString(blob);
fm.MarshalCookie = ReadString(blob);
TypeNameParser parser = TypeNameParser.Parse(fm.MarshalType, false);
if (!parser.Error)
{
fm.MarshalTypeRef = parser.GetType(module.universe, module, false, fm.MarshalType, false, false);
}
}
return true;
}
return false;
}
示例4: ReadType
private static Type ReadType(Module module, ByteReader br)
{
string str = ReadString(br);
if (str == "")
{
return null;
}
return module.Assembly.GetType(str) ?? module.universe.GetType(str, true);
}
示例5: MissingType
internal MissingType(Module module, Type declaringType, string ns, string name)
{
this.module = module;
this.declaringType = declaringType;
this.ns = ns;
this.name = name;
}
示例6: CustomAttributeData
// 1) Unresolved Custom Attribute
internal CustomAttributeData(Module module, int index)
{
this.module = module;
this.customAttributeIndex = index;
this.declSecurityIndex = -1;
}
示例7: CreateDllImportPseudoCustomAttribute
internal static CustomAttributeData CreateDllImportPseudoCustomAttribute(Module module, ImplMapFlags flags, string entryPoint, string dllName, MethodImplAttributes attr)
{
Type type = module.universe.System_Runtime_InteropServices_DllImportAttribute;
ConstructorInfo constructor = type.GetPseudoCustomAttributeConstructor(module.universe.System_String);
List<CustomAttributeNamedArgument> list = new List<CustomAttributeNamedArgument>();
System.Runtime.InteropServices.CharSet charSet;
switch (flags & ImplMapFlags.CharSetMask)
{
case ImplMapFlags.CharSetAnsi:
charSet = System.Runtime.InteropServices.CharSet.Ansi;
break;
case ImplMapFlags.CharSetUnicode:
charSet = System.Runtime.InteropServices.CharSet.Unicode;
break;
case ImplMapFlags.CharSetAuto:
charSet = System.Runtime.InteropServices.CharSet.Auto;
break;
case ImplMapFlags.CharSetNotSpec:
default:
charSet = System.Runtime.InteropServices.CharSet.None;
break;
}
System.Runtime.InteropServices.CallingConvention callingConvention;
switch (flags & ImplMapFlags.CallConvMask)
{
case ImplMapFlags.CallConvCdecl:
callingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl;
break;
case ImplMapFlags.CallConvFastcall:
callingConvention = System.Runtime.InteropServices.CallingConvention.FastCall;
break;
case ImplMapFlags.CallConvStdcall:
callingConvention = System.Runtime.InteropServices.CallingConvention.StdCall;
break;
case ImplMapFlags.CallConvThiscall:
callingConvention = System.Runtime.InteropServices.CallingConvention.ThisCall;
break;
case ImplMapFlags.CallConvWinapi:
callingConvention = System.Runtime.InteropServices.CallingConvention.Winapi;
break;
default:
callingConvention = 0;
break;
}
AddNamedArgument(list, type, "EntryPoint", entryPoint);
AddNamedArgument(list, type, "CharSet", module.universe.System_Runtime_InteropServices_CharSet, (int)charSet);
AddNamedArgument(list, type, "ExactSpelling", (int)flags, (int)ImplMapFlags.NoMangle);
AddNamedArgument(list, type, "SetLastError", (int)flags, (int)ImplMapFlags.SupportsLastError);
AddNamedArgument(list, type, "PreserveSig", (int)attr, (int)MethodImplAttributes.PreserveSig);
AddNamedArgument(list, type, "CallingConvention", module.universe.System_Runtime_InteropServices_CallingConvention, (int)callingConvention);
AddNamedArgument(list, type, "BestFitMapping", (int)flags, (int)ImplMapFlags.BestFitOn);
AddNamedArgument(list, type, "ThrowOnUnmappableChar", (int)flags, (int)ImplMapFlags.CharMapErrorOn);
return new CustomAttributeData(module, constructor, new object[] { dllName }, list);
}
示例8: __GetCustomAttributes
public static IList<CustomAttributeData> __GetCustomAttributes(Module module, Type attributeType, bool inherit)
{
if (module.__IsMissing)
{
throw new MissingModuleException((MissingModule)module);
}
return GetCustomAttributesImpl(null, module, 0x00000001, attributeType) ?? EmptyList;
}
示例9: ReadDeclarativeSecurity
internal static void ReadDeclarativeSecurity(Module module, int index, List<CustomAttributeData> list)
{
Universe u = module.universe;
Assembly asm = module.Assembly;
int action = module.DeclSecurity.records[index].Action;
ByteReader br = module.GetBlob(module.DeclSecurity.records[index].PermissionSet);
if (br.PeekByte() == '.')
{
br.ReadByte();
int count = br.ReadCompressedUInt();
for (int j = 0; j < count; j++)
{
Type type = ReadType(module, br);
ConstructorInfo constructor = type.GetPseudoCustomAttributeConstructor(u.System_Security_Permissions_SecurityAction);
// LAMESPEC there is an additional length here (probably of the named argument list)
byte[] blob = br.ReadBytes(br.ReadCompressedUInt());
list.Add(new CustomAttributeData(asm, constructor, action, blob, index));
}
}
else
{
// .NET 1.x format (xml)
char[] buf = new char[br.Length / 2];
for (int i = 0; i < buf.Length; i++)
{
buf[i] = br.ReadChar();
}
string xml = new String(buf);
ConstructorInfo constructor = u.System_Security_Permissions_PermissionSetAttribute.GetPseudoCustomAttributeConstructor(u.System_Security_Permissions_SecurityAction);
List<CustomAttributeNamedArgument> args = new List<CustomAttributeNamedArgument>();
args.Add(new CustomAttributeNamedArgument(GetProperty(null, u.System_Security_Permissions_PermissionSetAttribute, "XML", u.System_String),
new CustomAttributeTypedArgument(u.System_String, xml)));
list.Add(new CustomAttributeData(asm.ManifestModule, constructor, new object[] { action }, args));
}
}
示例10: CreatePreserveSigPseudoCustomAttribute
internal static CustomAttributeData CreatePreserveSigPseudoCustomAttribute(Module module)
{
Type type = module.universe.System_Runtime_InteropServices_PreserveSigAttribute;
ConstructorInfo constructor = type.GetPseudoCustomAttributeConstructor();
return new CustomAttributeData(module, constructor, Empty<object>.Array, null);
}
示例11: CreateFieldOffsetPseudoCustomAttribute
internal static CustomAttributeData CreateFieldOffsetPseudoCustomAttribute(Module module, int offset)
{
Type type = module.universe.System_Runtime_InteropServices_FieldOffsetAttribute;
ConstructorInfo constructor = type.GetPseudoCustomAttributeConstructor(module.universe.System_Int32);
return new CustomAttributeData(module, constructor, new object[] { offset }, null);
}
示例12: __GetCustomAttributes
public static IList<CustomAttributeData> __GetCustomAttributes(Module module, Type attributeType, bool inherit)
{
return module.GetCustomAttributesData(attributeType);
}
示例13: GetProperty
private static PropertyInfo GetProperty(Module context, Type type, string name, Type propertyType)
{
Type org = type;
for (; type != null && !type.__IsMissing; type = type.BaseType)
{
foreach (PropertyInfo property in type.__GetDeclaredProperties())
{
if (property.IsPublic && !property.IsStatic && property.Name == name)
{
return property;
}
}
}
// if the property is missing, we stick the missing property on the first missing base type
if (type == null)
{
type = org;
}
return type.Module.universe.GetMissingPropertyOrThrow(context, type, name,
PropertySignature.Create(CallingConventions.Standard | CallingConventions.HasThis, propertyType, null, new PackedCustomModifiers()));
}
示例14: GetCustomAttributes
public static IList<CustomAttributeData> GetCustomAttributes(Module module)
{
return __GetCustomAttributes(module, null, false);
}
示例15: GetCustomAttributesImpl
internal static List<CustomAttributeData> GetCustomAttributesImpl(List<CustomAttributeData> list, Module module, int token, Type attributeType)
{
foreach (int i in module.CustomAttribute.Filter(token))
{
if (attributeType == null)
{
if (list == null)
{
list = new List<CustomAttributeData>();
}
list.Add(new CustomAttributeData(module, i));
}
else
{
if (attributeType.IsAssignableFrom(module.ResolveMethod(module.CustomAttribute.records[i].Type).DeclaringType))
{
if (list == null)
{
list = new List<CustomAttributeData>();
}
list.Add(new CustomAttributeData(module, i));
}
}
}
return list;
}