本文整理匯總了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);
}
示例2: VerticalMetric
public VerticalMetric(BigEndianBinaryReader reader)
{
Contract.Requires(reader != null);
AdvanceHeight = reader.ReadUInt16();
TopSideBearings = reader.ReadInt16();
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}
示例7: EncodingRecord
internal EncodingRecord(BigEndianBinaryReader reader)
{
Contract.Requires(reader != null);
ushort platformID = reader.ReadUInt16();
ushort encodingID = reader.ReadUInt16();
}
示例8: CmapTable
internal CmapTable(BigEndianBinaryReader reader)
{
Contract.Requires(reader != null);
Contract.Requires(reader.BaseStream.CanSeek);
ushort version = reader.ReadUInt16();
ushort numTables = reader.ReadUInt16();
}
示例9: FromStream
public static Broker FromStream(BigEndianBinaryReader stream)
{
return new Broker
{
BrokerId = stream.ReadInt32(),
Host = stream.ReadInt16String(),
Port = stream.ReadInt32()
};
}
示例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);
}
示例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();
}
示例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();
}
示例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));
}
示例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);
}
示例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);
}