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())); }
public bool Equals(PhylopInterval other) { if (other == null) { return(false); } return(Begin.Equals(other.Begin)); }
/// <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)); }
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); }
/// <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)); }
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); }
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)); } }
/// <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)); }
public bool Equals(PhylopInterval other) { return(other != null && Begin.Equals(other.Begin)); }
public bool Equals(IPAddressRange other) { return(other != null && Begin.Equals(other.Begin) && End.Equals(other.End)); }
/// <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);
protected bool Equals(SeriesValue other) { return(Value == other.Value && Begin.Equals(other.Begin) && End.Equals(other.End)); }
public bool Equals(Range other) => ExcludeEnd.Equals(other?.ExcludeEnd) && Begin.Equals(other?.Begin) && End.Equals(other?.End);
public Boolean Equals(Range <T> other) { return(Begin.Equals(other.Begin) && End.Equals(other.End)); }
private bool Equals(IPAddressRange other) { return(Begin.Equals(other.Begin) && End.Equals(other.End)); }
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)); }