public static void Write(this byte[] buffer, ref int offset, IEnumerable <byte> value)
 {
     if (buffer == null)
     {
         throw new ArgumentNullException("buffer");
     }
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     foreach (byte num in value)
     {
         ByteArrayExtensions.Write(buffer, offset++, num);
     }
 }
Beispiel #2
0
        protected static uint Sum16Bits(byte[] buffer, int offset, int length)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }
            int  num1 = offset + length;
            uint num2 = 0U;

            while (offset < num1 - 1)
            {
                num2 += (uint)ByteArrayExtensions.ReadUShort(buffer, ref offset, Endianity.Big);
            }
            if (offset < num1)
            {
                num2 += (uint)(ushort)((uint)buffer[offset] << 8);
            }
            return(num2);
        }
 public static int Find(this byte[] array, int offset, int count, byte[] other, int otherOffset, int otherCount)
 {
     if (array == null)
     {
         throw new ArgumentNullException("array");
     }
     if (otherCount > count)
     {
         return(array.Length);
     }
     for (int index = offset + count - otherCount; offset < index; ++offset)
     {
         if (ByteArrayExtensions.SequenceEqual(array, offset, other, otherOffset, otherCount))
         {
             return(offset);
         }
     }
     return(array.Length);
 }
 public static void WriteCarriageReturnLinefeed(this byte[] buffer, ref int offset)
 {
     ByteArrayExtensions.Write(buffer, ref offset, (byte)13);
     ByteArrayExtensions.Write(buffer, ref offset, (byte)10);
 }
 public static void Write(this byte[] buffer, int offset, IpV6Address value, Endianity endianity)
 {
     ByteArrayExtensions.Write(buffer, offset, value.ToValue(), endianity);
 }
 public static byte[] ReadBytes(this byte[] buffer, int offset, int length)
 {
     byte[] destination = new byte[length];
     ByteArrayExtensions.BlockCopy(buffer, offset, destination, 0, length);
     return(destination);
 }
Beispiel #7
0
 internal IpV6Address ReadIpV6Address(int offset, Endianity endianity)
 {
     return(ByteArrayExtensions.ReadIpV6Address(this.Buffer, this.StartOffset + offset, endianity));
 }
Beispiel #8
0
 protected MacAddress ReadMacAddress(int offset, Endianity endianity)
 {
     return(ByteArrayExtensions.ReadMacAddress(this.Buffer, this.StartOffset + offset, endianity));
 }
 public static ushort ReadUShort(this byte[] buffer, int offset, Endianity endianity)
 {
     return((ushort)ByteArrayExtensions.ReadShort(buffer, offset, endianity));
 }
Beispiel #10
0
 internal void Write(byte[] buffer, ref int offset)
 {
     ByteArrayExtensions.BlockCopy(this.Buffer, this.StartOffset, buffer, offset, this.Length);
     offset += this.Length;
 }
 public static void Write(this byte[] buffer, ref int offset, byte value)
 {
     ByteArrayExtensions.Write(buffer, offset, value);
     ++offset;
 }
 public static IpV6Address ReadIpV6Address(this byte[] buffer, int offset, Endianity endianity)
 {
     return(new IpV6Address(ByteArrayExtensions.ReadUInt128(buffer, offset, endianity)));
 }
 public static IpV4TimeOfDay ReadIpV4TimeOfDay(this byte[] buffer, ref int offset, Endianity endianity)
 {
     return(new IpV4TimeOfDay(ByteArrayExtensions.ReadUInt(buffer, ref offset, endianity)));
 }
 public static MacAddress ReadMacAddress(this byte[] buffer, ref int offset, Endianity endianity)
 {
     return(new MacAddress(ByteArrayExtensions.ReadUInt48(buffer, ref offset, endianity)));
 }
 public static ulong ReadULong(this byte[] buffer, int offset, Endianity endianity)
 {
     return((ulong)ByteArrayExtensions.ReadLong(buffer, offset, endianity));
 }
 public static uint ReadUInt(this byte[] buffer, int offset, Endianity endianity)
 {
     return((uint)ByteArrayExtensions.ReadInt(buffer, offset, endianity));
 }
 public static void WriteDecimal(this byte[] buffer, ref int offset, uint value)
 {
     ByteArrayExtensions.Write(buffer, ref offset, value.ToString((IFormatProvider)CultureInfo.InvariantCulture), Encoding.ASCII);
 }
Beispiel #18
0
 internal ushort ReadUShort(int offset, Endianity endianity)
 {
     return(ByteArrayExtensions.ReadUShort(this.Buffer, this.StartOffset + offset, endianity));
 }
Beispiel #19
0
 internal ulong ReadULong(int offset, Endianity endianity)
 {
     return(ByteArrayExtensions.ReadULong(this.Buffer, this.StartOffset + offset, endianity));
 }
Beispiel #20
0
 internal byte[] ReadBytes(int offset, int length)
 {
     return(ByteArrayExtensions.ReadBytes(this.Buffer, this.StartOffset + offset, length));
 }
 public static byte[] ReadBytes(this byte[] buffer, ref int offset, int length)
 {
     byte[] numArray = ByteArrayExtensions.ReadBytes(buffer, offset, length);
     offset += length;
     return(numArray);
 }
Beispiel #22
0
 internal UInt48 ReadUInt48(int offset, Endianity endianity)
 {
     return(ByteArrayExtensions.ReadUInt48(this.Buffer, this.StartOffset + offset, endianity));
 }
 public static void Write(this byte[] buffer, ref int offset, UInt48 value, Endianity endianity)
 {
     ByteArrayExtensions.Write(buffer, offset, value, endianity);
     offset += 6;
 }
Beispiel #24
0
 internal BigInteger ReadUnsignedBigInteger(int offset, int length, Endianity endianity)
 {
     return(ByteArrayExtensions.ReadUnsignedBigInteger(this.Buffer, this.StartOffset + offset, length, endianity));
 }
 public static void Write(this byte[] buffer, int offset, ulong value, Endianity endianity)
 {
     ByteArrayExtensions.Write(buffer, offset, (long)value, endianity);
 }
Beispiel #26
0
 protected IpV4TimeOfDay ReadIpV4TimeOfDay(int offset, Endianity endianity)
 {
     return(ByteArrayExtensions.ReadIpV4TimeOfDay(this.Buffer, this.StartOffset + offset, endianity));
 }
 public static void Write(this byte[] buffer, int offset, DataSegment value)
 {
     ByteArrayExtensions.Write(buffer, ref offset, value);
 }
 public static void Write(this byte[] buffer, ref int offset, IpV4TimeOfDay value, Endianity endianity)
 {
     ByteArrayExtensions.Write(buffer, ref offset, value.MillisecondsSinceMidnightUniversalTime, endianity);
 }
Beispiel #29
0
 public void CopyTo(byte[] array, int arrayIndex)
 {
     ByteArrayExtensions.BlockCopy(this.Buffer, 0, array, arrayIndex, this.Length);
 }