System.IO.BinaryWriter.WriteByte(byte)

Here are the examples of the csharp api System.IO.BinaryWriter.WriteByte(byte) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

19 Source : Utils.cs
with MIT License
from wavesplatform

public static void WriteEvaluatedExpression(this BinaryWriter writer, object o)
        {
            const byte E_LONG = 0;
            const byte E_BYTES = 1;
            const byte E_STRING = 2;

            const byte E_TRUE = 6;
            const byte E_FALSE = 7;

            switch (o)
            {
                case long value:
                    writer.Write(E_LONG);
                    writer.WriteLong(value);
                    break;
                case bool value:
                    writer.WriteByte(value ? E_TRUE : E_FALSE);
                    break;
                case byte[] value:
                    writer.Write(E_BYTES);
                    writer.WriteInt(value.Length);
                    writer.Write(value);
                    break;
                case string value:
                    writer.Write(E_STRING);
                    var encoded = Encoding.UTF8.GetBytes(value);
                    writer.WriteInt(encoded.Length);
                    writer.Write(encoded);
                    break;
                default:
                    throw new ArgumentException("Only long, bool and byte[] entry values supported");
            }
        }

19 Source : Utils.cs
with MIT License
from wavesplatform

public static void Writereplacedet(this BinaryWriter stream, string replacedetId)
        {
            if (string.IsNullOrEmpty(replacedetId) || replacedetId == "WAVES")
            {
                stream.WriteByte(0);
            }
            else
            {
                stream.WriteByte(1);
                var decoded = Base58.Decode(replacedetId);
                stream.Write(decoded, 0, decoded.Length);
            }
        }