System.IO.Stream.WriteByte(byte)

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

1148 Examples 7

19 Source : ScriptDataBoolean.cs
with GNU General Public License v3.0
from Bililive

public void WriteTo(Stream stream)
        {
            stream.WriteByte((byte)this.Type);
            stream.WriteByte((byte)(this.Value ? 1 : 0));
        }

19 Source : ScriptDataEcmaArray.cs
with GNU General Public License v3.0
from Bililive

public void WriteTo(Stream stream)
        {
            stream.WriteByte((byte)this.Type);

            {
                var buffer = new byte[sizeof(uint)];
                BinaryPrimitives.WriteUInt32BigEndian(buffer, (uint)this.Value.Count);
                stream.Write(buffer);
            }

            foreach (var item in this.Value)
            {
                // key
                var bytes = Encoding.UTF8.GetBytes(item.Key);
                if (bytes.Length > ushort.MaxValue)
                    throw new AmfException($"Cannot write more than {ushort.MaxValue} into ScriptDataString");

                var buffer = new byte[sizeof(ushort)];
                BinaryPrimitives.WriteUInt16BigEndian(buffer, (ushort)bytes.Length);

                stream.Write(buffer);
                stream.Write(bytes);

                // value
                item.Value.WriteTo(stream);
            }

            stream.Write(new byte[] { 0, 0, 9 });
        }

19 Source : ScriptDataDate.cs
with GNU General Public License v3.0
from Bililive

public void WriteTo(Stream stream)
        {
            var dateTime = (double)this.Value.ToUnixTimeMilliseconds();
            var localDateTimeOffset = (short)this.Value.Offset.TotalMinutes;
            var buffer1 = new byte[sizeof(double)];
            var buffer2 = new byte[sizeof(ushort)];
            BinaryPrimitives.WriteInt64BigEndian(buffer1, BitConverter.DoubleToInt64Bits(dateTime));
            BinaryPrimitives.WriteInt16BigEndian(buffer2, localDateTimeOffset);
            stream.WriteByte((byte)this.Type);
            stream.Write(buffer1);
            stream.Write(buffer2);
        }

19 Source : ScriptDataReference.cs
with GNU General Public License v3.0
from Bililive

public void WriteTo(Stream stream)
        {
            stream.WriteByte((byte)this.Type);

            var buffer = new byte[sizeof(ushort)];
            BinaryPrimitives.WriteUInt16BigEndian(buffer, this.Value);
            stream.Write(buffer);
        }

19 Source : ScriptDataStrictArray.cs
with GNU General Public License v3.0
from Bililive

public void WriteTo(Stream stream)
        {
            stream.WriteByte((byte)this.Type);

            var buffer = new byte[sizeof(uint)];
            BinaryPrimitives.WriteUInt32BigEndian(buffer, (uint)this.Value.Count);
            stream.Write(buffer);

            foreach (var item in this.Value)
                item.WriteTo(stream);
        }

19 Source : ScriptDataString.cs
with GNU General Public License v3.0
from Bililive

public void WriteTo(Stream stream)
        {
            var bytes = Encoding.UTF8.GetBytes(this.Value);
            if (bytes.Length > ushort.MaxValue)
                throw new AmfException($"Cannot write more than {ushort.MaxValue} into ScriptDataString");

            var buffer = new byte[sizeof(ushort)];
            BinaryPrimitives.WriteUInt16BigEndian(buffer, (ushort)bytes.Length);

            stream.WriteByte((byte)this.Type);
            stream.Write(buffer);
            stream.Write(bytes);
        }

19 Source : ScriptDataUndefined.cs
with GNU General Public License v3.0
from Bililive

public void WriteTo(Stream stream) => stream.WriteByte((byte)this.Type);

19 Source : KeyframesScriptDataValue.cs
with GNU General Public License v3.0
from Bililive

[MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static unsafe void WriteStrictArray(Stream stream, uint count)
        {
            stream.WriteByte((byte)ScriptDataType.StrictArray);

            var buffer = new byte[sizeof(uint)];
            BinaryPrimitives.WriteUInt32BigEndian(buffer, count);
            stream.Write(buffer);
        }

19 Source : ScriptDataLongString.cs
with GNU General Public License v3.0
from Bililive

public void WriteTo(Stream stream)
        {
            var bytes = Encoding.UTF8.GetBytes(this.Value);

            var buffer = new byte[sizeof(uint)];
            BinaryPrimitives.WriteUInt32BigEndian(buffer, (uint)bytes.Length);

            stream.WriteByte((byte)this.Type);
            stream.Write(buffer);
            stream.Write(bytes);
        }

19 Source : ScriptDataNumber.cs
with GNU General Public License v3.0
from Bililive

public void WriteTo(Stream stream)
        {
            stream.WriteByte((byte)this.Type);
            var buffer = new byte[sizeof(double)];
            BinaryPrimitives.WriteInt64BigEndian(buffer, BitConverter.DoubleToInt64Bits(this.Value));
            stream.Write(buffer);
        }

19 Source : ScriptDataObject.cs
with GNU General Public License v3.0
from Bililive

public void WriteTo(Stream stream)
        {
            stream.WriteByte((byte)this.Type);

            foreach (var item in this.Value)
            {
                // key
                var bytes = Encoding.UTF8.GetBytes(item.Key);
                if (bytes.Length > ushort.MaxValue)
                    throw new AmfException($"Cannot write more than {ushort.MaxValue} into ScriptDataString");

                var buffer = new byte[sizeof(ushort)];
                BinaryPrimitives.WriteUInt16BigEndian(buffer, (ushort)bytes.Length);

                stream.Write(buffer);
                stream.Write(bytes);

                // value
                item.Value.WriteTo(stream);
            }

            stream.Write(new byte[] { 0, 0, 9 });
        }

19 Source : KeyframesScriptDataValue.cs
with GNU General Public License v3.0
from Bililive

public void WriteTo(Stream stream)
        {
            stream.WriteByte((byte)this.Type);

            var keyframesData = this.KeyframesData;
            var buffer = new byte[sizeof(double)];

            {
                // key
                WriteKey(stream, TimesBytes);

                // array
                WriteStrictArray(stream, (uint)keyframesData.Count);

                // value
                for (var i = 0; i < keyframesData.Count; i++)
                {
                    stream.WriteByte((byte)ScriptDataType.Number);
                    BinaryPrimitives.WriteInt64BigEndian(buffer, BitConverter.DoubleToInt64Bits(keyframesData[i].Time));
                    stream.Write(buffer);
                }
            }

            {
                // key
                WriteKey(stream, FilePositionsBytes);

                // array
                WriteStrictArray(stream, (uint)keyframesData.Count);

                // value
                for (var i = 0; i < keyframesData.Count; i++)
                {
                    stream.WriteByte((byte)ScriptDataType.Number);
                    BinaryPrimitives.WriteInt64BigEndian(buffer, BitConverter.DoubleToInt64Bits(keyframesData[i].FilePosition));
                    stream.Write(buffer);
                }
            }

            {
                // key
                WriteKey(stream, SpacerBytes);

                // array
                var count = 2u * (uint)(MaxDataCount - keyframesData.Count);
                WriteStrictArray(stream, count);

                // value
                BinaryPrimitives.WriteInt64BigEndian(buffer, BitConverter.DoubleToInt64Bits(double.NaN));
                for (var i = 0; i < count; i++)
                {
                    stream.WriteByte((byte)ScriptDataType.Number);
                    stream.Write(buffer);
                }
            }

            stream.Write(EndBytes);
        }

19 Source : RtcpPacket.cs
with MIT License
from BogdanovKirill

protected void Serialize(Stream stream)
        {
            int padding = PaddingFlag ? 1 : 0;

            stream.WriteByte((byte) ((ProtocolVersion << 6) | (padding << 5) | (SourceCount & 0x1F)));
            stream.WriteByte((byte) PayloadType);
            stream.WriteByte((byte) (DwordLength >> 8));
            stream.WriteByte((byte) DwordLength);
        }

19 Source : RtcpReceiverReportPacket.cs
with MIT License
from BogdanovKirill

public new void Serialize(Stream stream)
        {
            base.Serialize(stream);

            stream.WriteByte((byte) (SyncSourceId >> 24));
            stream.WriteByte((byte) (SyncSourceId >> 16));
            stream.WriteByte((byte) (SyncSourceId >> 8));
            stream.WriteByte((byte) SyncSourceId);

            foreach (var report in Reports)
            {
                stream.WriteByte((byte) (report.SyncSourceId >> 24));
                stream.WriteByte((byte) (report.SyncSourceId >> 16));
                stream.WriteByte((byte) (report.SyncSourceId >> 8));
                stream.WriteByte((byte) report.SyncSourceId);

                stream.WriteByte((byte) report.FractionLost);

                stream.WriteByte((byte) (report.replacedulativePacketLost >> 16));
                stream.WriteByte((byte) (report.replacedulativePacketLost >> 8));
                stream.WriteByte((byte) report.replacedulativePacketLost);

                stream.WriteByte((byte) (report.ExtHighestSequenceNumberReceived >> 24));
                stream.WriteByte((byte) (report.ExtHighestSequenceNumberReceived >> 16));
                stream.WriteByte((byte) (report.ExtHighestSequenceNumberReceived >> 8));
                stream.WriteByte((byte) report.ExtHighestSequenceNumberReceived);

                stream.WriteByte((byte) (report.Jitter >> 24));
                stream.WriteByte((byte) (report.Jitter >> 16));
                stream.WriteByte((byte) (report.Jitter >> 8));
                stream.WriteByte((byte) report.Jitter);

                stream.WriteByte((byte) (report.LastNtpTimeSenderReportReceived >> 24));
                stream.WriteByte((byte) (report.LastNtpTimeSenderReportReceived >> 16));
                stream.WriteByte((byte) (report.LastNtpTimeSenderReportReceived >> 8));
                stream.WriteByte((byte) report.LastNtpTimeSenderReportReceived);

                stream.WriteByte((byte) (report.DelaySinceLastTimeSenderReportReceived >> 24));
                stream.WriteByte((byte) (report.DelaySinceLastTimeSenderReportReceived >> 16));
                stream.WriteByte((byte) (report.DelaySinceLastTimeSenderReportReceived >> 8));
                stream.WriteByte((byte) report.DelaySinceLastTimeSenderReportReceived);
            }
        }

19 Source : RtcpSdesChunk.cs
with MIT License
from BogdanovKirill

public void Serialize(Stream stream)
        {
            stream.WriteByte((byte) (SyncSourceId >> 24));
            stream.WriteByte((byte) (SyncSourceId >> 16));
            stream.WriteByte((byte) (SyncSourceId >> 8));
            stream.WriteByte((byte) SyncSourceId);

            foreach (RtcpSdesItem item in Items)
                item.Serialize(stream);
        }

19 Source : RtcpSdesNameItem.cs
with MIT License
from BogdanovKirill

public override void Serialize(Stream stream)
        {
            int domainByteLength = GetDomainLength();
            byte[] domainNameBytes = Encoding.ASCII.GetBytes(DomainName);

            stream.WriteByte(1);
            stream.WriteByte((byte) (domainByteLength + 1));
            stream.Write(domainNameBytes, 0, domainByteLength);
            stream.WriteByte(0);
        }

19 Source : UriHelper.cs
with GNU General Public License v3.0
from bonarr

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);
            }
        }

19 Source : HttpUtility.cs
with MIT License
from bonzaiferroni

private static void urlEncodeChar (char c, Stream result, bool isUnicode)
    {
      if (c > 255) {
        // FIXME: What happens when there is an internal error?
        //if (!isUnicode)
        //  throw new ArgumentOutOfRangeException ("c", c, "c must be less than 256.");

        result.WriteByte ((byte) '%');
        result.WriteByte ((byte) 'u');

        var i = (int) c;
        var idx = i >> 12;
        result.WriteByte ((byte) _hexChars [idx]);

        idx = (i >> 8) & 0x0F;
        result.WriteByte ((byte) _hexChars [idx]);

        idx = (i >> 4) & 0x0F;
        result.WriteByte ((byte) _hexChars [idx]);

        idx = i & 0x0F;
        result.WriteByte ((byte) _hexChars [idx]);

        return;
      }

      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) '%');
        }

        var idx = ((int) c) >> 4;
        result.WriteByte ((byte) _hexChars [idx]);

        idx = ((int) c) & 0x0F;
        result.WriteByte ((byte) _hexChars [idx]);
      }
      else {
        result.WriteByte ((byte) c);
      }
    }

19 Source : HttpUtility.cs
with MIT License
from bonzaiferroni

private static void urlPathEncodeChar (char c, Stream result)
    {
      if (c < 33 || c > 126) {
        var bytes = Encoding.UTF8.GetBytes (c.ToString ());
        foreach (var b in bytes) {
          result.WriteByte ((byte) '%');

          var i = ((int) b) >> 4;
          result.WriteByte ((byte) _hexChars [i]);

          i = ((int) b) & 0x0F;
          result.WriteByte ((byte) _hexChars [i]);
        }
      }
      else if (c == ' ') {
        result.WriteByte ((byte) '%');
        result.WriteByte ((byte) '2');
        result.WriteByte ((byte) '0');
      }
      else {
        result.WriteByte ((byte) c);
      }
    }

