• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# BigEndianBinaryReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ReadMBRs

        public IEnumerable<MBRInfo> ReadMBRs()
        {
            ThrowIfDisposed();

            BigEndianBinaryReader NewReader = new BigEndianBinaryReader(m_StreamProviderRegistry[StreamTypes.Shape].OpenRead());
            return m_ShapeHandler.ReadMBRs(NewReader);
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:7,代码来源:ShapeReader.cs


示例2: VerticalMetric

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

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


示例3: 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


示例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="totalRecordLength">Total length of the record we are about to read</param>
        /// <param name="factory">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, int totalRecordLength, IGeometryFactory factory)
        {
            int totalRead = 0;
            ShapeGeometryType type = (ShapeGeometryType)ReadInt32(file, totalRecordLength, ref totalRead);
            //type = (ShapeGeometryType) EnumUtility.Parse(typeof (ShapeGeometryType), shapeTypeNum.ToString());
            if (type == ShapeGeometryType.NullShape)
                return factory.CreatePoint((Coordinate)null);

            if (type != ShapeType)
                throw new ShapefileException(string.Format("Encountered a '{0}' instead of a  '{1}'", type, ShapeType));

            CoordinateBuffer buffer = new CoordinateBuffer(1, NoDataBorderValue, true);
            IPrecisionModel precisionModel = factory.PrecisionModel;

            double x = precisionModel.MakePrecise(ReadDouble(file, totalRecordLength, ref totalRead));
            double y = precisionModel.MakePrecise(ReadDouble(file, totalRecordLength, ref totalRead));

            double? z = null, m = null;
            
            // Trond Benum: Let's read optional Z and M values                                
            if (HasZValue() && totalRead < totalRecordLength)
                z = ReadDouble(file, totalRecordLength, ref totalRead);

            if ((HasMValue() || HasZValue()) &&
                (totalRead < totalRecordLength))
                m = ReadDouble(file, totalRecordLength, ref totalRead);

            buffer.AddCoordinate(x, y, z, m);
            return factory.CreatePoint(buffer.ToSequence(factory.CoordinateSequenceFactory));
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:37,代码来源:PointHandler.cs


示例5: 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


示例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();
            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


示例7: EncodingRecord

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

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

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


示例8: 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


示例9: 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


示例10: ReadBundle

        public HgBundle ReadBundle(Stream stream)
        {   
            var uncompressedStream = GetUncompressedStream(stream);
            var binaryReader = new BigEndianBinaryReader(new BufferedStream(new NonClosingStreamWrapper(uncompressedStream), 1024 * 1024));
            var changelog = ReadBundleGroup(binaryReader);
            var manifest = ReadBundleGroup(binaryReader);
            var files = ReadBundleFiles(binaryReader); new List<HgBundleFile>();

            return new HgBundle(changelog, manifest, files);
        }
开发者ID:cornelius90,项目名称:InnovatorAdmin,代码行数:10,代码来源:HgBundleReader.cs


示例11: 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


示例12: ReadDouble

        /// <summary>
        /// Read a double from the stream.<br/>Tracks how many words (1 word = 2 bytes) we have read and than 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 double ReadDouble(BigEndianBinaryReader file, int totalRecordLength, ref int totalRead)
        {
            var newRead = totalRead + 4;
            if (newRead > totalRecordLength)
                throw new Exception("End of data encountered while reading double");

            // 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.ReadDouble();
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:17,代码来源:ShapeHandler.cs


示例13: UInt32Tests

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

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

            // assert
            Assert.That(expectedValue, Is.EqualTo(actualValue));
        }
开发者ID:BDeus,项目名称:KafkaNetClient,代码行数:11,代码来源:BigEndianBinaryReaderTests.cs


示例14: 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


示例15: CharArrayTests

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

            // act
            var actualValue = binaryReader.ReadChars(givenBytes.Length);

            // assert
            Assert.Equal(expectedValue, actualValue);
        }
开发者ID:rudygt,项目名称:dot-kafka,代码行数:12,代码来源:BigEndianBinaryReaderTests.cs


示例16: Read

        public object Read(MemoryStream buffer)
        {
            var reader = new BigEndianBinaryReader(buffer);

            var length = reader.ReadInt16();

            byte[] bytes = new byte[length];

            buffer.Read(bytes, 0, length);

            return Encoding.UTF8.GetString(bytes);
        }
开发者ID:rudygt,项目名称:dot-kafka,代码行数:12,代码来源:KafkaString.cs


示例17: 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


示例18: ReadBundleFiles

        private IEnumerable<HgBundleFile> ReadBundleFiles(BigEndianBinaryReader binaryReader)
        {
            uint fileNameLength;
            while((fileNameLength = binaryReader.ReadUInt32()) != 0)
            {
                var fileNameBytes = binaryReader.ReadBytes((int)fileNameLength - 4 /* For "file name length" value itself */);
                var fileName = hgEncoder.DecodeAsLocal(fileNameBytes);
                var fileGroup = ReadBundleGroup(binaryReader);

                var file = new HgBundleFile(new HgPath(fileName), fileGroup);
                yield return file;
            } // while
        }
开发者ID:cornelius90,项目名称:InnovatorAdmin,代码行数:13,代码来源:HgBundleReader.cs


示例19: ShapefileEnumerator

            /// <summary>
            /// Initializes a new instance of the ShapefileEnumerator class.
            /// </summary>
            /// <param name="shapefile"></param>
            public ShapefileEnumerator(ShapeReader shapefile)
            {                
                _parent = shapefile;

                // create a file stream for each enumerator that is given out. This allows the same file
                // to have one or more enumerator. If we used the parents stream - than only one IEnumerator 
                // could be given out.
                FileStream stream = new FileStream(_parent._filename, System.IO.FileMode.Open, FileAccess.Read, FileShare.Read);
                _shpBinaryReader = new BigEndianBinaryReader(stream);

                // skip header - since parent has already read this.
                _shpBinaryReader.ReadBytes(100);
                ShapeGeometryTypes type = _parent._mainHeader.ShapeType;
                _handler = Shapefile.GetShapeHandler(type);
                if (_handler == null) 
                    throw new NotSupportedException("Unsuported shape type:" + type);
            }
开发者ID:zhongshuiyuan,项目名称:mapwindowsix,代码行数:21,代码来源:ShapeReader.cs


示例20: 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="totalRecordLength">Total length of the record we are about 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, int totalRecordLength, IGeometryFactory geometryFactory)
        {
            int totalRead = 0;
            int shapeTypeNum = ReadInt32(file, totalRecordLength, ref totalRead);

            var type = (ShapeGeometryType) EnumUtility.Parse(typeof(ShapeGeometryType), shapeTypeNum.ToString());
            if (type == ShapeGeometryType.NullShape)
                return geometryFactory.CreateMultiPoint(new IPoint[] { });

            if (type != ShapeType)
                throw new ShapefileException(string.Format("Encountered a '{0}' instead of a  '{1}'", type, ShapeType));

            // Read and for now ignore bounds.
            int bblength = GetBoundingBoxLength();
            boundingBox = new double[bblength];
            for (; boundingBoxIndex < 4; boundingBoxIndex++)
            {
                double d = ReadDouble(file, totalRecordLength, ref totalRead);
                boundingBox[boundingBoxIndex] = d;
            }

            // Read points
            var numPoints = ReadInt32(file, totalRecordLength, ref totalRead);
            var buffer = new CoordinateBuffer(numPoints, NoDataBorderValue, true);
            var points = new IPoint[numPoints];
            var pm = geometryFactory.PrecisionModel;

            for (var i = 0; i < numPoints; i++)
            {
                var x = pm.MakePrecise(ReadDouble(file, totalRecordLength, ref totalRead));
                var y = pm.MakePrecise(ReadDouble(file, totalRecordLength, ref totalRead));
                buffer.AddCoordinate(x, y);
                buffer.AddMarker();
            }

            // Trond Benum: We have now read all the points, let's read optional Z and M values            
            GetZMValues(file, totalRecordLength, ref totalRead, buffer);            

            var sequences = buffer.ToSequences(geometryFactory.CoordinateSequenceFactory);
            for (var i = 0; i < numPoints; i++)
                points[i] = geometryFactory.CreatePoint(sequences[i]);
         
            geom = geometryFactory.CreateMultiPoint(points);
          
            return geom;
        }        
开发者ID:sridhar19091986,项目名称:sharpmapx,代码行数:53,代码来源:MultiPointHandler.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BigEndianStream类代码示例发布时间:2022-05-24
下一篇:
C# BigDecimal类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap