Exemplo n.º 1
0
 public bool Equals(UInt48 other)
 {
     if ((int)this._mostSignificant == (int)other._mostSignificant)
     {
         return((int)this._leastSignificant == (int)other._leastSignificant);
     }
     return(false);
 }
Exemplo n.º 2
0
        private static UInt48 HostToNetworkOrder(UInt48 value)
        {
            UInt48 result;

            unsafe
            {
                UInt48* resultPtr = &result;
                byte* resultBytePtr = (byte*)resultPtr;
                
                UInt48* valuePtr = &value;
                byte* valueBytePtr = (byte*)valuePtr;

                resultBytePtr[0] = valueBytePtr[5];
                resultBytePtr[1] = valueBytePtr[4];
                resultBytePtr[2] = valueBytePtr[3];
                resultBytePtr[3] = valueBytePtr[2];
                resultBytePtr[4] = valueBytePtr[1];
                resultBytePtr[5] = valueBytePtr[0];
            }

            return result;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Writes the given value to the buffer using the given endianity and increments the offset by the number of bytes written.
 /// </summary>
 /// <param name="buffer">The buffer to write the value to.</param>
 /// <param name="offset">The offset in the buffer to start writing.</param>
 /// <param name="value">The value to write.</param>
 /// <param name="endianity">The endianity to use when converting the value to bytes.</param>
 public static void Write(this byte[] buffer, ref int offset, UInt48 value, Endianity endianity)
 {
     buffer.Write(offset, value, endianity);
     offset += UInt48.SizeOf;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Writes the given value to the buffer using the given endianity.
 /// </summary>
 /// <param name="buffer">The buffer to write the value to.</param>
 /// <param name="offset">The offset in the buffer to start writing.</param>
 /// <param name="value">The value to write.</param>
 /// <param name="endianity">The endianity to use when converting the value to bytes.</param>
 public static void Write(this byte[] buffer, int offset, UInt48 value, Endianity endianity)
 {
     if (IsWrongEndianity(endianity))
         value = HostToNetworkOrder(value);
     Write(buffer, offset, value);
 }
Exemplo n.º 5
0
 private static void Write(byte[] buffer, int offset, UInt48 value)
 {
     unsafe
     {
         fixed (byte* ptr = &buffer[offset])
         {
             *((UInt48*)ptr) = value;
         }
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Returns true iff the two values represent the same value.
 /// </summary>
 /// <param name="other">The value to compare to.</param>
 /// <returns>True iff the two values represent the same value.</returns>
 public bool Equals(UInt48 other)
 {
     return _mostSignificant == other._mostSignificant &&
            _leastSignificant == other._leastSignificant;
 }
Exemplo n.º 7
0
 public static void AssertValue(this XElement element, UInt48 expectedValue)
 {
     element.AssertValue(expectedValue.ToString("x12"));
 }
Exemplo n.º 8
0
 public static UInt48 Parse(string value, NumberStyles style)
 {
     return(UInt48.Parse(value, style, (IFormatProvider)CultureInfo.CurrentCulture.NumberFormat));
 }
Exemplo n.º 9
0
 public static UInt48 Parse(string value, IFormatProvider provider)
 {
     return(UInt48.Parse(value, NumberStyles.Integer, provider));
 }
Exemplo n.º 10
0
 public static UInt48 Parse(string value)
 {
     return(UInt48.Parse(value, NumberStyles.Integer, (IFormatProvider)CultureInfo.CurrentCulture));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Returns true iff the two values represent the same value.
 /// </summary>
 /// <param name="other">The value to compare to.</param>
 /// <returns>True iff the two values represent the same value.</returns>
 public bool Equals(UInt48 other)
 {
     return(_mostSignificant == other._mostSignificant &&
            _leastSignificant == other._leastSignificant);
 }