Beispiel #1
0
        /// <summary>
        /// Checks to see if two UnsuccessAddresses are equal.
        /// </summary>
        /// <param name="obj">The UnsuccessAddresses to check</param>
        /// <returns>true if obj and this are equal</returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (GetType() != obj.GetType())
            {
                return(false);
            }

            DestinationAddress da = (DestinationAddress)obj;

            if (!da.IsDistributionList)
            {
                // value member check
                return
                    (DestinationAddressTon.Equals(da.DestinationAddressTon) &&
                     DestinationAddressNpi.Equals(da.DestinationAddressNpi) &&
                     DestAddress.Equals(da.DestAddress));
            }
            else
            {
                return(DistributionList.Equals(da.DistributionList));
            }
        }
Beispiel #2
0
 /// <summary>
 /// Generates a hashcode of the entry.
 /// </summary>
 /// <returns>Generated hashcode.</returns>
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (DestAddress != null ? DestAddress.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ OutPort.GetHashCode();
         return hashCode;
     }
 }
Beispiel #3
0
 /// <summary>
 /// Generates a hashcode of the entry.
 /// </summary>
 /// <returns>Generated hashcode.</returns>
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = 1;
         hashCode = (hashCode * 397) ^ (DestAddress != null ? DestAddress.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ FEC;
         return(hashCode);
     }
 }
Beispiel #4
0
        /// <summary>
        /// Gets the hash code for this object.
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            int hashCode = 0;

            if (!IsDistributionList)
            {
                hashCode ^= DestAddress.GetHashCode();
                hashCode ^= DestinationAddressNpi.GetHashCode();
                hashCode ^= DestinationAddressTon.GetHashCode();
            }
            else
            {
                hashCode ^= DistributionList.GetHashCode();
            }

            return(hashCode);
        }
Beispiel #5
0
        /// <summary>
        /// Converts <c>MPLSPackage</c> to bytes
        /// </summary>
        /// <returns>Converted package</returns>
        public byte[] ToBytes()
        {
            List <byte> result = new List <byte>();

            PacketLength = HeaderLength + Payload.Length;

            result.AddRange(LabelStack.GetBytes());
            result.AddRange(BitConverter.GetBytes(ID));
            result.AddRange(BitConverter.GetBytes(PacketLength));
            result.AddRange(BitConverter.GetBytes(TTL));
            result.AddRange(SourceAddress.GetAddressBytes());
            result.AddRange(DestAddress.GetAddressBytes());
            result.AddRange(BitConverter.GetBytes(Port));
            result.AddRange(Encoding.ASCII.GetBytes(Payload ?? ""));

            return(result.ToArray());
        }
 public override string ToString()
 {
     return($"LabelStack={LabelStack};Message={Message};Source={SourceAddress.ToString()};Destination={DestAddress.ToString()};Port={Port}");
 }