当前位置: 首页>>代码示例>>C#>>正文


C# Reader.ByteReader类代码示例

本文整理汇总了C#中IKVM.Reflection.Reader.ByteReader的典型用法代码示例。如果您正苦于以下问题:C# ByteReader类的具体用法?C# ByteReader怎么用?C# ByteReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ByteReader类属于IKVM.Reflection.Reader命名空间,在下文中一共展示了ByteReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的IKVM.Reflection.Reader.ByteReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。