19 Source : PbvCompressorLZW.cs
with MIT License
from bradhannah

public bool Decompress(string pInputFileName, string pOutputFileName)
        {
            Stream reader = null;
            Stream writer = null;

            try
            {
                Initialize();
                reader = new FileStream(pInputFileName, FileMode.Open);
                writer = new FileStream(pOutputFileName, FileMode.Create);
                int iNextCode = 256;
                int iNewCode, iOldCode;
                byte bChar;
                int iCurrentCode, iCounter;
                byte[] baDecodeStack = new byte[TABLE_SIZE];

                iOldCode = ReadCode(reader);
                bChar = (byte)iOldCode;
                writer.WriteByte((byte)iOldCode); //write first byte since it is plain ascii

                iNewCode = ReadCode(reader);

                while (iNewCode != MAX_VALUE) //read file all file
                {
                    if (iNewCode >= iNextCode)
                    {
                        //fix for prefix+chr+prefix+char+prefx special case
                        baDecodeStack[0] = bChar;
                        iCounter = 1;
                        iCurrentCode = iOldCode;
                    }
                    else
                    {
                        iCounter = 0;
                        iCurrentCode = iNewCode;
                    }

                    while (iCurrentCode > 255) //decode string by cycling back through the prefixes
                    {
                        //lstDecodeStack.Add((byte)_iaCharTable[iCurrentCode]);
                        //iCurrentCode = _iaPrefixTable[iCurrentCode];
                        baDecodeStack[iCounter] = (byte)_iaCharTable[iCurrentCode];
                        ++iCounter;
                        if (iCounter >= MAX_CODE)
                            throw new Exception("oh crap");
                        iCurrentCode = _iaPrefixTable[iCurrentCode];
                    }

                    baDecodeStack[iCounter] = (byte)iCurrentCode;
                    bChar = baDecodeStack[iCounter]; //set last char used

                    while (iCounter >= 0) //write out decodestack
                    {
                        writer.WriteByte(baDecodeStack[iCounter]);
                        --iCounter;
                    }

                    if (iNextCode <= MAX_CODE) //insert into tables
                    {
                        _iaPrefixTable[iNextCode] = iOldCode;
                        _iaCharTable[iNextCode] = bChar;
                        ++iNextCode;
                    }

                    iOldCode = iNewCode;

                    //if (reader.PeekChar() != 0)
                    iNewCode = ReadCode(reader);
                }
            } catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                if (writer != null)
                    writer.Close();
                File.Delete(pOutputFileName);
                return false;
            }
            finally
            {
                if (reader != null)
                    reader.Close();
                if (writer != null)
                    writer.Close();
            }

            return true;
        }

19 Source : PbvCompressorLZW.cs
with MIT License
from bradhannah

private void WriteCode(Stream pWriter, int pCode)
        {
            _iBitBuffer |= (ulong)pCode << (32 - MAX_BITS - _iBitCounter); //make space and insert new code in buffer
            _iBitCounter += MAX_BITS; //increment bit counter

            while (_iBitCounter >= 8) //write all the bytes we can
            {
                // int temp = (byte)((_iBitBuffer >> 24) & 255);
                pWriter.WriteByte((byte)((_iBitBuffer >> 24) & 255)); //write byte from bit buffer
                _iBitBuffer <<= 8; //remove written byte from buffer
                _iBitCounter -= 8; //decrement counter
            }
        }

19 Source : DERGenerator.cs
with MIT License
from BreezeHub

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);
			}
		}

19 Source : DERGenerator.cs
with MIT License
from BreezeHub

