當前位置: 首頁>>代碼示例>>C#>>正文


C# BigEndianBinaryReader.ReadInt32方法代碼示例

本文整理匯總了C#中BigEndianBinaryReader.ReadInt32方法的典型用法代碼示例。如果您正苦於以下問題:C# BigEndianBinaryReader.ReadInt32方法的具體用法?C# BigEndianBinaryReader.ReadInt32怎麽用?C# BigEndianBinaryReader.ReadInt32使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BigEndianBinaryReader的用法示例。


在下文中一共展示了BigEndianBinaryReader.ReadInt32方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Read

        /// <summary>
        /// Reads a stream and converts the shapefile record to an equilivant geometry object.
        /// </summary>
        /// <param name="file">The stream to read.</param>
        /// <param name="geometryFactory">The geometry factory to use when making the object.</param>
        /// <returns>The Geometry object that represents the shape file record.</returns>
        public override IGeometry Read(BigEndianBinaryReader file, IGeometryFactory geometryFactory)
        {
            int shapeTypeNum = file.ReadInt32();

            type = (ShapeGeometryType) Enum.Parse(typeof(ShapeGeometryType), shapeTypeNum.ToString());
            if (type == ShapeGeometryType.NullShape)
                return geometryFactory.CreateMultiPoint(new IPoint[] { });
            
            if (!(type == ShapeGeometryType.MultiPoint  || type == ShapeGeometryType.MultiPointM ||
                  type == ShapeGeometryType.MultiPointZ || type == ShapeGeometryType.MultiPointZM))	
                throw new ShapefileException("Attempting to load a non-multipoint as multipoint.");

            // Read and for now ignore bounds.
            int bblength = GetBoundingBoxLength();
            bbox = new double[bblength];
            for (; bbindex < 4; bbindex++)
            {
                double d = file.ReadDouble();
                bbox[bbindex] = d;
            }

            // Read points
            int numPoints = file.ReadInt32();
            IPoint[] points = new IPoint[numPoints];
            for (int i = 0; i < numPoints; i++)
            {
                double x = file.ReadDouble();
                double y = file.ReadDouble();
                IPoint point = geometryFactory.CreatePoint(new Coordinate(x, y));                
                points[i] = point;
            }
            geom = geometryFactory.CreateMultiPoint(points);
            GrabZMValues(file);
            return geom;
        }        
開發者ID:ExRam,項目名稱:DotSpatial-PCL,代碼行數:41,代碼來源:MultiPointHandler.cs

示例2: FromStream

 public static Broker FromStream(BigEndianBinaryReader stream)
 {
     return new Broker
         {
             BrokerId = stream.ReadInt32(),
             Host = stream.ReadInt16String(),
             Port = stream.ReadInt32()
         };
 }
開發者ID:jsifantu,項目名稱:kafka-net,代碼行數:9,代碼來源:Broker.cs

示例3: read

 internal void read(BigEndianBinaryReader reader)
 {
     width = reader.ReadInt32();
     height = reader.ReadInt32();
     bitdepth = reader.ReadByte();
     colortype = (ColorType)reader.ReadByte();
     method = reader.ReadByte();
     filter = reader.ReadByte();
     interlace = reader.ReadByte();
 }
開發者ID:Bananattack,項目名稱:ankh,代碼行數:10,代碼來源:png.cs

