当前位置: 首页>>代码示例>>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;未经允许,请勿转载。