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


C# BigEndianBinaryReader.ReadUInt16方法代码示例

本文整理汇总了C#中BigEndianBinaryReader.ReadUInt16方法的典型用法代码示例。如果您正苦于以下问题:C# BigEndianBinaryReader.ReadUInt16方法的具体用法?C# BigEndianBinaryReader.ReadUInt16怎么用?C# BigEndianBinaryReader.ReadUInt16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BigEndianBinaryReader的用法示例。


在下文中一共展示了BigEndianBinaryReader.ReadUInt16方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EncodingRecord

		internal EncodingRecord(BigEndianBinaryReader reader)
		{
			Contract.Requires(reader != null);

			ushort platformID = reader.ReadUInt16();
			ushort encodingID = reader.ReadUInt16();

		}
开发者ID:JeroenBos,项目名称:ASDE,代码行数:8,代码来源:EncodingRecord.cs

示例2: CmapTable

		internal CmapTable(BigEndianBinaryReader reader)
		{
			Contract.Requires(reader != null);
			Contract.Requires(reader.BaseStream.CanSeek);

			ushort version = reader.ReadUInt16();
			ushort numTables = reader.ReadUInt16();
		}
开发者ID:JeroenBos,项目名称:ASDE,代码行数:8,代码来源:CmapTable.cs

示例3: VerticalMetric

		public VerticalMetric(BigEndianBinaryReader reader)
		{
			Contract.Requires(reader != null);

			AdvanceHeight = reader.ReadUInt16();
			TopSideBearings = reader.ReadInt16();
		}
开发者ID:JeroenBos,项目名称:ASDE,代码行数:7,代码来源:vMetric.cs

示例4: ReadPhotoshopCurvesFile

        public static CurveCollection ReadPhotoshopCurvesFile(string filePath)
        {
            CurveCollection curves = new CurveCollection();

            using (Stream fileStream = File.OpenRead(filePath))
            {
                using (BinaryReader reader = new BigEndianBinaryReader(fileStream))
                {
                    // Read version.
                    ushort version = reader.ReadUInt16();
                    //reader.ReadUInt16();

                    // Read number of curves in file.
                    ushort numCurves = reader.ReadUInt16();

                    // Read all curves.
                    for (int i = 0; i < numCurves; ++i)
                    {
                        Curve curve = new Curve();
                        curves.Add(curve);

                        // Read number of points in the curve.
                        ushort numPoints = reader.ReadUInt16();

                        // Read all points.
                        for (int j = 0; j < numPoints; ++j)
                        {
                            // First number is output.
                            ushort output = reader.ReadUInt16();

                            // Second number is input.
                            ushort input = reader.ReadUInt16();

                            curve.Points.Add(new CurvePoint
                            {
                                Input = input,
                                Output = output
                            });
                        }
                    }
                }
            }

            return curves;
        }
开发者ID:pacificIT,项目名称:dynamic-image,代码行数:45,代码来源:PhotoshopCurvesReader.cs

示例5: ConstantPoolItemInvokeDynamic

			internal ConstantPoolItemInvokeDynamic(BigEndianBinaryReader br)
			{
				bootstrap_specifier_index = br.ReadUInt16();
				name_and_type_index = br.ReadUInt16();
			}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:5,代码来源:ClassFile.cs

示例6: ConstantPoolItemMethodHandle

			internal ConstantPoolItemMethodHandle(BigEndianBinaryReader br)
			{
				ref_kind = br.ReadByte();
				method_index = br.ReadUInt16();
			}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:5,代码来源:ClassFile.cs

示例7: ConstantPoolItemMethodType

			internal ConstantPoolItemMethodType(BigEndianBinaryReader br)
			{
				signature_index = br.ReadUInt16();
			}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:4,代码来源:ClassFile.cs