示例4: Read

        /// <summary>
        /// Reads a stream and converts the shapefile record to an equilivent geometry object.
        /// </summary>
        /// <param name="file">The stream to read.</param>
        /// <param name="geometryFactory">The geometry factory to use when making the object.</param>
        /// <returns>The Geometry object that represents the shape file record.</returns>
        public override IGeometry Read(BigEndianBinaryReader file, IGeometryFactory geometryFactory)
        {
            int shapeTypeNum = file.ReadInt32();
            type = (ShapeGeometryType) Enum.Parse(typeof(ShapeGeometryType), shapeTypeNum.ToString());
            if (type == ShapeGeometryType.NullShape)
                return geometryFactory.CreateMultiLineString(null);

            if (!(type == ShapeGeometryType.LineString  || type == ShapeGeometryType.LineStringM ||
                  type == ShapeGeometryType.LineStringZ || type == ShapeGeometryType.LineStringZM))
                throw new ShapefileException("Attempting to load a non-arc as arc.");

            // Read and for now ignore bounds.            
            int bblength = GetBoundingBoxLength();
            bbox = new double[bblength];
            for (; bbindex < 4; bbindex++)
            {
                double d = file.ReadDouble();
                bbox[bbindex] = d;
            }
        
            int numParts = file.ReadInt32();
            int numPoints = file.ReadInt32();
            int[] partOffsets = new int[numParts];
            for (int i = 0; i < numParts; i++)
                partOffsets[i] = file.ReadInt32();
			
            ILineString[] lines = new ILineString[numParts];			
            for (int part = 0; part < numParts; part++)
            {
                int start, finish, length;
                start = partOffsets[part];
                if (part == numParts - 1)
                     finish = numPoints;
                else finish = partOffsets[part + 1];
                length = finish - start;
                CoordinateList points = new CoordinateList();                
                points.Capacity = length;
                for (int i = 0; i < length; i++)
                {
                    double x = file.ReadDouble();
                    double y = file.ReadDouble();
                    ICoordinate external = new Coordinate(x, y);
                    geometryFactory.PrecisionModel.MakePrecise(external);
                    points.Add(external);				    
                }
                ILineString line = geometryFactory.CreateLineString(points.ToArray());
                lines[part] = line;
            }
            geom = geometryFactory.CreateMultiLineString(lines);
            GrabZMValues(file);
            return geom;
        }
開發者ID:ExRam,項目名稱:DotSpatial-PCL,代碼行數:58,代碼來源:MultiLineHandler.cs

示例5: Read

        /// <summary>
        /// Reads a stream and converts the shapefile record to an equilivent geometry object.
        /// </summary>
        /// <param name="file">The stream to read.</param>
        /// <param name="geometryFactory">The geometry factory to use when making the object.</param>
        /// <returns>The Geometry object that represents the shape file record.</returns>
        public override IGeometry Read(BigEndianBinaryReader file, IGeometryFactory geometryFactory)
        {
            int shapeTypeNum = file.ReadInt32();
            type = (ShapeGeometryType) Enum.Parse(typeof (ShapeGeometryType), shapeTypeNum.ToString());
            if (type == ShapeGeometryType.NullShape)
            {
                ICoordinate emptyCoordinate = null;
                return geometryFactory.CreatePoint(emptyCoordinate);
            }

            if (!(type == ShapeGeometryType.Point  || type == ShapeGeometryType.PointM ||
                  type == ShapeGeometryType.PointZ || type == ShapeGeometryType.PointZM))
                throw new ShapefileException("Attempting to load a point as point.");		    

            double x = file.ReadDouble();
            double y = file.ReadDouble();		    
            ICoordinate external = new Coordinate(x,y);			
            geometryFactory.PrecisionModel.MakePrecise(external);
            IPoint point = geometryFactory.CreatePoint(external);
            if (HasZValue() || HasMValue())
            {
                IDictionary<ShapeGeometryType, double> data = new Dictionary<ShapeGeometryType, double>(2);
                if (HasZValue())
                    GetZValue(file, data);
                if (HasMValue())
                    GetMValue(file, data);
                // point.UserData = data;
            }
            return point;
        }
開發者ID:diegowald,項目名稱:intellitrack,代碼行數:36,代碼來源:PointHandler.cs