internal static void WriteDerEncoded(
			Stream outStream,
			int tag,
			byte[] bytes)
		{
			outStream.WriteByte((byte)tag);
			WriteLength(outStream, bytes.Length);
			outStream.Write(bytes, 0, bytes.Length);
		}

19 Source : DerObjectIdentifier.cs
with MIT License
from BreezeHub

private void WriteField(
			Stream outputStream,
			BigInteger fieldValue)
		{
			int byteCount = (fieldValue.BitLength + 6) / 7;
			if(byteCount == 0)
			{
				outputStream.WriteByte(0);
			}
			else
			{
				BigInteger tmpValue = fieldValue;
				byte[] tmp = new byte[byteCount];
				for(int i = byteCount - 1; i >= 0; i--)
				{
					tmp[i] = (byte)((tmpValue.IntValue & 0x7f) | 0x80);
					tmpValue = tmpValue.ShiftRight(7);
				}
				tmp[byteCount - 1] &= 0x7f;
				outputStream.Write(tmp, 0, tmp.Length);
			}
		}

19 Source : HexEncoder.cs
with MIT License
from BreezeHub

public int Encode(
			byte[] data,
			int off,
			int length,
			Stream outStream)
		{
			for(int i = off; i < (off + length); i++)
			{
				int v = data[i];

				outStream.WriteByte(encodingTable[v >> 4]);
				outStream.WriteByte(encodingTable[v & 0xf]);
			}

			return length * 2;
		}

19 Source : HexEncoder.cs
with MIT License
from BreezeHub

public int Decode(
			byte[] data,
			int off,
			int length,
			Stream outStream)
		{
			byte b1, b2;
			int outLen = 0;
			int end = off + length;

			while(end > off)
			{
				if(!Ignore((char)data[end - 1]))
				{
					break;
				}

				end--;
			}

			int i = off;
			while(i < end)
			{
				while(i < end && Ignore((char)data[i]))
				{
					i++;
				}

				b1 = decodingTable[data[i++]];

				while(i < end && Ignore((char)data[i]))
				{
					i++;
				}

				b2 = decodingTable[data[i++]];

				if((b1 | b2) >= 0x80)
					throw new IOException("invalid characters encountered in Hex data");

				outStream.WriteByte((byte)((b1 << 4) | b2));

				outLen++;
			}

			return outLen;
		}

19 Source : HexEncoder.cs
with MIT License
from BreezeHub

public int DecodeString(
			string data,
			Stream outStream)
		{
			byte b1, b2;
			int length = 0;

			int end = data.Length;

			while(end > 0)
			{
				if(!Ignore(data[end - 1]))
				{
					break;
				}

				end--;
			}

			int i = 0;
			while(i < end)
			{
				while(i < end && Ignore(data[i]))
				{
					i++;
				}

				b1 = decodingTable[data[i++]];

				while(i < end && Ignore(data[i]))
				{
					i++;
				}

				b2 = decodingTable[data[i++]];

				if((b1 | b2) >= 0x80)
					throw new IOException("invalid characters encountered in Hex data");

				outStream.WriteByte((byte)((b1 << 4) | b2));

				length++;
			}

			return length;
		}

19 Source : FilterStream.cs
with MIT License
from BreezeHub

public override void WriteByte(byte value)
		{
			s.WriteByte(value);
		}

19 Source : TumblerUrlBuilder.cs
with MIT License
from BreezeHub

private static void HttpEncoderUrlEncodeChar(char c, Stream result, bool isUnicode)
		{
			char[] hexChars = "0123456789abcdef".ToCharArray();
			
			if(c > 255)
			{
				//FIXME: what happens when there is an internal error?
				//if (!isUnicode)
				//    throw new ArgumentOutOfRangeException ("c", c, "c must be less than 256");
				int idx;
				int i = (int)c;

				result.WriteByte((byte)'%');
				result.WriteByte((byte)'u');
				idx = i >> 12;
				result.WriteByte((byte)hexChars[idx]);
				idx = (i >> 8) & 0x0F;
				result.WriteByte((byte)hexChars[idx]);
				idx = (i >> 4) & 0x0F;
				result.WriteByte((byte)hexChars[idx]);
				idx = i & 0x0F;
				result.WriteByte((byte)hexChars[idx]);
				return;
			}

			if(c > ' ' && HttpEncoderNotEncoded(c))
			{
				result.WriteByte((byte)c);
				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);
		}

