예제 #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()));
        }
예제 #2
0
 public bool Equals(PhylopInterval other)
 {
     if (other == null)
     {
         return(false);
     }
     return(Begin.Equals(other.Begin));
 }
예제 #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));
        }
예제 #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);
 }
예제 #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));
 }
예제 #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);
        }
예제 #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));
            }
        }
예제 #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));
 }
예제 #9
0
 public bool Equals(PhylopInterval other)
 {
     return(other != null && Begin.Equals(other.Begin));
 }
예제 #10
0
 public bool Equals(IPAddressRange other)
 {
     return(other != null && Begin.Equals(other.Begin) && End.Equals(other.End));
 }
예제 #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);
예제 #12
0
 protected bool Equals(SeriesValue other)
 {
     return(Value == other.Value && Begin.Equals(other.Begin) && End.Equals(other.End));
 }
예제 #13
0
 public bool Equals(Range other)
 => ExcludeEnd.Equals(other?.ExcludeEnd) &&
 Begin.Equals(other?.Begin) &&
 End.Equals(other?.End);
예제 #14
0
 public Boolean Equals(Range <T> other)
 {
     return(Begin.Equals(other.Begin) && End.Equals(other.End));
 }
예제 #15
0
 private bool Equals(IPAddressRange other)
 {
     return(Begin.Equals(other.Begin) && End.Equals(other.End));
 }
예제 #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));
 }