示例8: ReadConstantPool

 ConstantPool[] ReadConstantPool(BigEndianBinaryReader reader)
 {
     ushort constantPoolCount = reader.ReadUInt16();
     ConstantPool[] constantPool = new ConstantPool[constantPoolCount];
     //Console.WriteLine("Reading {0} ConstantPool items", constantPoolCount);
     // JVM Spec 4.1.
     // The value of the constant_pool_count item is equal to the number
     // of entries in the constant_pool table plus one. A constant_pool
     // index is considered valid if it is greater than zero and less
     // than constant_pool_count, with the exception for constants of
     // type long and double noted in 4.4.5.
     for (ushort i = 1; i < constantPoolCount; i++) {
         ConstantType tag = (ConstantType) reader.ReadByte();
         ConstantPool item = new ConstantPool();
         constantPool[i] = item;
         switch (tag) {
             case ConstantType.Class:
                 /*
                     CONSTANT_Class_info {
                         u1 tag;
                         u2 name_index;
                     }
                 */
                 item.ConstantType = ConstantType.Class;
                 item.NameIndex = reader.ReadUInt16();
                 break;
             case ConstantType.Fieldref:
                 /*
                     CONSTANT_Fieldref_info {
                         u1 tag;
                         u2 class_index;
                         u2 name_and_type_index;
                     }
                 */
                 item.ConstantType = ConstantType.Fieldref;
                 item.ClassIndex = reader.ReadUInt16();
                 item.NameAndTypeIndex = reader.ReadUInt16();
                 break;
             case ConstantType.Methodref:
                 /*
                     CONSTANT_Methodref_info {
                         u1 tag;
                         u2 class_index;
                         u2 name_and_type_index;
                     }
                 */
                 item.ConstantType = ConstantType.Methodref;
                 item.ClassIndex = reader.ReadUInt16();
                 item.NameAndTypeIndex = reader.ReadUInt16();
                 break;
             case ConstantType.InterfaceMethodref:
                 /*
                     CONSTANT_InterfaceMethodref_info {
                         u1 tag;
                         u2 class_index;
                         u2 name_and_type_index;
                     }
                 */
                 item.ConstantType = ConstantType.InterfaceMethodref;
                 item.ClassIndex = reader.ReadUInt16();
                 item.NameAndTypeIndex = reader.ReadUInt16();
                 break;
             case ConstantType.String:
                 /*
                     CONSTANT_String_info {
                         u1 tag;
                         u2 string_index;
                     }
                 */
                 item.ConstantType = ConstantType.String;
                 item.StringIndex = reader.ReadUInt16();
                 break;
             case ConstantType.Integer:
                 /*
                     CONSTANT_Integer_info {
                         u1 tag;
                         u4 bytes;
                     }
                 */
                 item.ConstantType = ConstantType.Integer;
                 item.Integer = reader.ReadInt32();
                 break;
             case ConstantType.Float:
                 /*
                     CONSTANT_Float_info {
                         u1 tag;
                         u4 bytes;
                     }
                 */
                 item.ConstantType = ConstantType.Float;
                 item.Float = reader.ReadSingle();
                 break;
             case ConstantType.Long:
                 /*
                     CONSTANT_Long_info {
                         u1 tag;
                         u4 high_bytes;
                         u4 low_bytes;
                     }
                 */
//.........这里部分代码省略.........
开发者ID:olympum,项目名称:caffeine,代码行数:101,代码来源:ClassFile.cs

示例9: ConstantPoolItemNameAndType

			internal ConstantPoolItemNameAndType(BigEndianBinaryReader br)
			{
				name_index = br.ReadUInt16();
				descriptor_index = br.ReadUInt16();
			}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:5,代码来源:ClassFile.cs

示例10: Field

			internal Field(ClassFile classFile, string[] utf8_cp, BigEndianBinaryReader br) : base(classFile, utf8_cp, br)
			{
				if((IsPrivate && IsPublic) || (IsPrivate && IsProtected) || (IsPublic && IsProtected)
					|| (IsFinal && IsVolatile)
					|| (classFile.IsInterface && (!IsPublic || !IsStatic || !IsFinal || IsTransient)))
				{
					throw new ClassFormatError("{0} (Illegal field modifiers: 0x{1:X})", classFile.Name, access_flags);
				}
				int attributes_count = br.ReadUInt16();
				for(int i = 0; i < attributes_count; i++)
				{
					switch(classFile.GetConstantPoolUtf8String(utf8_cp, br.ReadUInt16()))
					{
						case "Deprecated":
							if(br.ReadUInt32() != 0)
							{
								throw new ClassFormatError("Invalid Deprecated attribute length");
							}
							flags |= FLAG_MASK_DEPRECATED;
							break;
						case "ConstantValue":
						{
							if(br.ReadUInt32() != 2)
							{
								throw new ClassFormatError("Invalid ConstantValue attribute length");
							}
							ushort index = br.ReadUInt16();
							try
							{
								switch(Signature)
								{
									case "I":
										constantValue = classFile.GetConstantPoolConstantInteger(index);
										break;
									case "S":
										constantValue = (short)classFile.GetConstantPoolConstantInteger(index);
										break;
									case "B":
										constantValue = (byte)classFile.GetConstantPoolConstantInteger(index);
										break;
									case "C":
										constantValue = (char)classFile.GetConstantPoolConstantInteger(index);
										break;
									case "Z":
										constantValue = classFile.GetConstantPoolConstantInteger(index) != 0;
										break;
									case "J":
										constantValue = classFile.GetConstantPoolConstantLong(index);
										break;
									case "F":
										constantValue = classFile.GetConstantPoolConstantFloat(index);
										break;
									case "D":
										constantValue = classFile.GetConstantPoolConstantDouble(index);
										break;
									case "Ljava.lang.String;":
										constantValue = classFile.GetConstantPoolConstantString(index);
										break;
									default:
										throw new ClassFormatError("{0} (Invalid signature for constant)", classFile.Name);
								}
							}
							catch(InvalidCastException)
							{
								throw new ClassFormatError("{0} (Bad index into constant pool)", classFile.Name);
							}
							catch(IndexOutOfRangeException)
							{
								throw new ClassFormatError("{0} (Bad index into constant pool)", classFile.Name);
							}
							catch(InvalidOperationException)
							{
								throw new ClassFormatError("{0} (Bad index into constant pool)", classFile.Name);
							}
							catch(NullReferenceException)
							{
								throw new ClassFormatError("{0} (Bad index into constant pool)", classFile.Name);
							}
							break;
						}
						case "Signature":
							if(classFile.MajorVersion < 49)
							{
								goto default;
							}
							if(br.ReadUInt32() != 2)
							{
								throw new ClassFormatError("Signature attribute has incorrect length");
							}
							signature = classFile.GetConstantPoolUtf8String(utf8_cp, br.ReadUInt16());
							break;
						case "RuntimeVisibleAnnotations":
							if(classFile.MajorVersion < 49)
							{
								goto default;
							}
							annotations = ReadAnnotations(br, classFile, utf8_cp);
							break;
						case "RuntimeInvisibleAnnotations":
							if(classFile.MajorVersion < 49)
//.........这里部分代码省略.........
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:101,代码来源:ClassFile.cs

示例11: ClassFile

        public ClassFile(Stream s)
        {
            BigEndianBinaryReader reader = new BigEndianBinaryReader(s);
            /*
                ClassFile {
                    u4 magic;
                    u2 minor_version;
                    u2 major_version;
                    u2 constant_pool_count;
                    cp_info constant_pool[constant_pool_count-1];
                    u2 access_flags;
                    u2 this_class;
                    u2 super_class;
                    u2 interfaces_count;
                    u2 interfaces[interfaces_count];
                    u2 fields_count;
                    field_info fields[fields_count];
                    u2 methods_count;
                    method_info methods[methods_count];
                    u2 attributes_count;
                    attribute_info attributes[attributes_count];
                }
            */

            uint magic = reader.ReadUInt32();
            if (magic != 0xCAFEBABE) {
                throw new ApplicationException("Bad magic in class: " +
                    magic);
            }
            ushort minorVersion = reader.ReadUInt16();
            ushort majorVersion = reader.ReadUInt16();
            if (majorVersion < 45 || majorVersion > 48) {
                throw new ApplicationException("Unsupported class version (" +
                    majorVersion + '.' + minorVersion + ")");
            }
            constantPool = ReadConstantPool(reader);
            accessFlags = reader.ReadUInt16();
            thisClass = reader.ReadUInt16();
            superClass = reader.ReadUInt16();
            interfaces = ReadInterfaces(reader);
            fields = ReadFields(reader);
            methods = ReadMethods(reader);
            attributes = ReadAttributes(reader);
        }
开发者ID:olympum,项目名称:caffeine,代码行数:44,代码来源:ClassFile.cs

示例12: ReadFields

 FieldInfo[] ReadFields(BigEndianBinaryReader reader)
 {
     ushort fieldsCount = reader.ReadUInt16();
     FieldInfo[] fields = new FieldInfo[fieldsCount];
     if (fieldsCount == 0) {
         return fields;
     }
     for (ushort i = 0; i < fieldsCount; i++) {
         /*
             field_info {
                 u2 access_flags;
                 u2 name_index;
                 u2 descriptor_index;
                 u2 attributes_count;
                 attribute_info attributes[attributes_count];
             }
         */
         FieldInfo field;
         field.AccessFlags = reader.ReadUInt16();
         field.NameIndex = reader.ReadUInt16();
         field.DescriptorIndex = reader.ReadUInt16();
         field.Attributes = ReadAttributes(reader);
         fields[i] = field;
     }
     return fields;
 }
开发者ID:olympum,项目名称:caffeine,代码行数:26,代码来源:ClassFile.cs

示例13: Read

				internal void Read(ClassFile classFile, string[] utf8_cp, Method method, BigEndianBinaryReader br, ClassFileParseOptions options)
				{
					max_stack = br.ReadUInt16();
					max_locals = br.ReadUInt16();
					uint code_length = br.ReadUInt32();
					if(code_length > 65535)
					{
						throw new ClassFormatError("{0} (Invalid Code length {1})", classFile.Name, code_length);
					}
					Instruction[] instructions = new Instruction[code_length + 1];
					int basePosition = br.Position;
					int instructionIndex = 0;
					try
					{
						BigEndianBinaryReader rdr = br.Section(code_length);
						while(!rdr.IsAtEnd)
						{
							instructions[instructionIndex].Read((ushort)(rdr.Position - basePosition), rdr, classFile);
							hasJsr |= instructions[instructionIndex].NormalizedOpCode == NormalizedByteCode.__jsr;
							instructionIndex++;
						}
						// we add an additional nop instruction to make it easier for consumers of the code array
						instructions[instructionIndex++].SetTermNop((ushort)(rdr.Position - basePosition));
					}
					catch(ClassFormatError x)
					{
						// any class format errors in the code block are actually verify errors
						verifyError = x.Message;
					}
					this.instructions = new Instruction[instructionIndex];
					Array.Copy(instructions, 0, this.instructions, 0, instructionIndex);
					// build the pcIndexMap
					int[] pcIndexMap = new int[this.instructions[instructionIndex - 1].PC + 1];
					for(int i = 0; i < pcIndexMap.Length; i++)
					{
						pcIndexMap[i] = -1;
					}
					for(int i = 0; i < instructionIndex - 1; i++)
					{
						pcIndexMap[this.instructions[i].PC] = i;
					}
					// convert branch offsets to indexes
					for(int i = 0; i < instructionIndex - 1; i++)
					{
						switch(this.instructions[i].NormalizedOpCode)
						{
							case NormalizedByteCode.__ifeq:
							case NormalizedByteCode.__ifne:
							case NormalizedByteCode.__iflt:
							case NormalizedByteCode.__ifge:
							case NormalizedByteCode.__ifgt:
							case NormalizedByteCode.__ifle:
							case NormalizedByteCode.__if_icmpeq:
							case NormalizedByteCode.__if_icmpne:
							case NormalizedByteCode.__if_icmplt:
							case NormalizedByteCode.__if_icmpge:
							case NormalizedByteCode.__if_icmpgt:
							case NormalizedByteCode.__if_icmple:
							case NormalizedByteCode.__if_acmpeq:
							case NormalizedByteCode.__if_acmpne:
							case NormalizedByteCode.__ifnull:
							case NormalizedByteCode.__ifnonnull:
							case NormalizedByteCode.__goto:
							case NormalizedByteCode.__jsr:
								this.instructions[i].SetTargetIndex(pcIndexMap[this.instructions[i].Arg1 + this.instructions[i].PC]);
								break;
							case NormalizedByteCode.__tableswitch:
							case NormalizedByteCode.__lookupswitch:
								this.instructions[i].MapSwitchTargets(pcIndexMap);
								break;
						}
					}
					// read exception table
					ushort exception_table_length = br.ReadUInt16();
					exception_table = new ExceptionTableEntry[exception_table_length];
					for(int i = 0; i < exception_table_length; i++)
					{
						ushort start_pc = br.ReadUInt16();
						ushort end_pc = br.ReadUInt16();
						ushort handler_pc = br.ReadUInt16();
						ushort catch_type = br.ReadUInt16();
						if(start_pc >= end_pc
							|| end_pc > code_length
							|| handler_pc >= code_length
							|| (catch_type != 0 && !classFile.SafeIsConstantPoolClass(catch_type)))
						{
							throw new ClassFormatError("Illegal exception table: {0}.{1}{2}", classFile.Name, method.Name, method.Signature);
						}
						classFile.MarkLinkRequiredConstantPoolItem(catch_type);
						// if start_pc, end_pc or handler_pc is invalid (i.e. doesn't point to the start of an instruction),
						// the index will be -1 and this will be handled by the verifier
						int startIndex = pcIndexMap[start_pc];
						int endIndex;
						if (end_pc == code_length)
						{
							// it is legal for end_pc to point to just after the last instruction,
							// but since there isn't an entry in our pcIndexMap for that, we have
							// a special case for this
							endIndex = instructionIndex - 1;
						}
//.........这里部分代码省略.........
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:101,代码来源:ClassFile.cs

示例14: ClassFile

	internal ClassFile(byte[] buf, int offset, int length, string inputClassName, bool allowJavaLangObject)
	{
		try
		{
			BigEndianBinaryReader br = new BigEndianBinaryReader(buf, offset, length);
			if (br.ReadUInt32() != 0xCAFEBABE)
			{
				throw new ClassFormatError("{0} (Bad magic number)", inputClassName);
			}
			int minorVersion = br.ReadUInt16();
			majorVersion = br.ReadUInt16();
			if (majorVersion < SupportedVersions.Minimum || majorVersion > SupportedVersions.Maximum)
			{
				throw new UnsupportedClassVersionError(inputClassName + " (" + majorVersion + "." + minorVersion + ")");
			}
			int constantpoolcount = br.ReadUInt16();
			constantpool = new ConstantPoolItem[constantpoolcount];
			utf8_cp = new string[constantpoolcount];
			for (int i = 1; i < constantpoolcount; i++)
			{
				Constant tag = (Constant) br.ReadByte();
				switch (tag)
				{
					case Constant.Class:
						constantpool[i] = new ConstantPoolItemClass(br);
						break;
					case Constant.Double:
						constantpool[i] = new ConstantPoolItemDouble(br);
						i++;
						break;
					case Constant.Fieldref:
						constantpool[i] = new ConstantPoolItemFieldref(br);
						break;
					case Constant.Float:
						constantpool[i] = new ConstantPoolItemFloat(br);
						break;
					case Constant.Integer:
						constantpool[i] = new ConstantPoolItemInteger(br);
						break;
					case Constant.InterfaceMethodref:
						constantpool[i] = new ConstantPoolItemInterfaceMethodref(br);
						break;
					case Constant.Long:
						constantpool[i] = new ConstantPoolItemLong(br);
						i++;
						break;
					case Constant.Methodref:
						constantpool[i] = new ConstantPoolItemMethodref(br);
						break;
					case Constant.NameAndType:
						constantpool[i] = new ConstantPoolItemNameAndType(br);
						break;
					case Constant.String:
						constantpool[i] = new ConstantPoolItemString(br);
						break;
					case Constant.Utf8:
						utf8_cp[i] = br.ReadString(inputClassName);
						break;
					default:
						throw new ClassFormatError("{0} (Illegal constant pool type 0x{1:X})", inputClassName, tag);
				}
			}
			for (int i = 1; i < constantpoolcount; i++)
			{
				if (constantpool[i] != null)
				{
					try
					{
						constantpool[i].Resolve(this);
					}
					catch (ClassFormatError x)
					{
						// HACK at this point we don't yet have the class name, so any exceptions throw
						// are missing the class name
						throw new ClassFormatError("{0} ({1})", inputClassName, x.Message);
					}
					catch (IndexOutOfRangeException)
					{
						throw new ClassFormatError("{0} (Invalid constant pool item #{1})", inputClassName, i);
					}
					catch (InvalidCastException)
					{
						throw new ClassFormatError("{0} (Invalid constant pool item #{1})", inputClassName, i);
					}
				}
			}
			access_flags = (__Modifiers) br.ReadUInt16();
			// NOTE although the vmspec says (in 4.1) that interfaces must be marked abstract, earlier versions of
			// javac (JDK 1.1) didn't do this, so the VM doesn't enforce this rule
			// NOTE although the vmspec implies (in 4.1) that ACC_SUPER is illegal on interfaces, it doesn't enforce this
			if ((IsInterface && IsFinal) || (IsAbstract && IsFinal))
			{
				throw new ClassFormatError("{0} (Illegal class modifiers 0x{1:X})", inputClassName, access_flags);
			}
			this_class = br.ReadUInt16();
			ValidateConstantPoolItemClass(inputClassName, this_class);
			super_class = br.ReadUInt16();
			// NOTE for convenience we allow parsing java/lang/Object (which has no super class), so
			// we check for super_class != 0
			if (super_class != 0)
//.........这里部分代码省略.........
开发者ID:sourcewarehouse,项目名称:janett,代码行数:101,代码来源:ClassFile.cs

示例15: ReadInterfaces

 ushort[] ReadInterfaces(BigEndianBinaryReader reader)
 {
     ushort interfacesCount = reader.ReadUInt16();
     ushort[] interfaces = new ushort[interfacesCount];
     if (interfacesCount == 0) {
         return interfaces;
     }
     for (ushort i = 0; i < interfacesCount; i++) {
         interfaces[i] = reader.ReadUInt16();
     }
     return interfaces;
 }
开发者ID:olympum,项目名称:caffeine,代码行数:12,代码来源:ClassFile.cs


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