本文整理汇总了C#中System.IO.Stream.WriteByte方法的典型用法代码示例。如果您正苦于以下问题:C# Stream.WriteByte方法的具体用法?C# Stream.WriteByte怎么用?C# Stream.WriteByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.Stream
的用法示例。
在下文中一共展示了Stream.WriteByte方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteInt
private static void WriteInt(Stream stream, int value)
{
stream.WriteByte((byte)(value));
stream.WriteByte((byte)(value >> 8));
stream.WriteByte((byte)(value >> 16));
stream.WriteByte((byte)(value >> 24));
}
示例2: Pack
public static void Pack(Stream stream, UInt32 value)
{
if (value > ZMaxValue)
throw new ArgumentOutOfRangeException("value", value, "Must be between 0 and " + ZMaxValue);
byte length;
if (value <= 0x3F) length = 0;
else if (value <= 0x3FFF) length = 1;
else if (value <= 0x3FFFFF) length = 2;
else length = 3;
var b = (byte)(value << 26 >> 24);
b = (byte)(b | length);
stream.WriteByte(b);
if (length == 0) return;
b = (byte)(value << 18 >> 24);
stream.WriteByte(b);
if (length == 1) return;
b = (byte)(value << 10 >> 24);
stream.WriteByte(b);
if (length == 2) return;
b = (byte)(value << 2 >> 24);
stream.WriteByte(b);
}
示例3: WriteInt
public static void WriteInt(Stream outStream,int n)
{
outStream.WriteByte((byte)(n >> 24));
outStream.WriteByte((byte)(n >> 16));
outStream.WriteByte((byte)(n >> 8));
outStream.WriteByte((byte)n);
}
示例4: UrlEncodeChar
static void UrlEncodeChar (char c, Stream result, bool isUnicode) {
if (c > ' ' && NotEncoded (c)) {
result.WriteByte ((byte)c);
return;
}
if (c==' ') {
result.WriteByte ((byte)'+');
return;
}
if ( (c < '0') ||
(c < 'A' && c > '9') ||
(c > 'Z' && c < 'a') ||
(c > 'z')) {
if (isUnicode && c > 127) {
result.WriteByte ((byte)'%');
result.WriteByte ((byte)'u');
result.WriteByte ((byte)'0');
result.WriteByte ((byte)'0');
}
else
result.WriteByte ((byte)'%');
int idx = ((int) c) >> 4;
result.WriteByte ((byte)hexChars [idx]);
idx = ((int) c) & 0x0F;
result.WriteByte ((byte)hexChars [idx]);
}
else {
result.WriteByte ((byte)c);
}
}
示例5: WriteUInt
/// <summary>
/// Write unsigned integer into the stream
/// </summary>
public static void WriteUInt(Stream destination, uint value)
{
destination.WriteByte((byte)value);
destination.WriteByte((byte)(value >> 8));
destination.WriteByte((byte)(value >> 16));
destination.WriteByte((byte)(value >> 24));
}
示例6: WriteValue
public override void WriteValue(Stream stream, object value, SerializerSession session)
{
//null = 0
// [0]
//length < 255 gives length + 1 as a single byte + payload
// [B length+1] [Payload]
//others gives 254 + int32 length + payload
// [B 254] [I Length] [Payload]
if (value == null)
{
stream.WriteByte(0);
}
else
{
var bytes = Encoding.UTF8.GetBytes((string) value);
if (bytes.Length < 255)
{
stream.WriteByte((byte)(bytes.Length+1));
stream.Write(bytes, 0, bytes.Length);
}
else
{
stream.WriteByte(254);
stream.WriteInt32(bytes.Length);
stream.Write(bytes,0,bytes.Length);
}
}
}
示例7: PackU
public static void PackU(Stream stream, UInt32? nullableValue)
{
byte length;
if (!nullableValue.HasValue) {
stream.WriteByte(7);
return;
}
var value = nullableValue.Value;
if (value <= 0x1FU) length = 0;
else if (value <= 0x1FFFU) length = 1;
else if (value <= 0x1FFFFFU) length = 2;
else if (value <= 0x1FFFFFFFU) length = 3;
else length = 4;
var b = (byte)(value << 27 >> 24);
b = (byte)(b | length);
stream.WriteByte(b);
if (length == 0) return;
b = (byte)(value << 19 >> 24);
stream.WriteByte(b);
if (length == 1) return;
b = (byte)(value << 11 >> 24);
stream.WriteByte(b);
if (length == 2) return;
b = (byte)(value << 3 >> 24);
stream.WriteByte(b);
if (length == 3) return;
b = (byte)(value >> 29);
stream.WriteByte(b);
}
示例8: WriteInt
public void WriteInt(uint val, Stream s)
{
s.WriteByte((byte)(0xff & val));
s.WriteByte((byte)(0xff & (val >> 8)));
s.WriteByte((byte)(0xff & (val >> 16)));
s.WriteByte((byte)(0xff & (val >> 24)));
}
示例9: Write
public void Write(Stream fs, bool comFiles)
{
//beginning of the uninstall file info
if (comFiles)
fs.WriteByte(0x8B);
else
fs.WriteByte(0x8A);
//path to the file
WriteFiles.WriteDeprecatedString(fs, 0x01, Path);
//delete the file?
if (DeleteFile)
WriteFiles.WriteBool(fs, 0x02, true);
if (UnNGENFile)
{
WriteFiles.WriteBool(fs, 0x03, true);
// the CPU version of the file to un-ngen
WriteFiles.WriteInt(fs, 0x04, (int) CPUVersion);
WriteFiles.WriteInt(fs, 0x05, (int)FrameworkVersion);
}
if (RegisterCOMDll != COMRegistration.None)
WriteFiles.WriteInt(fs, 0x06, (int) RegisterCOMDll);
//end of uninstall file info
fs.WriteByte(0x9A);
}
示例10: WriteBgra
public static void WriteBgra(Stream output, Color color)
{
output.WriteByte(color.B);
output.WriteByte(color.G);
output.WriteByte(color.R);
output.WriteByte(color.A);
}
示例11: Encode
public void Encode(Stream stream)
{
stream.WriteByte((byte) initialCodeSize);
curPixel = 0;
Compress(initialCodeSize + 1, stream);
stream.WriteByte(GifConstants.terminator);
}
示例12: WriteBeUint32
public static void WriteBeUint32(Stream stm, uint u)
{
stm.WriteByte((byte)(u >> 24));
stm.WriteByte((byte)(u >> 16));
stm.WriteByte((byte)(u >> 8));
stm.WriteByte((byte)(u));
}
示例13: WriteUInt
public static void WriteUInt(Stream stream, uint value)
{
stream.WriteByte((byte) (value & 0xff));
stream.WriteByte((byte) ((value >> 8) & 0xff));
stream.WriteByte((byte) ((value >> 0x10) & 0xff));
stream.WriteByte((byte) ((value >> 0x18) & 0xff));
}
示例14: WriteLength
private static void WriteLength(
Stream outStr,
int length)
{
if (length > 127)
{
int size = 1;
int val = length;
while ((val >>= 8) != 0)
{
size++;
}
outStr.WriteByte((byte)(size | 0x80));
for (int i = (size - 1) * 8; i >= 0; i -= 8)
{
outStr.WriteByte((byte)(length >> i));
}
}
else
{
outStr.WriteByte((byte)length);
}
}
示例15: OutputInt
public static void OutputInt(int n, Stream s)
{
s.WriteByte((byte)(n >> 24));
s.WriteByte((byte)(n >> 16));
s.WriteByte((byte)(n >> 8));
s.WriteByte((byte)n);
}