示例6: Read

		/// <summary>
		/// Reads a stream and converts the shapefile record to an equilivent geometry object.
		/// </summary>
		/// <param name="file">The stream to read.</param>
		/// <param name="geometryFactory">The geometry factory to use when making the object.</param>
		/// <returns>The Geometry object that represents the shape file record.</returns>
		public override IGeometry Read(BigEndianBinaryReader file, IGeometryFactory geometryFactory)
		{
			int shapeTypeNum = file.ReadInt32();
            ShapeGeometryTypes shapeType = (ShapeGeometryTypes)Enum.Parse(typeof(ShapeGeometryTypes), shapeTypeNum.ToString());
            if( ! ( shapeType == ShapeGeometryTypes.LineString  || shapeType == ShapeGeometryTypes.LineStringM   ||
                    shapeType == ShapeGeometryTypes.LineStringZ || shapeType == ShapeGeometryTypes.LineStringZM  ))
				throw new ShapefileException("Attempting to load a non-arc as arc.");

			//read and for now ignore bounds.
			double[] box = new double[4];
			for (int i = 0; i < 4; i++) 
			{
				double d= file.ReadDouble();
				box[i] =d;
			}
        
			int numParts = file.ReadInt32();
			int numPoints = file.ReadInt32();
			int[] partOffsets = new int[numParts];
			for (int i = 0; i < numParts; i++)
				partOffsets[i] = file.ReadInt32();
			
			ILineString[] lines = new LineString[numParts];
			int start, finish, length;
			for (int part = 0; part < numParts; part++)
			{
				start = partOffsets[part];
				if (part == numParts - 1)
					 finish = numPoints;
				else finish = partOffsets[part + 1];
				length = finish - start;
                CoordinateList points = new CoordinateList();
				Coordinate external;
				for (int i = 0; i < length; i++)
				{
					external = new Coordinate(file.ReadDouble(),file.ReadDouble());
					// points.Add(geometryFactory.PrecisionModel.ToInternal(external));
                    new PrecisionModel(geometryFactory.PrecisionModel).MakePrecise(external);
                    points.Add(external);
				}
				lines[part] = geometryFactory.CreateLineString(points.ToArray());
			}
			return geometryFactory.CreateMultiLineString(lines);
		}
開發者ID:zhongshuiyuan,項目名稱:mapwindowsix,代碼行數:50,代碼來源:MultiLineHandler.cs

示例7: ReadInt32

 /// <summary>
 /// Read an int from the stream.<br/>Tracks how many words (1 word = 2 bytes) we have read and that we do not over read.
 /// </summary>
 /// <param name="file">The reader to use</param>
 /// <param name="totalRecordLength">The total number of words (1 word = 2 bytes) this record has</param>
 /// <param name="totalRead">A word counter</param>
 /// <returns>The value read</returns>
 protected int ReadInt32(BigEndianBinaryReader file, int totalRecordLength, ref int totalRead)
 {
     var newRead = totalRead + 2;
     if (newRead > totalRecordLength)
         throw new Exception("End of data encountered while reading integer");
     
     // track how many bytes we have read to know if we have optional values at the end of the record or not
     totalRead = newRead; 
     return file.ReadInt32();
 }
開發者ID:Walt-D-Cat,項目名稱:NetTopologySuite,代碼行數:17,代碼來源:ShapeHandler.cs

示例8: Read

		/// <summary>
		/// Reads a stream and converts the shapefile record to an equilivant geometry object.
		/// </summary>
		/// <param name="file">The stream to read.</param>
		/// <param name="geometryFactory">The geometry factory to use when making the object.</param>
		/// <returns>The Geometry object that represents the shape file record.</returns>
        public override IGeometry Read(BigEndianBinaryReader file, IGeometryFactory geometryFactory)
        {
            int shapeTypeNum = file.ReadInt32();
            ShapeGeometryTypes shapeType = (ShapeGeometryTypes)Enum.Parse(typeof(ShapeGeometryTypes), shapeTypeNum.ToString());
            if ( ! ( shapeType == ShapeGeometryTypes.MultiPoint  || shapeType == ShapeGeometryTypes.MultiPointM ||
                     shapeType == ShapeGeometryTypes.MultiPointZ || shapeType == ShapeGeometryTypes.MultiPointZM))	
                throw new ShapefileException("Attempting to load a non-multipoint as multipoint.");

            // Read and for now ignore bounds.
            double[] box = new double[4];
            for (int i = 0; i < 4; i++)
                box[i] = file.ReadDouble();

            // Read points
            int numPoints = file.ReadInt32();
            Coordinate[] points = new Coordinate[numPoints];
            for (int i = 0; i < numPoints; i++)
                points[i] = new Coordinate(file.ReadDouble(), file.ReadDouble());
            return geometryFactory.CreateMultiPoint(points);
        }
