コード例 #1
0
 public bool Equals(UInt48 other)
 {
     if ((int)this._mostSignificant == (int)other._mostSignificant)
     {
         return((int)this._leastSignificant == (int)other._leastSignificant);
     }
     return(false);
 }
コード例 #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;
        }
コード例 #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;
 }
コード例 #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);
 }
コード例 #5
0
 private static void Write(byte[] buffer, int offset, UInt48 value)
 {
     unsafe
     {
         fixed (byte* ptr = &buffer[offset])
         {
             *((UInt48*)ptr) = value;
         }
     }
 }
コード例 #6
0
ファイル: UInt48.cs プロジェクト: amitla/Pcap.Net
 /// <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;
 }
コード例 #7
0
ファイル: XElementExtensions.cs プロジェクト: amitla/Pcap.Net
 public static void AssertValue(this XElement element, UInt48 expectedValue)
 {
     element.AssertValue(expectedValue.ToString("x12"));
 }
コード例 #8
0
 public static UInt48 Parse(string value, NumberStyles style)
 {
     return(UInt48.Parse(value, style, (IFormatProvider)CultureInfo.CurrentCulture.NumberFormat));
 }
コード例 #9
0
 public static UInt48 Parse(string value, IFormatProvider provider)
 {
     return(UInt48.Parse(value, NumberStyles.Integer, provider));
 }
コード例 #10
0
 public static UInt48 Parse(string value)
 {
     return(UInt48.Parse(value, NumberStyles.Integer, (IFormatProvider)CultureInfo.CurrentCulture));
 }
コード例 #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);
 }