19 Source : ThrottledStream.cs
with GNU General Public License v3.0
from BRH-Media

public override void WriteByte(byte value)
        {
            Throttle(1);
            _baseStream.WriteByte(value);
        }

19 Source : ByteSwapping.cs
with MIT License
from bryanperris

public sealed override void WriteByte(byte value)
        {
            m_BaseStream.WriteByte(value);
        }

19 Source : Asm.cs
with MIT License
from bryanperris

public static Cartridge replacedembleSimpleCartNoMagic(bool swap = false)
        {
            var result = replacedembleCartTypeA(swap);

            /* Dump to file */
            Stream d = new MemoryStream();
            d.Write(result, 0, result.Length);
            d.Position = 0;

            // Clear away the bus configuration
            for (int i = 0; i < 4; i++)
            {
                d.WriteByte(0);
            }

            d.Position = 0;

            return new Cartridge(d);
        }

19 Source : Rdram.cs
with MIT License
from bryanperris

private void WriteRdram8(uint address, byte value) {
            m_MemoryStream.Position = address;
            m_BaseStream.WriteByte(value);
        }

19 Source : CartridgeRomChecksum.cs
with MIT License
from bryanperris

public void UpdateRomChecksum(Stream romSource) {
            romSource.Position = 0x10;

            romSource.WriteByte(m_Hashcode[3]);
            romSource.WriteByte(m_Hashcode[2]);
            romSource.WriteByte(m_Hashcode[1]);
            romSource.WriteByte(m_Hashcode[0]);

            romSource.WriteByte(m_Hashcode[7]);
            romSource.WriteByte(m_Hashcode[6]);
            romSource.WriteByte(m_Hashcode[5]);
            romSource.WriteByte(m_Hashcode[4]);
        }

19 Source : InterpreterBaseRsp.cs
with MIT License
from bryanperris

public override void WriteByte(byte value)
            {
                m_BaseStream.WriteByte(value);
            }

19 Source : RazorTestCase.cs
with MIT License
from bUnit-dev

private string GetUniqueID(ITestMethod testMethod)
		{
			if (testMethod is null)
				throw new ArgumentNullException(nameof(testMethod));

			using var stream = new MemoryStream();
			var replacedemblyName = testMethod.TestClreplaced.TestCollection.Testreplacedembly.replacedembly.Name;

			// Get just the replacedembly name (without version info) when obtained by reflection
			if (testMethod.TestClreplaced.TestCollection.Testreplacedembly.replacedembly is IReflectionreplacedemblyInfo replacedembly)
				replacedemblyName = replacedembly.replacedembly.GetName().Name ?? string.Empty;

			Write(stream, replacedemblyName);
			Write(stream, testMethod.TestClreplaced.Clreplaced.Name);
			Write(stream, TestNumber.ToString(CultureInfo.InvariantCulture));

			stream.Position = 0;

			var hash = new byte[20];
			var data = stream.ToArray();

			var hasher = new Sha1Digest();
			hasher.BlockUpdate(data, 0, data.Length);
			hasher.DoFinal(hash, 0);

			return BytesToHexString(hash);

			static void Write(Stream stream, string value)
			{
				var bytes = Encoding.UTF8.GetBytes(value);
				stream.Write(bytes, 0, bytes.Length);
				stream.WriteByte(0);
			}

			static string BytesToHexString(byte[] bytes)
			{
				var chars = new char[bytes.Length * 2];
				var i = 0;

				foreach (var b in bytes)
				{
					chars[i++] = NibbleToHexChar(b >> 4);
					chars[i++] = NibbleToHexChar(b & 0xF);
				}

				return new string(chars);
			}

			static char NibbleToHexChar(int b)
				=> (char)(b < 10 ? b + '0' : b - 10 + 'a');
		}

19 Source : FontFileStream.cs
with Apache License 2.0
from cajuncoding

public void WriteUShort(int value) {
            stream.WriteByte((byte) ((value >> 8) & 0xFF));
            stream.WriteByte((byte) (value & 0xFF));
        }

19 Source : FontFileStream.cs
with Apache License 2.0
from cajuncoding