開發者ID:zhongshuiyuan,項目名稱:mapwindowsix,代碼行數:26,代碼來源:MultiPointHandler.cs

示例9: Int32Tests

        public void Int32Tests(Int32 expectedValue, Byte[] givenBytes)
        {
            // arrange
            var binaryReader = new BigEndianBinaryReader(givenBytes);

            // act
            var actualValue = binaryReader.ReadInt32();

            // assert
            Assert.That(expectedValue, Is.EqualTo(actualValue));
        }
開發者ID:BDeus,項目名稱:KafkaNetClient,代碼行數:11,代碼來源:BigEndianBinaryReaderTests.cs

示例10: Int32Tests

        public void Int32Tests(Int32 expectedValue, Byte[] givenBytes)
        {
            // arrange
            var memoryStream = new MemoryStream(givenBytes);
            var binaryReader = new BigEndianBinaryReader(memoryStream);

            // act
            var actualValue = binaryReader.ReadInt32();

            // assert
            Assert.Equal(expectedValue, actualValue);
        }
開發者ID:rudygt,項目名稱:dot-kafka,代碼行數:12,代碼來源:BigEndianBinaryReaderTests.cs

示例11: FromStream

        public static Partition FromStream(BigEndianBinaryReader stream)
        {
            var partition = new Partition
            {
                ErrorCode = stream.ReadInt16(),
                PartitionId = stream.ReadInt32(),
                LeaderId = stream.ReadInt32(),
                Replicas = new List<int>(),
                Isrs = new List<int>()
            };

            var numReplicas = stream.ReadInt32();
            for (int i = 0; i < numReplicas; i++)
            {
                partition.Replicas.Add(stream.ReadInt32());
            }

            var numIsr = stream.ReadInt32();
            for (int i = 0; i < numIsr; i++)
            {
                partition.Isrs.Add(stream.ReadInt32());
            }

            return partition;
        }
開發者ID:BDeus,項目名稱:KafkaNetClient,代碼行數:25,代碼來源:Topic.cs

示例12: Read

		/// <summary>
		/// Reads a stream and converts the shapefile record to an equilivent geometry object.
		/// </summary>
		/// <param name="file">The stream to read.</param>
		/// <param name="geometryFactory">The geometry factory to use when making the object.</param>
		/// <returns>The Geometry object that represents the shape file record.</returns>
		public override IGeometry Read(BigEndianBinaryReader file, IGeometryFactory geometryFactory)
		{
			int shapeTypeNum = file.ReadInt32();
            ShapeGeometryTypes shapeType = (ShapeGeometryTypes)Enum.Parse(typeof(ShapeGeometryTypes), shapeTypeNum.ToString());
            if (  ( shapeType == ShapeGeometryTypes.LineString  || shapeType == ShapeGeometryTypes.LineStringM   ||
                     shapeType == ShapeGeometryTypes.LineStringZ || shapeType == ShapeGeometryTypes.LineStringZM  ||
                     shapeType == ShapeGeometryTypes.MultiPatch || shapeType == ShapeGeometryTypes.NullShape ||
                     shapeType == ShapeGeometryTypes.Polygon || shapeType == ShapeGeometryTypes.PolygonM ||
                     shapeType == ShapeGeometryTypes.PolygonZ || shapeType == ShapeGeometryTypes.PolygonZM                                  
                     ))	
				throw new ShapefileException("Attempting to load a non-point shapefile as point.");
			double x= file.ReadDouble();
			double y= file.ReadDouble();
			Coordinate external = new Coordinate(x,y);			
			// return geometryFactory.CreatePoint(geometryFactory.PrecisionModel.ToInternal(external));
            new PrecisionModel(geometryFactory.PrecisionModel).MakePrecise(external);
            return geometryFactory.CreatePoint(external);
		}
開發者ID:zhongshuiyuan,項目名稱:mapwindowsix,代碼行數:24,代碼來源:PointHandler.cs

