本文整理汇总了C#中ByteOrder类的典型用法代码示例。如果您正苦于以下问题:C# ByteOrder类的具体用法?C# ByteOrder怎么用?C# ByteOrder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ByteOrder类属于命名空间,在下文中一共展示了ByteOrder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DataReader
public DataReader(Stream stream)
{
mStream = new BinaryReader(stream);
if (!BitConverter.IsLittleEndian) {
byteOrder = ByteOrder.Big;
}
}
开发者ID:qq573011406,项目名称:UnityAssetTool,代码行数:7,代码来源:DataReader.cs
示例2: GetBytes
/// <summary>
/// Splits number into the byte array
/// </summary>
/// <param name="number">Value to split</param>
/// <param name="outputArray">Array where the bytes be stored</param>
/// <param name="byteOrder">Byte order of the array</param>
public static void GetBytes(long number, byte[] outputArray, ByteOrder byteOrder)
{
if (byteOrder == ByteOrder.BigEndian)
ToBigEndian(number, outputArray);
else
throw new NotImplementedException(Resources.StringResources.NotImplementedLittleEndian.ToString());
}
开发者ID:PavelBansky,项目名称:microframework,代码行数:13,代码来源:Endianity.cs
示例3: GetValue
/// <summary>
/// Get value from the byte array
/// </summary>
/// <param name="byteArray">Byte array</param>
/// <param name="startIndex">Start index in array</param>
/// <param name="length">Number of bytes to parse</param>
/// <param name="byteOrder">Byte order</param>
/// <returns>Long value</returns>
public static long GetValue(byte[] byteArray, int startIndex, int length, ByteOrder byteOrder)
{
if (byteOrder == ByteOrder.BigEndian)
return FromBigEndian(byteArray, startIndex, length);
else
throw new NotImplementedException(Resources.StringResources.NotImplementedLittleEndian.ToString());
}
开发者ID:PavelBansky,项目名称:microframework,代码行数:15,代码来源:Endianity.cs
示例4: PrimitiveElementAttribute
public PrimitiveElementAttribute(int serializationOrder, ByteOrder dataByteOrder)
{
Require.That("serializationOrder", serializationOrder >= 0);
SerializationOrder = serializationOrder;
DataByteOrder = dataByteOrder;
}
开发者ID:mattchamb,项目名称:Construct.NET,代码行数:7,代码来源:PrimitiveElementAttribute.cs
示例5: Read16Bits
public static UInt16 Read16Bits(I2cDevice device, byte reg, ByteOrder byteOrder, string exceptionMessage)
{
try
{
byte[] addr = { reg };
byte[] data = new byte[2];
device.WriteRead(addr, data);
switch (byteOrder)
{
case ByteOrder.BigEndian:
return (UInt16)((data[0] << 8) | data[1]);
case ByteOrder.LittleEndian:
return (UInt16)((data[1] << 8) | data[0]);
default:
throw new SensorException($"Unsupported byte order {byteOrder}");
}
}
catch (Exception exception)
{
throw new SensorException(exceptionMessage, exception);
}
}
开发者ID:harshatech2012,项目名称:RPi.SenseHat,代码行数:27,代码来源:I2CSupport.cs
示例6: BytesToInt32
public static int BytesToInt32(byte[] bytes, ByteOrder byteOrder)
{
if (byteOrder == ByteOrder.BigEndian)
Array.Reverse(bytes);
return BitConverter.ToInt32(bytes, 0);
}
开发者ID:shincfk,项目名称:shooter-downloader,代码行数:7,代码来源:Util.cs
示例7: OtfHeaderDecoder
/// <summary>
/// Read the message header structure and cache the meta data for finding the key fields for decoding messages.
/// </summary>
/// <param name="headerStructure"> for the meta data describing the message header. </param>
public OtfHeaderDecoder(HeaderStructure headerStructure)
{
_size = headerStructure.Tokens[0].Size;
foreach (Token token in headerStructure.Tokens)
{
switch (token.Name)
{
case HeaderStructure.BlockLength:
_blockLengthOffset = token.Offset;
_blockLengthType = token.Encoding.PrimitiveType;
_blockLengthByteOrder = token.Encoding.ByteOrder;
break;
case HeaderStructure.TemplateId:
_templateIdOffset = token.Offset;
_templateIdType = token.Encoding.PrimitiveType;
_templateIdByteOrder = token.Encoding.ByteOrder;
break;
case HeaderStructure.SchemaId:
_schemaIdOffset = token.Offset;
_schemaIdType = token.Encoding.PrimitiveType;
_schemaIdByteOrder = token.Encoding.ByteOrder;
break;
case HeaderStructure.SchemaVersion:
_schemaVersionOffset = token.Offset;
_schemaVersionType = token.Encoding.PrimitiveType;
_schemaVersionByteOrder = token.Encoding.ByteOrder;
break;
}
}
}
开发者ID:nivertech,项目名称:simple-binary-encoding,代码行数:38,代码来源:OtfHeaderDecoder.cs
示例8: EmptyByteBuffer
EmptyByteBuffer(IByteBufferAllocator allocator, ByteOrder order)
{
Contract.Requires(allocator != null);
this.allocator = allocator;
this.order = order;
this.str = this.GetType().Name + (order == ByteOrder.BigEndian ? "BE" : "LE");
}
开发者ID:ktj007,项目名称:DotNetty,代码行数:8,代码来源:EmptyByteBuffer.cs
示例9: DataBuffer
/// <summary>
/// Initializes a new instance of the <see cref="DataBuffer"/> class.
/// </summary>
/// <param name="capacity">The capacity of the new instance.</param>
/// <param name="mode">The endianness mode of the new instance.</param>
public DataBuffer(int capacity, ByteOrder mode)
{
Contract.Requires(capacity > 0);
Contract.Ensures(this.Position == 0);
this.data = new byte[capacity];
this.Mode = mode;
}
开发者ID:eriser,项目名称:nsynth,代码行数:13,代码来源:DataBuffer.cs
示例10: Create
/// <summary>Create a <see cref="BinaryReader"/> or a <see cref="BigEndianBinaryReader"/> based upon a <see cref="ByteOrder"/>.</summary>
/// <param name="byteOrder"></param>
/// <param name="input"></param>
/// <returns></returns>
public static BinaryReader Create(ByteOrder byteOrder, Stream input)
{
switch (byteOrder) {
case ByteOrder.LittleEndian: return new BinaryReader(input);
case ByteOrder.BigEndian: return new BigEndianBinaryReader(input);
default: throw new NotSupportedException();
}
}
开发者ID:Burton-Radons,项目名称:Alexandria,代码行数:12,代码来源:BigEndianBinaryReader.cs
示例11: ToURational
/// <summary>
/// Returns an unsigned rational number converted from the first
/// eight bytes of the given byte array. The first four bytes are
/// assumed to be the numerator and the next four bytes are the
/// denumerator.
/// Numbers are converted from the given byte-order to platform byte-order.
/// </summary>
public static MathEx.UFraction32 ToURational(byte[] data, ByteOrder frombyteorder)
{
byte[] num = new byte[4];
byte[] den = new byte[4];
Array.Copy(data, 0, num, 0, 4);
Array.Copy(data, 4, den, 0, 4);
return new MathEx.UFraction32(ToUInt32(num, 0, frombyteorder, ByteOrder.System), ToUInt32(den, 0, frombyteorder, ByteOrder.System));
}
开发者ID:noahzaozao,项目名称:UnityAdmobAppEventDemo,代码行数:15,代码来源:ExifBitConverter.cs
示例12: ByteReader
/// <summary>
/// Creates a new instance of ByteReader with UTF-8 encoding.
/// </summary>
/// <param name="message">The bytes to read from</param>
public ByteReader(byte[] message)
{
_message = message;
_position = 0;
if (_byteOrder == ByteOrder.Default)
_byteOrder = _defaultByteOrder;
}
开发者ID:marinehero,项目名称:microserver,代码行数:12,代码来源:ByteReader.cs
示例13: CoalescedFileXml
public CoalescedFileXml(List<FileEntry> files = null, IEnumerable<int> compileTypes = null, ByteOrder byteOrder = ByteOrder.LittleEndian, int overrideCompileValueTypes = -1, uint version = 0)
{
ByteOrder = byteOrder;
Files = files ?? new List<FileEntry>();
OverrideCompileValueTypes = overrideCompileValueTypes;
Version = version;
CompileTypes = compileTypes ?? new[] { 0, 1, 2, 3, 4 };
}
开发者ID:ME3Explorer,项目名称:ME3Explorer,代码行数:8,代码来源:CoalescedFileXml.cs
示例14: GetBytes
/// <summary>
/// Converts the given signed rational number to an array of bytes.
/// Numbers are converted from the platform byte-order to the given byte-order.
/// </summary>
public static byte[] GetBytes(MathEx.Fraction32 value, ByteOrder tobyteorder)
{
byte[] num = GetBytes(value.Numerator, ByteOrder.System, tobyteorder);
byte[] den = GetBytes(value.Denominator, ByteOrder.System, tobyteorder);
byte[] data = new byte[8];
Array.Copy(num, 0, data, 0, 4);
Array.Copy(den, 0, data, 4, 4);
return data;
}
开发者ID:Kyeong-min,项目名称:graduation-work-webapi,代码行数:13,代码来源:ExifBitConverter.cs
示例15: ToHostOrder
public static byte[] ToHostOrder(this byte[] src, ByteOrder srcOrder)
{
if (src == null)
return null;
return src.Length > 1 && !srcOrder.IsHostOrder()
? src.CopyReverse()
: src;
}
开发者ID:jerriclynsjohn,项目名称:WebSocket.Portable,代码行数:9,代码来源:ByteExtensions.cs
示例16: MapByteOrder
public static ByteOrderCodec MapByteOrder(ByteOrder byteOrder)
{
if (byteOrder == ByteOrder.BigEndian)
{
return ByteOrderCodec.SBE_BIG_ENDIAN;
}
return ByteOrderCodec.SBE_LITTLE_ENDIAN;
}
开发者ID:kingula,项目名称:simple-binary-encoding,代码行数:9,代码来源:IrUtil.cs
示例17: ByteWriter
public ByteWriter(Stream s, ByteOrder byteOrder, Encoding encoding)
: this(s)
{
_byteOrder = byteOrder;
_encoding = encoding;
if (_byteOrder == ByteOrder.Default)
_byteOrder = _defaultByteOrder;
}
开发者ID:marinehero,项目名称:microserver,代码行数:9,代码来源:ByteWriter.cs
示例18: BOutput
public BOutput(BTransport transport, BRegistry registry, int streamHeaderMagic, int negotiatedBypsVersion, long negotiatedVersion, ByteOrder negotiatedByteOrder)
{
this.objMap = transport.getApiDesc().uniqueObjects ? null : new BObjMap();
this.header = new BMessageHeader(streamHeaderMagic, negotiatedBypsVersion, negotiatedVersion, negotiatedByteOrder, transport.getWire().makeMessageId());
this.header.targetId = transport.getTargetId();
this.header.sessionId = transport.getSessionId();
this.transport = transport;
this.registry = registry;
this.streams = null;
}
开发者ID:marcarvalho,项目名称:byps,代码行数:10,代码来源:BOutput.cs
示例19: ByteWriter
public ByteWriter(int capacity)
{
_byteOrder = ByteOrder.Default;
#if(MF)
_stream = new MemoryStream();
#else
//_stream = new MemoryStream(capacity);
#endif
}
开发者ID:RasmusTG,项目名称:HomeAlarmPlusPi,代码行数:10,代码来源:ByteWriter.cs
示例20: BinaryFile
public BinaryFile(byte[] byteArray, ByteOrder byteOrder)
{
this.memStream = new MemoryStream(byteArray);
this.binaryReader = new BinaryReader(memStream);
// Set position to the beginning of the stream.
this.memStream.Position = 0;
this.byteOrder = byteOrder;
}
开发者ID:jeanibarz,项目名称:REWEQ2EQPreset,代码行数:10,代码来源:BinaryFile.cs
注:本文中的ByteOrder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论