public void WriteTag(byte[] value) {
            stream.WriteByte(value[0]);
            stream.WriteByte(value[1]);
            stream.WriteByte(value[2]);
            stream.WriteByte(value[3]);
        }

19 Source : FontFileStream.cs
with Apache License 2.0
from cajuncoding

public int Pad() {
            int remainder = (int) (stream.Position%4);
            for (int i = 0; i < remainder; i++) {
                stream.WriteByte(0);
            }

            return remainder;
        }

19 Source : PdfWriter.cs
with Apache License 2.0
from cajuncoding

public void WriteByte(byte value) {
            stream.WriteByte(value);
            position++;
        }

19 Source : FontFileStream.cs
with Apache License 2.0
from cajuncoding

public void WriteDateTime(long value) {
            stream.WriteByte((byte) ((value >> 56) & 0xFF));
            stream.WriteByte((byte) ((value >> 48) & 0xFF));
            stream.WriteByte((byte) ((value >> 40) & 0xFF));
            stream.WriteByte((byte) ((value >> 32) & 0xFF));
            stream.WriteByte((byte) ((value >> 24) & 0xFF));
            stream.WriteByte((byte) ((value >> 16) & 0xFF));
            stream.WriteByte((byte) ((value >> 8) & 0xFF));
            stream.WriteByte((byte) ((int) value & 0xFF));
        }

19 Source : FontFileStream.cs
with Apache License 2.0
from cajuncoding

public void WriteByte(byte value) {
            stream.WriteByte(value);
        }

19 Source : FontFileStream.cs
with Apache License 2.0
from cajuncoding

public void WriteChar(sbyte value) {
            stream.WriteByte((byte) ((int) value & 0xFF));
        }

19 Source : FontFileStream.cs
with Apache License 2.0
from cajuncoding

public void WriteShort(int value) {
            stream.WriteByte((byte) ((value >> 8) & 0xFF));
            stream.WriteByte((byte) (value & 0xFF));
        }

19 Source : FontFileStream.cs
with Apache License 2.0
from cajuncoding

public void WriteLong(int value) {
            stream.WriteByte((byte) ((value >> 24) & 0xFF));
            stream.WriteByte((byte) ((value >> 16) & 0xFF));
            stream.WriteByte((byte) ((value >> 8) & 0xFF));
            stream.WriteByte((byte) (value & 0xFF));
        }

19 Source : FontFileStream.cs
with Apache License 2.0
from cajuncoding

public void WriteULong(uint value) {
            stream.WriteByte((byte) ((value >> 24) & 0xFF));
            stream.WriteByte((byte) ((value >> 16) & 0xFF));
            stream.WriteByte((byte) ((value >> 8) & 0xFF));
            stream.WriteByte((byte) ((int) value & 0xFF));
        }

19 Source : TftpStreamWriter.cs
with Microsoft Public License
from Callisto82

public void WriteUInt16(ushort value)
        {
            stream.WriteByte((byte)(value >> 8));
            stream.WriteByte((byte)(value & 0xFF));
        }

19 Source : TftpStreamWriter.cs
with Microsoft Public License
from Callisto82

public void WriteByte(byte b)
        {
            stream.WriteByte(b);
        }

19 Source : RangeCoder.cs
with MIT License
from CatLib

public void ShiftLow()
        {
            if ((uint)Low < 0xFF000000 || (uint)(Low >> 32) == 1)
            {
                byte temp = _cache;
                do
                {
                    Stream.WriteByte((byte)(temp + (Low >> 32)));
                    temp = 0xFF;
                }
                while (--_cacheSize != 0);
                _cache = (byte)(((uint)Low) >> 24);
            }
            _cacheSize++;
            Low = ((uint)Low) << 8;
        }

19 Source : MsgPackWriter.cs
with GNU Affero General Public License v3.0
from cc004

public void Write(sbyte x)
		{
			if (x >= -32 && x <= -1)
			{
				_strm.WriteByte((byte)(0xE0 | (byte)x));
				return;
			}
			if (x >= 0 && x <= sbyte.MaxValue)
			{
				_strm.WriteByte((byte)x);
				return;
			}
			byte[] tmp = _tmp;
			tmp[0] = 208;
			tmp[1] = (byte)x;
			_strm.Write(tmp, 0, 2);
		}

See More Examples