示例13: TROPUSR

        public TROPUSR(string path_in)
        {
            this.path = path_in;
            BigEndianBinaryReader TROPUSRReader = null;

            if (path == null)
                throw new Exception("Path cannot be null!");

            if (!path.EndsWith(@"\"))
                path += @"\";

            if (!File.Exists(path + "TROPUSR.DAT"))
                throw new Exception("Cannot find TROPUSR.DAT.");

            try {
                TROPUSRReader = new BigEndianBinaryReader(new FileStream(path + "TROPUSR.DAT", FileMode.Open));
            } catch (IOException) {
                throw new Exception("Cannot Open TROPUSR.DAT.");
            }

            header = TROPUSRReader.ReadBytes(Marshal.SizeOf(typeof(Header))).ToStruct<Header>();
            if (header.Magic != 0x0000000100ad548f81)
                throw new Exception("Not a vaild TROPUSR.DAT.");

            typeRecordTable = new Dictionary<int, TypeRecord>();
            for (int i = 0; i < header.UnknowCount; i++) {
                TypeRecord TypeRecordTmp = TROPUSRReader.ReadBytes(Marshal.SizeOf(typeof(TypeRecord))).ToStruct<TypeRecord>();
                typeRecordTable.Add(TypeRecordTmp.ID, TypeRecordTmp);
            }

            do {
                // 1 unknow 2 account_id 3 trophy_id and hash(?) 4 trophy info
                //
                int type = TROPUSRReader.ReadInt32();
                int blocksize = TROPUSRReader.ReadInt32();
                int sequenceNumber = TROPUSRReader.ReadInt32(); // if have more than same type block, it will be used
                int unknow = TROPUSRReader.ReadInt32();
                byte[] blockdata = TROPUSRReader.ReadBytes(blocksize);
                switch (type) {
                    case 1: // unknow
                        break;
                    case 2:
                        account_id = Encoding.UTF8.GetString(blockdata, 16, 16);
                        break;
                    case 3:
                        trophy_id = Encoding.UTF8.GetString(blockdata, 0, 16).Trim('\0');
                        short u1 = BitConverter.ToInt16(blockdata, 16).ChangeEndian();
                        short u2 = BitConverter.ToInt16(blockdata, 18).ChangeEndian();
                        short u3 = BitConverter.ToInt16(blockdata, 20).ChangeEndian();
                        short u4 = BitConverter.ToInt16(blockdata, 22).ChangeEndian();
                        all_trophy_number = BitConverter.ToInt32(blockdata, 24).ChangeEndian();
                        int u5 = BitConverter.ToInt32(blockdata, 28).ChangeEndian();
                        AchievementRate[0] = BitConverter.ToUInt32(blockdata, 64);
                        AchievementRate[1] = BitConverter.ToUInt32(blockdata, 68);
                        AchievementRate[2] = BitConverter.ToUInt32(blockdata, 72);
                        AchievementRate[3] = BitConverter.ToUInt32(blockdata, 76);
                        break;
                    case 4:
                        trophyTypeTable.Add(blockdata.ToStruct<TrophyType>());
                        break;
                    case 5:
                        trophyListInfo = blockdata.ToStruct<TrophyListInfo>();
                        break;
                    case 6:
                        trophyTimeInfoTable.Add(blockdata.ToStruct<TrophyTimeInfo>());
                        break;
                    case 7:// unknow
                        unknowType7 = blockdata.ToStruct<UnknowType7>();
                        // Console.WriteLine("Unsupported block type. (Type{0})", type);
                        break;
                    case 8: // hash
                        unknowHash = blockdata.SubArray(0, 20);
                        break;
                    case 9: // 通常寫著白金獎盃的一些數字,不明
                        // Console.WriteLine("Unsupported block type. (Type{0})", type);
                        break;
                    case 10: // i think it just a padding
                        break;
                }

            } while (TROPUSRReader.BaseStream.Position < TROPUSRReader.BaseStream.Length);

            trophyListInfo.ListLastUpdateTime = DateTime.Now;
            TROPUSRReader.Close();
        }
開發者ID:darkautism,項目名稱:TROPHYParser,代碼行數:85,代碼來源:TROPUSR.cs

示例14: Read

 public object Read(MemoryStream buffer)
 {
     var reader = new BigEndianBinaryReader(buffer);
     return reader.ReadInt32();
 }
開發者ID:rudygt,項目名稱:dot-kafka,代碼行數:5,代碼來源:KafkaInt32.cs

示例15: Read

				internal void Read(ushort pc, BigEndianBinaryReader br, ClassFile classFile)
				{
					this.pc = pc;
					ByteCode bc = (ByteCode)br.ReadByte();
					switch(ByteCodeMetaData.GetMode(bc))
					{
						case ByteCodeMode.Simple:
							break;
						case ByteCodeMode.Constant_1:
							arg1 = br.ReadByte();
							classFile.MarkLinkRequiredConstantPoolItem(arg1);
							break;
						case ByteCodeMode.Local_1:
							arg1 = br.ReadByte();
							break;
						case ByteCodeMode.Constant_2:
							arg1 = br.ReadUInt16();
							classFile.MarkLinkRequiredConstantPoolItem(arg1);
							break;
						case ByteCodeMode.Branch_2:
							arg1 = br.ReadInt16();
							break;
						case ByteCodeMode.Branch_4:
							arg1 = br.ReadInt32();
							break;
						case ByteCodeMode.Constant_2_1_1:
							arg1 = br.ReadUInt16();
							classFile.MarkLinkRequiredConstantPoolItem(arg1);
							arg2 = br.ReadByte();
							if(br.ReadByte() != 0)
							{
								throw new ClassFormatError("invokeinterface filler must be zero");
							}
							break;
						case ByteCodeMode.Immediate_1:
							arg1 = br.ReadSByte();
							break;
						case ByteCodeMode.Immediate_2:
							arg1 = br.ReadInt16();
							break;
						case ByteCodeMode.Local_1_Immediate_1:
							arg1 = br.ReadByte();
							arg2 = br.ReadSByte();
							break;
						case ByteCodeMode.Constant_2_Immediate_1:
							arg1 = br.ReadUInt16();
							classFile.MarkLinkRequiredConstantPoolItem(arg1);
							arg2 = br.ReadSByte();
							break;
						case ByteCodeMode.Tableswitch:
						{
							// skip the padding
							uint p = pc + 1u;
							uint align = ((p + 3) & 0x7ffffffc) - p;
							br.Skip(align);
							int default_offset = br.ReadInt32();
							this.arg1 = default_offset;
							int low = br.ReadInt32();
							int high = br.ReadInt32();
							if(low > high || high > 16384L + low)
							{
								throw new ClassFormatError("Incorrect tableswitch");
							}
							SwitchEntry[] entries = new SwitchEntry[high - low + 1];
							for(int i = low; i < high; i++)
							{
								entries[i - low].value = i;
								entries[i - low].target = br.ReadInt32();
							}
							// do the last entry outside the loop, to avoid overflowing "i", if high == int.MaxValue
							entries[high - low].value = high;
							entries[high - low].target = br.ReadInt32();
							this.switch_entries = entries;
							break;
						}
						case ByteCodeMode.Lookupswitch:
						{
							// skip the padding
							uint p = pc + 1u;
							uint align = ((p + 3) & 0x7ffffffc) - p;
							br.Skip(align);
							int default_offset = br.ReadInt32();
							this.arg1 = default_offset;
							int count = br.ReadInt32();
							if(count < 0 || count > 16384)
							{
								throw new ClassFormatError("Incorrect lookupswitch");
							}
							SwitchEntry[] entries = new SwitchEntry[count];
							for(int i = 0; i < count; i++)
							{
								entries[i].value = br.ReadInt32();
								entries[i].target = br.ReadInt32();
							}
							this.switch_entries = entries;
							break;
						}
						case ByteCodeMode.WidePrefix:
							bc = (ByteCode)br.ReadByte();
							// NOTE the PC of a wide instruction is actually the PC of the
//.........這裏部分代碼省略.........
開發者ID:jira-sarec,項目名稱:ICSE-2012-TraceLab,代碼行數:101,代碼來源:ClassFile.cs


注:本文中的BigEndianBinaryReader.ReadInt32方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。