本文整理汇总了C#中Stream.WriteBytes方法的典型用法代码示例。如果您正苦于以下问题:C# Stream.WriteBytes方法的具体用法?C# Stream.WriteBytes怎么用?C# Stream.WriteBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream.WriteBytes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveToStream
protected override void SaveToStream(Stream stream)
{
if (Version==0 &&
(_CreationTime > uint.MaxValue ||
_ModificationTime > uint.MaxValue ||
Duration > uint.MaxValue)) Version = 1;
base.SaveToStream(stream);
if (Version == 1)
{
stream.WriteBEUInt64(_CreationTime);
stream.WriteBEUInt64(_ModificationTime);
stream.WriteBEUInt32(TimeScale);
stream.WriteBEUInt64(Duration);
}
else // if(Version == 0)
{
stream.WriteBEUInt32(checked((uint)_CreationTime));
stream.WriteBEUInt32(checked((uint)_ModificationTime));
stream.WriteBEUInt32(TimeScale);
stream.WriteBEUInt32(checked((uint)Duration));
}
stream.WriteBEInt32(_Rate);
stream.WriteBEInt16(_Volume);
stream.WriteBytes(Reserved);
for (int i = 0; i < 9; i++) stream.WriteBEInt32(Matrix[i]);
stream.WriteBytes(PreDefined);
stream.WriteBEUInt32(NextTrackID);
}
示例2: SaveToStream
protected override void SaveToStream(Stream stream)
{
base.SaveToStream(stream);
stream.WriteBytes(MajorBrand.GetBytes());
stream.WriteBEUInt32(MinorVersion);
foreach (FourCC compatibleBrand in _CompatibleBrands)
{
stream.WriteBytes(compatibleBrand.GetBytes());
}
}
示例3: WriteToStream
public override void WriteToStream(Stream outputStream)
{
outputStream
.WriteBytes((Byte)ASCIIBytes.p)
.WriteInt32(4 + password.Length)
.WriteBytes(password);
}
示例4: WriteToStream
public override void WriteToStream(Stream outputStream)
{
outputStream
.WriteBytes((byte)FrontEndMessageCode.Describe)
.WriteInt32(_messageLength)
.WriteBytes((byte)_whatToDescribe)
.WriteBytesNullTerminated(_bPortalName);
}
示例5: WriteToStream
public override void WriteToStream(Stream outputStream)
{
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "WriteToStream");
outputStream
.WriteBytes((Byte)ASCIIBytes.p)
.WriteInt32(4 + password.Length)
.WriteBytes(password);
}
示例6: WriteBeginRequest
private static void WriteBeginRequest(Stream Stream)
{
Stream.WriteBytes(new byte[]
{
1, // Version
(byte)Fastcgi.PacketType.FCGI_BEGIN_REQUEST, // Type
0, 1, // RequestId
0, 8, // Content Length
0, // Padding Length
0, // Reserved
1, 2, 3, 4, 5, 6, 7, 8, // Data
});
}
示例7: Encode
public static void Encode(Image image, Stream stream)
{
stream.WriteString(image.Header);
stream.WriteBytes(image.LogicalScreenDescriptor.ToBytes());
if (image.LogicalScreenDescriptor.GlobalColorTableFlag)
{
stream.WriteBytes(image.GlobalColorTable);
}
foreach (var applicationExtension in image.ApplictionExtensions)
{
stream.WriteBytes(applicationExtension.ToBytes());
}
foreach (var commentExtension in image.CommentExtensions)
{
stream.WriteBytes(commentExtension.ToBytes());
}
WriteFrames(image.Frames, stream);
}
示例8: WriteFrames
private static void WriteFrames(IEnumerable<ImageFrame> frames, Stream stream)
{
foreach (var frame in frames)
{
var frameBytes = new List<byte>();
if (frame.GraphicControlExtension != null)
{
frameBytes.AddRange(frame.GraphicControlExtension.ToBytes());
}
frame.ImageDescriptor.SortFlag = false;
frame.ImageDescriptor.InterlaceFlag = false;
frameBytes.AddRange(frame.ImageDescriptor.ToBytes());
if (frame.ImageDescriptor.LocalColorTableFlag)
{
frameBytes.AddRange(frame.LocalColorTable);
}
stream.WriteBytes(frameBytes.ToArray());
var transparentColorIndex = -1;
if (frame.GraphicControlExtension != null && frame.GraphicControlExtension.TransparentColorFlag)
{
transparentColorIndex = frame.GraphicControlExtension.TransparentColorIndex;
}
var imageData = GetImageData(frame.Bitmap, frame.LocalColorTable, transparentColorIndex);
var lzwEncoder = new LzwEncoder(imageData, (byte) frame.ColorDepth);
lzwEncoder.Encode(stream);
stream.WriteByte(Const.BlockTerminator);
}
stream.WriteByte(Const.EndIntroducer);
}
示例9: DecryptIplToMemory
/// <summary>
///
/// </summary>
/// <param name="IplData"></param>
/// <param name="OutputStream"></param>
/// <param name="ToMemoryAddress"></param>
/// <returns></returns>
public static IplInfo DecryptIplToMemory(byte[] IplData, Stream OutputStream, bool ToMemoryAddress = true)
{
var buffer = new byte[0x1000];
var IplInfo = default(IplInfo);
//ArrayUtils.HexDump(IplData);
fixed (byte* IplPtr = IplData)
fixed (byte* bufferPtr = buffer)
{
for (int n = 0; n < IplData.Length; n += 0x1000)
{
var Ptr = IplPtr + n;
var Header = *(Kirk.AES128CMACHeader*)Ptr;
//Console.WriteLine(Header.DataSize);
var Kirk = new Kirk();
Kirk.kirk_init();
Kirk.kirk_CMD1(bufferPtr, Ptr, 0x1000, do_check: false);
var IplBlock = *(IplBlock*)bufferPtr;
//Console.WriteLine(IplBlock.ToStringDefault());
if (ToMemoryAddress)
{
OutputStream.Position = IplBlock.LoadAddress;
Console.WriteLine("IplBlock.LoadAddress: 0x{0:X8}", IplBlock.LoadAddress);
}
OutputStream.WriteBytes(PointerUtils.PointerToByteArray(&IplBlock.BlockData, (int)IplBlock.BlockSize));
if (IplBlock.EntryFunction != 0)
{
IplInfo.EntryFunction = IplBlock.EntryFunction;
}
}
}
return IplInfo;
}
示例10: EncodeBits
private void EncodeBits(Stream stream, BitEncoder bitEncoder, int suffix)
{
bitEncoder.Add(suffix);
bitEncoder.Add(this.endCode);
bitEncoder.End();
if (bitEncoder.Length > 255)
{
var leftBuffer = new byte[bitEncoder.Length - 255];
bitEncoder.CopyTo(255, leftBuffer, 0, leftBuffer.Length);
bitEncoder.Clear();
bitEncoder.AddRange(leftBuffer);
stream.WriteByte((byte) leftBuffer.Length);
stream.WriteBytes(leftBuffer);
}
else
{
stream.WriteByte((byte) (bitEncoder.Length));
stream.WriteBytes(bitEncoder.ToArray());
bitEncoder.Clear();
}
}
示例11: concatenateFragmentsInto
private bool concatenateFragmentsInto(Stream destination)
{
while (true) {
var frame = WebSocketFrame.Read (_stream, false);
var msg = checkIfValidReceivedFrame (frame);
if (msg != null)
return processUnsupportedFrame (frame, CloseStatusCode.ProtocolError, msg);
frame.Unmask ();
if (frame.IsFinal) {
/* FINAL */
// CONT
if (frame.IsContinuation) {
destination.WriteBytes (frame.PayloadData.ApplicationData);
break;
}
// PING
if (frame.IsPing) {
processPingFrame (frame);
continue;
}
// PONG
if (frame.IsPong) {
processPongFrame (frame);
continue;
}
// CLOSE
if (frame.IsClose)
return processCloseFrame (frame);
}
else {
/* MORE */
// CONT
if (frame.IsContinuation) {
destination.WriteBytes (frame.PayloadData.ApplicationData);
continue;
}
}
// ?
return processUnsupportedFrame (
frame,
CloseStatusCode.UnsupportedData,
"Unsupported data has been received while receiving the fragmented data.");
}
return true;
}
示例12: SaveToStream
protected override void SaveToStream(Stream stream)
{
base.SaveToStream(stream);
stream.WriteBytes(Format.GetBytes());
}
示例13: Serialize
//.........这里部分代码省略.........
var sectionDataOffset = 2 + (file.Sections.Count * 6);
var sections = new List<KeyValuePair<ushort, int>>();
foreach (var section in file.Sections.OrderBy(s => keys.IndexOf(s.Key)))
{
sections.Add(new KeyValuePair<ushort, int>(
(ushort)keys.IndexOf(section.Key), sectionDataOffset));
var valueDataOffset = 2 + (section.Value.Count * 6);
var values = new List<KeyValuePair<ushort, int>>();
foreach (var value in section.Value.OrderBy(v => keys.IndexOf(v.Key)))
{
index.Position = fileDataOffset + sectionDataOffset + valueDataOffset;
values.Add(new KeyValuePair<ushort, int>(
(ushort)keys.IndexOf(value.Key), valueDataOffset));
index.WriteValueU16((ushort)value.Value.Count, endian);
valueDataOffset += 2;
foreach (var item in value.Value)
{
if (item.Type == 1)
{
index.WriteValueS32((1 << 29) | bitOffset, endian);
}
else if (item.Type == 0 || item.Type == 2 || item.Type == 3 || item.Type == 4)
{
index.WriteValueS32((item.Type << 29) | bitOffset, endian);
bitOffset += huffmanEncoder.Encode((item.Value ?? "") + '\0', bits, bitOffset);
}
valueDataOffset += 4;
}
}
index.Position = fileDataOffset + sectionDataOffset;
index.WriteValueU16((ushort)values.Count, endian);
sectionDataOffset += 2;
foreach (var value in values)
{
index.WriteValueU16(value.Key, endian);
index.WriteValueS32(value.Value, endian);
sectionDataOffset += 6;
}
sectionDataOffset += valueDataOffset;
}
index.Position = fileDataOffset;
index.WriteValueU16((ushort)sections.Count, endian);
fileDataOffset += 2;
foreach (var section in sections)
{
index.WriteValueU16(section.Key, endian);
index.WriteValueS32(section.Value, endian);
fileDataOffset += 6;
}
fileDataOffset += sectionDataOffset;
}
index.Position = 0;
index.WriteValueU16((ushort)files.Count, endian);
foreach (var file in files)
{
index.WriteValueU16(file.Key, endian);
index.WriteValueS32(file.Value, endian);
}
index.Position = 0;
indexSize = (uint)index.Length;
output.Seek(headerSize + stringTableSize + huffmanSize, SeekOrigin.Begin);
output.WriteFromStream(index, index.Length);
}
output.Seek(headerSize + stringTableSize + huffmanSize + indexSize, SeekOrigin.Begin);
output.WriteValueS32(bits.Length, endian);
var bytes = new byte[(bits.Length - 1) / 8 + 1];
bits.CopyTo(bytes, 0);
output.WriteBytes(bytes);
output.Seek(8, SeekOrigin.Begin);
output.WriteValueS32(maxKeyLength, endian);
output.WriteValueS32(maxValueLength, endian);
output.WriteValueU32(stringTableSize, endian);
output.WriteValueU32(huffmanSize, endian);
output.WriteValueU32(indexSize, endian);
output.WriteValueS32(bytes.Length, endian);
output.Seek(0, SeekOrigin.Begin);
output.WriteValueU32(0x666D726D, endian);
}
示例14: AppendParameterValue
private void AppendParameterValue(Stream dest, NpgsqlParameter parameter)
{
byte[] serialised = parameter.TypeInfo.ConvertToBackend(parameter.NpgsqlValue, false, Connector.NativeToBackendTypeConverterOptions);
// Add parentheses wrapping parameter value before the type cast to avoid problems with Int16.MinValue, Int32.MinValue and Int64.MinValue
// See bug #1010543
// Check if this parenthesis can be collapsed with the previous one about the array support. This way, we could use
// only one pair of parentheses for the two purposes instead of two pairs.
dest
.WriteBytes((byte)ASCIIBytes.ParenLeft)
.WriteBytes((byte)ASCIIBytes.ParenLeft)
.WriteBytes(serialised)
.WriteBytes((byte)ASCIIBytes.ParenRight);
if (parameter.UseCast)
{
dest.WriteString("::{0}", parameter.TypeInfo.CastName);
if (parameter.TypeInfo.UseSize && (parameter.Size > 0))
{
dest.WriteString("({0})", parameter.Size);
}
}
dest.WriteBytes((byte)ASCIIBytes.ParenRight);
}
示例15: WriteToStream
public override void WriteToStream(Stream outputStream)
{
outputStream.WriteBytes(pgCommandBytes);
}