Exemplo n.º 1
0
        public int GetPrefixLength()
        {
            byte[] byteBegin = Begin.GetAddressBytes();
            byte[] byteEnd   = End.GetAddressBytes();

            // Handle single IP
            if (Begin.Equals(End))
            {
                return(byteBegin.Length * 8);
            }

            int length = byteBegin.Length * 8;

            for (int i = 0; i < length; i++)
            {
                byte[] mask = Bits.GetBitMask(byteBegin.Length, i);
                if (new IPAddress(Bits.And(byteBegin, mask)).Equals(Begin))
                {
                    if (new IPAddress(Bits.Or(byteBegin, Bits.Not(mask))).Equals(End))
                    {
                        return(i);
                    }
                }
            }
            throw new FormatException(string.Format("{0} is not a CIDR Subnet", ToString()));
        }
Exemplo n.º 2
0
 public bool Equals(PhylopInterval other)
 {
     if (other == null)
     {
         return(false);
     }
     return(Begin.Equals(other.Begin));
 }
Exemplo n.º 3
0
        /// <summary>
        /// Compares two exceptional periods for equality.
        /// </summary>
        /// <param name="ExceptionalPeriod">An exceptional period to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public Boolean Equals(ExceptionalPeriod ExceptionalPeriod)
        {
            if ((Object)ExceptionalPeriod == null)
            {
                return(false);
            }

            return(Begin.Equals(ExceptionalPeriod.Begin) &&
                   End.Equals(ExceptionalPeriod.End));
        }
Exemplo n.º 4
0
 public bool BeginAndEndAreEqual()
 {
     if (HasRange)
     {
         var bytes = new[] { "byte[]", "rowversion" };
         if (bytes.Any(t => t == Version.SimpleType))
         {
             var beginBytes = (byte[])Begin;
             var endBytes   = (byte[])End;
             return(Common.AreEqual(beginBytes, endBytes));
         }
         return(Begin.Equals(End));
     }
     return(false);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Check if this ip address range equals another object
 /// </summary>
 /// <param name="obj">Other object</param>
 /// <returns>True if equal, false otherwise</returns>
 public override bool Equals(object obj)
 {
     if (obj == null || !(obj is IPAddressRange other))
     {
         return(false);
     }
     else if (Begin == null && other.Begin == null && End == null && other.End == null)
     {
         return(true);
     }
     else if (Begin == null || End == null)
     {
         return(false);
     }
     return(Begin.Equals(other.Begin) && End.Equals(other.End));
 }
Exemplo n.º 6
0
        public override bool Equals(object obj)
        {
            if (obj is EndPoint)
            {
                EndPoint other = (EndPoint)obj;

                return(Position.Equals(other.Position) &&
                       Begin.Equals(other.Begin) &&
                       Angle.Equals(other.Angle));

                // We do not care about the segment being the same
                // since that would create a circular reference
            }

            return(false);
        }
Exemplo n.º 7
0
        public IEnumerator <IPAddress> GetEnumerator()
        {
            if (Begin.Equals(End))
            {
                yield return(Begin);

                yield break;
            }

            var first = Begin.GetAddressBytes();
            var last  = End.GetAddressBytes();

            for (var ip = first; Bits.LtECore(ip, last); ip = Bits.Increment(ip))
            {
                yield return(new IPAddress(ip));
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Determines whether the specified <see cref="Range"/> is equal to this instance.
 /// </summary>
 /// <param name="other">The <see cref="Range"/> to compare with this instance.</param>
 public bool Equals(Range other)
 {
     return(Begin.Equals(other.Begin) &&
            End.Equals(other.End));
 }
Exemplo n.º 9
0
 public bool Equals(PhylopInterval other)
 {
     return(other != null && Begin.Equals(other.Begin));
 }
Exemplo n.º 10
0
 public bool Equals(IPAddressRange other)
 {
     return(other != null && Begin.Equals(other.Begin) && End.Equals(other.End));
 }
Exemplo n.º 11
0
        /// <summary>
        /// Compares two RegularRegularHourss for equality.
        /// </summary>
        /// <param name="RegularRegularHours">A RegularRegularHours to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public Boolean Equals(RegularHours RegularRegularHours)

        => Weekday.Equals(RegularRegularHours.Weekday) &&
        Begin.Equals(RegularRegularHours.Begin) &&
        End.Equals(RegularRegularHours.End);
Exemplo n.º 12
0
 protected bool Equals(SeriesValue other)
 {
     return(Value == other.Value && Begin.Equals(other.Begin) && End.Equals(other.End));
 }
Exemplo n.º 13
0
 public bool Equals(Range other)
 => ExcludeEnd.Equals(other?.ExcludeEnd) &&
 Begin.Equals(other?.Begin) &&
 End.Equals(other?.End);
Exemplo n.º 14
0
 public Boolean Equals(Range <T> other)
 {
     return(Begin.Equals(other.Begin) && End.Equals(other.End));
 }
Exemplo n.º 15
0
 private bool Equals(IPAddressRange other)
 {
     return(Begin.Equals(other.Begin) && End.Equals(other.End));
 }
Exemplo n.º 16
0
 public bool Equals(Station other)
 {
     return(Identifier.Equals(other.Identifier) && string.Equals(Name, other.Name) && string.Equals(Country, other.Country) && string.Equals(FIPSCountryId, other.FIPSCountryId) && string.Equals(State, other.State) && string.Equals(CallSign, other.CallSign) && Latitude.Equals(other.Latitude) && Longitude.Equals(other.Longitude) && Elevation.Equals(other.Elevation) && Begin.Equals(other.Begin) && End.Equals(other.End));
 }