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


C# BigEndianBinaryReader類代碼示例

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


BigEndianBinaryReader類屬於命名空間,在下文中一共展示了BigEndianBinaryReader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


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