Пример #1
0
 /// <summary>
 /// Determines whether [contains] [the specified range].
 /// </summary>
 /// <param name="range">The range.</param>
 /// <param name="specificCode">The specific code.</param>
 /// <returns><c>true</c> if [contains] [the specified range]; otherwise, <c>false</c>.</returns>
 public static bool Contains(PostalCodeRange range, PostalCode specificCode)
 {
     if (specificCode == null)
     {
         return(range.IsDefault);
     }
     if ((range.Start != null && !range.Start.ValidateFormatCompatibility(specificCode)) ||
         (range.End != null && !range.End.ValidateFormatCompatibility(specificCode)))
     {
         return(false);
     }
     return(range.IsDefault ||
            ((range.Start <= specificCode) && (specificCode <= range.End)));
 }
Пример #2
0
        /// <summary>
        /// Determines whether [contains] [the specified range].
        /// </summary>
        /// <param name="range">The range.</param>
        /// <param name="specificCode">The specific code.</param>
        /// <returns><c>true</c> if [contains] [the specified range]; otherwise, <c>false</c>.</returns>
        public static bool Contains(PostalCodeRange range, PostalCode specificCode)
        {
            if (specificCode == null)
            {
                return(range.IsDefault);
            }
            if ((range.Start != null && !range.Start.ValidateFormatCompatibility(specificCode)) ||
                (range.End != null && !range.End.ValidateFormatCompatibility(specificCode)))
            {
                return(false);
            }

            return(range.IsDefault ||
                   ((range.Start <= specificCode.LowestExpandedPostalCodeString) && (range.End >= specificCode.HighestExpandedPostalCodeString)));
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostalCodeRange"/> class.
        /// </summary>
        /// <param name="start">The start.</param>
        /// <param name="end">The end.</param>
        /// <exception cref="System.ArgumentException"></exception>
        public PostalCodeRange(PostalCode start, PostalCode end)
        {
            if (start != null && end != null && start.GetType() != end.GetType())
            {
                throw new ArgumentException(String.Format(
                                                "The start and the end of the range are from incompatible types ('{0}' & '{1}')",
                                                start.GetType(), end.GetType()));
            }

            if (end != null && start != null && start > end)
            {
                throw new ArgumentException(String.Format(
                                                "PostalCodeRange end ({0}) can't be before start ({1})", end, start));
            }

            Start = start;
            End   = end;
        }
Пример #4
0
 internal override bool ValidateFormatCompatibility(PostalCode other)
 {
     return(HasSameFormat(other as GBPostalCode));
 }
 /// <summary>
 /// Determines whether the range contains substractFrom postal code.
 /// </summary>
 /// <param name="postalCode">The postal code.</param>
 /// <returns><c>true</c> if range contains the specified postal code; otherwise, <c>false</c>.</returns>
 public bool Contains(PostalCode postalCode)
 {
     return(Contains(this, postalCode));
 }
 /// <summary>
 /// Ares the adjacent.
 /// </summary>
 /// <param name="left">The left.</param>
 /// <param name="right">The right.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 public static bool AreAdjacent(PostalCodeRange left, PostalCodeRange right)
 {
     return(PostalCode.AreAdjacent(left.Start, right.End) ||
            PostalCode.AreAdjacent(left.End, right.Start));
 }