本文整理汇总了C#中IKVM.Reflection.Reader.ByteReader类的典型用法代码示例。如果您正苦于以下问题:C# ByteReader类的具体用法?C# ByteReader怎么用?C# ByteReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ByteReader类属于IKVM.Reflection.Reader命名空间,在下文中一共展示了ByteReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: FromBlob
internal static ByteReader FromBlob(byte[] blobHeap, int blob)
{
ByteReader br = new ByteReader(blobHeap, blob, 4);
int length = br.ReadCompressedUInt();
br.end = br.pos + length;
return br;
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:7,代码来源:ByteReader.cs
示例2: ReadSig
internal static FieldSignature ReadSig(ModuleReader module, ByteReader br, IGenericContext context)
{
if (br.ReadByte() != FIELD)
{
throw new BadImageFormatException();
}
CustomModifiers mods = CustomModifiers.Read(module, br, context);
Type fieldType = ReadType(module, br, context);
return new FieldSignature(fieldType, mods);
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:10,代码来源:FieldSignature.cs
示例3: ExtractResources
private static void ExtractResources(ResourceDirectoryEntry root, byte[] buf)
{
ByteReader br = new ByteReader(buf, 0, buf.Length);
while (br.Length >= 32)
{
br.Align(4);
RESOURCEHEADER hdr = new RESOURCEHEADER(br);
if (hdr.DataSize != 0)
{
root[hdr.TYPE][hdr.NAME][new OrdinalOrName(hdr.LanguageId)].Data = ByteBuffer.Wrap(br.ReadBytes(hdr.DataSize));
}
}
}
开发者ID:ikvm,项目名称:IKVM.NET-cvs-clone,代码行数:13,代码来源:ResourceSection.cs
示例4: CustomAttributeData
internal CustomAttributeData(Assembly asm, ConstructorInfo constructor, ByteReader br)
{
this.lazyConstructor = constructor;
if (br.Length == 0)
{
// it's legal to have an empty blob
lazyConstructorArguments = Empty<CustomAttributeTypedArgument>.Array;
lazyNamedArguments = Empty<CustomAttributeNamedArgument>.Array;
}
else
{
if (br.ReadUInt16() != 1)
{
throw new BadImageFormatException();
}
lazyConstructorArguments = ReadConstructorArguments(asm, br, constructor);
lazyNamedArguments = ReadNamedArguments(asm, br, br.ReadUInt16(), constructor.DeclaringType);
}
}
开发者ID:,项目名称:,代码行数:19,代码来源:
示例5: ReadGenericInst
private static Type ReadGenericInst(ModuleReader module, ByteReader br, IGenericContext context)
{
Type type;
switch (br.ReadByte())
{
case ELEMENT_TYPE_CLASS:
type = ReadTypeDefOrRefEncoded(module, br, context).MarkNotValueType();
break;
case ELEMENT_TYPE_VALUETYPE:
type = ReadTypeDefOrRefEncoded(module, br, context).MarkValueType();
break;
default:
throw new BadImageFormatException();
}
if (!type.__IsMissing && !type.IsGenericTypeDefinition)
{
throw new BadImageFormatException();
}
int genArgCount = br.ReadCompressedInt();
Type[] args = new Type[genArgCount];
Type[][] reqmod = null;
Type[][] optmod = null;
for (int i = 0; i < genArgCount; i++)
{
// LAMESPEC the Type production (23.2.12) doesn't include CustomMod* for genericinst, but C++ uses it, the verifier allows it and ildasm also supports it
CustomModifiers mods = ReadCustomModifiers(module, br, context);
if (mods.required != null || mods.optional != null)
{
if (reqmod == null)
{
reqmod = new Type[genArgCount][];
optmod = new Type[genArgCount][];
}
reqmod[i] = mods.required;
optmod[i] = mods.optional;
}
args[i] = ReadType(module, br, context);
}
return GenericTypeInstance.Make(type, args, reqmod, optmod);
}
开发者ID:ngraziano,项目名称:mono,代码行数:40,代码来源:Signature.cs
示例6: DecodeDeclSecurity
bool DecodeDeclSecurity(StringBuilder sb, IList<CustomAttributeData> list, int level)
{
try
{
sb.Append(" = {");
bool first = true;
foreach (var sec in list)
{
if (!first)
{
sb.Append(',');
sb.AppendLine();
sb.Append(' ', level + 14);
}
first = false;
string typeName = sec.Constructor.DeclaringType.AssemblyQualifiedName;
if (typeName.EndsWith(", mscorlib", StringComparison.Ordinal))
{
typeName = typeName.Substring(0, typeName.Length - 10);
}
AppendTypeName(sb, sec.Constructor.DeclaringType, typeName, compat != CompatLevel.None);
sb.Append(" = {");
byte[] blob = sec.__GetBlob();
// LAMESPEC the count of named arguments is a compressed integer (instead of UInt16 as NumNamed in custom attributes)
var br = new ByteReader(blob, 0, blob.Length);
int count = br.ReadCompressedInt();
ReadNamedArguments(sb, br, count, 0, compat != CompatLevel.None && count > 1);
sb.Append('}');
}
sb.Append('}');
return true;
}
catch (IKVM.Reflection.BadImageFormatException)
{
return false;
}
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:37,代码来源:CABlob.cs
示例7: ReadSig
internal static MethodSignature ReadSig(ModuleReader module, ByteReader br, IGenericContext context)
{
CallingConventions callingConvention;
int genericParamCount;
Type returnType;
Type[] parameterTypes;
byte flags = br.ReadByte();
switch (flags & 7)
{
case DEFAULT:
callingConvention = CallingConventions.Standard;
break;
case VARARG:
callingConvention = CallingConventions.VarArgs;
break;
default:
throw new BadImageFormatException();
}
if ((flags & HASTHIS) != 0)
{
callingConvention |= CallingConventions.HasThis;
}
if ((flags & EXPLICITTHIS) != 0)
{
callingConvention |= CallingConventions.ExplicitThis;
}
genericParamCount = 0;
if ((flags & GENERIC) != 0)
{
genericParamCount = br.ReadCompressedInt();
context = new UnboundGenericMethodContext(context);
}
int paramCount = br.ReadCompressedInt();
Type[][][] modifiers = null;
Type[] optionalCustomModifiers;
Type[] requiredCustomModifiers;
ReadCustomModifiers(module, br, context, out requiredCustomModifiers, out optionalCustomModifiers);
returnType = ReadRetType(module, br, context);
parameterTypes = new Type[paramCount];
PackedCustomModifiers.SetModifiers(ref modifiers, 0, 0, optionalCustomModifiers, paramCount + 1);
PackedCustomModifiers.SetModifiers(ref modifiers, 0, 1, requiredCustomModifiers, paramCount + 1);
for (int i = 0; i < parameterTypes.Length; i++)
{
if ((callingConvention & CallingConventions.VarArgs) != 0 && br.PeekByte() == SENTINEL)
{
Array.Resize(ref parameterTypes, i);
if (modifiers != null)
{
Array.Resize(ref modifiers, i + 1);
}
break;
}
ReadCustomModifiers(module, br, context, out requiredCustomModifiers, out optionalCustomModifiers);
PackedCustomModifiers.SetModifiers(ref modifiers, i + 1, 0, optionalCustomModifiers, paramCount + 1);
PackedCustomModifiers.SetModifiers(ref modifiers, i + 1, 1, requiredCustomModifiers, paramCount + 1);
parameterTypes[i] = ReadParam(module, br, context);
}
return new MethodSignature(returnType, parameterTypes, modifiers, callingConvention, genericParamCount);
}
开发者ID:ngraziano,项目名称:mono,代码行数:59,代码来源:MethodSignature.cs
示例8: ReadString
private static string ReadString(ByteReader br)
{
return Encoding.UTF8.GetString(br.ReadBytes(br.ReadCompressedUInt()));
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:4,代码来源:MarshalSpec.cs
示例9: ReadType
Type ReadType(ByteReader br, out string typeName)
{
typeName = br.ReadString();
if (typeName == null)
{
return null;
}
if (typeName.Length > 0 && typeName[typeName.Length - 1] == 0)
{
// there are broken compilers that emit an extra NUL character after the type name
typeName = typeName.Substring(0, typeName.Length - 1);
}
var type = universe.ResolveType(assembly, typeName);
if (type != null && type.Assembly == mscorlib)
{
// we don't want that!
type = universe.ResolveType(assembly, type.FullName + ", mscorlib, Version=0.0.0.0");
}
return type;
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:20,代码来源:CABlob.cs
示例10: ReadNamedArguments
void ReadNamedArguments(StringBuilder sb, ByteReader br, int named, int level, bool securityCompatHack)
{
for (int i = 0; i < named; i++)
{
if (i != 0)
{
AppendNewLine(sb, level);
}
byte fieldOrProperty = br.ReadByte();
switch (fieldOrProperty)
{
case 0x53:
sb.Append("field ");
break;
case 0x54:
sb.Append("property ");
break;
default:
throw new IKVM.Reflection.BadImageFormatException();
}
string typeName;
Type fieldOrPropertyType = ReadFieldOrPropType(sb, br, out typeName);
AppendCATypeName(sb, fieldOrPropertyType, typeName, securityCompatHack);
sb.Append(' ').Append(QuoteIdentifier(br.ReadString(), true)).Append(" = ");
ReadFixedArg(sb, br, fieldOrPropertyType);
}
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:27,代码来源:CABlob.cs
示例11: DecodeCABlob
bool DecodeCABlob(StringBuilder sb, ConstructorInfo constructor, byte[] blob, int level)
{
try
{
// CustomAttribute
var br = new ByteReader(blob, 2, blob.Length - 4);
ReadConstructorArguments(sb, br, constructor, level);
br = new ByteReader(blob, blob.Length - (br.Length + 2), br.Length + 2);
int named = br.ReadUInt16();
if (constructor.GetParameters().Length != 0 && named != 0)
{
AppendNewLine(sb, level);
}
ReadNamedArguments(sb, br, named, level, false);
return true;
}
catch (IKVM.Reflection.BadImageFormatException) { }
catch (ArgumentOutOfRangeException) { }
return false;
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:20,代码来源:CABlob.cs
示例12: ReadArrayBounds
private static int[] ReadArrayBounds(ByteReader br)
{
int num = br.ReadCompressedUInt();
if (num == 0)
{
return null;
}
int[] arr = new int[num];
for (int i = 0; i < num; i++)
{
arr[i] = br.ReadCompressedInt();
}
return arr;
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:14,代码来源:Signature.cs
示例13: ReadMethodSpec
internal static Type[] ReadMethodSpec(ModuleReader module, ByteReader br, IGenericContext context)
{
if (br.ReadByte() != GENERICINST)
{
throw new BadImageFormatException();
}
Type[] args = new Type[br.ReadCompressedUInt()];
for (int i = 0; i < args.Length; i++)
{
CustomModifiers.Skip(br);
args[i] = ReadType(module, br, context);
}
return args;
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:14,代码来源:Signature.cs
示例14: ReadFunctionPointer
private static Type ReadFunctionPointer(ModuleReader module, ByteReader br, IGenericContext context)
{
__StandAloneMethodSig sig = MethodSignature.ReadStandAloneMethodSig(module, br, context);
if (module.universe.EnableFunctionPointers)
{
return FunctionPointerType.Make(module.universe, sig);
}
else
{
// by default, like .NET we return System.IntPtr here
return module.universe.System_IntPtr;
}
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:13,代码来源:Signature.cs
示例15: ReadTypeSpec
internal static Type ReadTypeSpec(ModuleReader module, ByteReader br, IGenericContext context)
{
// LAMESPEC a TypeSpec can contain custom modifiers (C++/CLI generates "newarr (TypeSpec with custom modifiers)")
CustomModifiers.Skip(br);
// LAMESPEC anything can be adorned by (useless) custom modifiers
// also, VAR and MVAR are also used in TypeSpec (contrary to what the spec says)
return ReadType(module, br, context);
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:8,代码来源:Signature.cs
示例16: RESOURCEHEADER
internal RESOURCEHEADER(ByteReader br)
{
DataSize = br.ReadInt32();
HeaderSize = br.ReadInt32();
TYPE = ReadOrdinalOrName(br);
NAME = ReadOrdinalOrName(br);
br.Align(4);
DataVersion = br.ReadInt32();
MemoryFlags = br.ReadUInt16();
LanguageId = br.ReadUInt16();
Version = br.ReadInt32();
Characteristics = br.ReadInt32();
}
开发者ID:koush,项目名称:mono,代码行数:13,代码来源:ResourceSection.cs
示例17: ReadOrdinalOrName
private static OrdinalOrName ReadOrdinalOrName(ByteReader br)
{
char c = br.ReadChar();
if (c == 0xFFFF)
{
return new OrdinalOrName(br.ReadUInt16());
}
else
{
StringBuilder sb = new StringBuilder();
while (c != 0)
{
sb.Append(c);
c = br.ReadChar();
}
return new OrdinalOrName(sb.ToString());
}
}
开发者ID:koush,项目名称:mono,代码行数:18,代码来源:ResourceSection.cs
示例18: ReadTypeOrVoid
private static Type ReadTypeOrVoid(ModuleReader module, ByteReader br, IGenericContext context)
{
if (br.PeekByte() == ELEMENT_TYPE_VOID)
{
br.ReadByte();
return module.universe.System_Void;
}
else
{
return ReadType(module, br, context);
}
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:12,代码来源:Signature.cs
示例19: ReadConstructorArguments
void ReadConstructorArguments(StringBuilder sb, ByteReader br, ConstructorInfo constructor, int level)
{
bool first = true;
foreach (var parameter in constructor.GetParameters())
{
if (!first)
{
AppendNewLine(sb, level);
}
first = false;
ReadFixedArg(sb, br, parameter.ParameterType);
}
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:13,代码来源:CABlob.cs
示例20: ReadType
// see ECMA 335 CLI spec June 2006 section 23.2.12 for this production
protected static Type ReadType(ModuleReader module, ByteReader br, IGenericContext context)
{
CustomModifiers mods;
switch (br.ReadByte())
{
case ELEMENT_TYPE_CLASS:
return ReadTypeDefOrRefEncoded(module, br, context).MarkNotValueType();
case ELEMENT_TYPE_VALUETYPE:
return ReadTypeDefOrRefEncoded(module, br, context).MarkValueType();
case ELEMENT_TYPE_BOOLEAN:
return module.universe.System_Boolean;
case ELEMENT_TYPE_CHAR:
return module.universe.System_Char;
case ELEMENT_TYPE_I1:
return module.universe.System_SByte;
case ELEMENT_TYPE_U1:
return module.universe.System_Byte;
case ELEMENT_TYPE_I2:
return module.universe.System_Int16;
case ELEMENT_TYPE_U2:
return module.universe.System_UInt16;
case ELEMENT_TYPE_I4:
return module.universe.System_Int32;
case ELEMENT_TYPE_U4:
return module.universe.System_UInt32;
case ELEMENT_TYPE_I8:
return module.universe.System_Int64;
case ELEMENT_TYPE_U8:
return module.universe.System_UInt64;
case ELEMENT_TYPE_R4:
return module.universe.System_Single;
case ELEMENT_TYPE_R8:
return module.universe.System_Double;
case ELEMENT_TYPE_I:
return module.universe.System_IntPtr;
case ELEMENT_TYPE_U:
return module.universe.System_UIntPtr;
case ELEMENT_TYPE_STRING:
return module.universe.System_String;
case ELEMENT_TYPE_OBJECT:
return module.universe.System_Object;
case ELEMENT_TYPE_VAR:
return context.GetGenericTypeArgument(br.ReadCompressedUInt());
case ELEMENT_TYPE_MVAR:
return context.GetGenericMethodArgument(br.ReadCompressedUInt());
case ELEMENT_TYPE_GENERICINST:
return ReadGenericInst(module, br, context);
case ELEMENT_TYPE_SZARRAY:
mods = CustomModifiers.Read(module, br, context);
return ReadType(module, br, context).__MakeArrayType(mods);
case ELEMENT_TYPE_ARRAY:
mods = CustomModifiers.Read(module, br, context);
return ReadType(module, br, context).__MakeArrayType(br.ReadCompressedUInt(), ReadArraySizes(br), ReadArrayBounds(br), mods);
case ELEMENT_TYPE_PTR:
mods = CustomModifiers.Read(module, br, context);
return ReadTypeOrVoid(module, br, context).__MakePointerType(mods);
case ELEMENT_TYPE_FNPTR:
return ReadFunctionPointer(module, br, context);
default:
throw new BadImageFormatException();
}
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:63,代码来源:Signature.cs
注:本文中的IKVM.Reflection.Reader.ByteReader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论