private static void Validate (string id, TimeSpan baseUtcOffset, AdjustmentRule [] adjustmentRules)
{
if (id == null)
throw new ArgumentNullException ("id");
if (id == String.Empty)
throw new ArgumentException ("id parameter is an empty string");
if (baseUtcOffset.Ticks % TimeSpan.TicksPerMinute != 0)
throw new ArgumentException ("baseUtcOffset parameter does not represent a whole number of minutes");
if (baseUtcOffset > new TimeSpan (14, 0, 0) || baseUtcOffset < new TimeSpan (-14, 0, 0))
throw new ArgumentOutOfRangeException ("baseUtcOffset parameter is greater than 14 hours or less than -14 hours");
#if STRICT
if (id.Length > 32)
throw new ArgumentException ("id parameter shouldn't be longer than 32 characters");
#endif
if (adjustmentRules != null && adjustmentRules.Length != 0) {
AdjustmentRule prev = null;
foreach (AdjustmentRule current in adjustmentRules) {
if (current == null)
throw new InvalidTimeZoneException ("one or more elements in adjustmentRules are null");
if ((baseUtcOffset + current.DaylightDelta < new TimeSpan (-14, 0, 0)) ||
(baseUtcOffset + current.DaylightDelta > new TimeSpan (14, 0, 0)))
throw new InvalidTimeZoneException ("Sum of baseUtcOffset and DaylightDelta of one or more object in adjustmentRules array is greater than 14 or less than -14 hours;");
if (prev != null && prev.DateStart > current.DateStart)
throw new InvalidTimeZoneException ("adjustment rules specified in adjustmentRules parameter are not in chronological order");
if (prev != null && prev.DateEnd > current.DateStart)
throw new InvalidTimeZoneException ("some adjustment rules in the adjustmentRules parameter overlap");
if (prev != null && prev.DateEnd == current.DateStart)
throw new InvalidTimeZoneException ("a date can have multiple adjustment rules applied to it");
prev = current;
}
}
}