本文整理汇总了C#中Stream.WriteInt方法的典型用法代码示例。如果您正苦于以下问题:C# Stream.WriteInt方法的具体用法?C# Stream.WriteInt怎么用?C# Stream.WriteInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream.WriteInt方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteToStream
public override void WriteToStream(Stream aStream)
{
base.WriteToStream (aStream);
aStream.WriteInt (EntityID);
aStream.WriteByte ((byte)Type);
aStream.WriteInt (X);
aStream.WriteInt (Y);
aStream.WriteInt (Z);
}
示例2: Serialize
public override void Serialize(Stream stream, Type type, object value)
{
var array = value as Array;
var elementType = type.GetElementType();
stream.WriteInt(array.Length);
for (int i = 0; i < array.Length; i++)
ctx.Serializer.Serialize_Main(stream, elementType, array.GetValue(i));
}
示例3: Serialize
public override void Serialize(Stream stream, Type type, object value)
{
var collection = (ICollection)value;
Type elementType = GetElementType(type);
stream.WriteInt(collection.Count);
foreach (var item in collection)
ctx.Serializer.Serialize_Main(stream, elementType, item);
}
示例4: Stream
public static void Stream(IEnumerable<HashBlock> hashBlocks, Stream outputStream)
{
outputStream.WriteUInt((uint) hashBlocks.Count());
foreach (HashBlock block in hashBlocks)
{
outputStream.Write(block.Hash, 0, 16);
outputStream.WriteInt(block.Length);
outputStream.WriteLong(block.Offset);
outputStream.WriteUInt(block.Checksum);
}
}
示例5: WriteQueryParameters
/// <summary>
/// Writes the query parameters.
/// </summary>
/// <param name="buffer">The buffer.</param>
protected void WriteQueryParameters(Stream buffer)
{
buffer.WriteConsistency(CqlConsistency);
var flags = (byte)((Parameters != null ? 1 : 0) |
(SkipMetaData ? 2 : 0) |
(PageSize.HasValue ? 4 : 0) |
(PagingState != null ? 8 : 0) |
(SerialConsistency.HasValue ? 16 : 0) |
(ProtocolVersion >= 3 && Timestamp.HasValue ? 32 : 0));
buffer.WriteByte(flags);
if(Parameters != null)
{
buffer.WriteShort((ushort)Parameters.Count);
foreach(var value in Parameters)
buffer.WriteByteArray(value);
}
if(PageSize.HasValue)
buffer.WriteInt(PageSize.Value);
if(PagingState != null)
buffer.WriteByteArray(PagingState);
if(SerialConsistency.HasValue)
buffer.WriteShort((ushort)SerialConsistency.Value);
if(ProtocolVersion >= 3 && Timestamp.HasValue)
buffer.WriteLong(Timestamp.Value.ToTimestamp()*1000); //convert milliseconds to microseconds
}
示例6: SendCopyDelta
private void SendCopyDelta(CopyDelta delta, Stream inputStream, Stream outputStream)
{
if (inputStream.CanSeek == false) throw new IOException("inputStream not seekable");
outputStream.WriteByte(DeltaStreamConstants.COPY_BLOCK_START_MARKER);
outputStream.WriteLong(delta.Offset);
outputStream.WriteInt(delta.Length);
inputStream.Seek(delta.Length, SeekOrigin.Current);
}
示例7: WriteTo
public override void WriteTo(Stream stream, bool writeType, bool writeName)
{
base.WriteTo(stream, writeType, writeName);
stream.WriteByte(ItemType);
stream.WriteInt(Length);
for (int i = 0; i < Length; ++i)
{
Items[i].WriteTo(stream, false, false);
}
}
示例8: SendByteDelta
private void SendByteDelta(ByteDelta delta, Stream inputStream, Stream outputStream)
{
outputStream.WriteByte(DeltaStreamConstants.NEW_BLOCK_START_MARKER);
outputStream.WriteInt(delta.Length);
var buffer = new byte[delta.Length];
inputStream.Seek(delta.Offset, SeekOrigin.Begin);
long totalRead = 0;
while (totalRead < delta.Length)
{
var toRead = (int) MathEx.Bounded(0, StreamChunkSize, delta.Length - totalRead);
int readLength = inputStream.Read(buffer, 0, toRead);
if (readLength == 0 && totalRead < delta.Length)
throw new IOException("Input stream offset out of bounds, or not enough data available");
outputStream.Write(buffer, 0, readLength);
totalRead += readLength;
}
}
示例9: EncodeDisp32
void EncodeDisp32(Stream buffer, byte constant)
{
if (indexReg != null) {
buffer.WriteByte (CombineModRM (MOD_R32_PTR_DISP32, 0x04, constant));
buffer.WriteByte (CombineSib (baseReg.Index, indexReg.Index, scale));
} else {
buffer.WriteByte (CombineModRM (MOD_R32_PTR_DISP32, baseReg.Index, constant));
if (baseReg == ESP)
buffer.WriteByte (0x24);
}
buffer.WriteInt (disp);
}