Example #1
0
        /// <summary>
        /// Initializes a new instance of
        /// the <see cref="TimeZoneCollection"/> class.
        /// </summary>
        /// <param name="data">The registry data to use
        /// when populating the collection.</param>
        internal TimeZoneCollection(RegistryKey data)
            : base(new List <TimeZone>())
        {
            string[] subKeyNames = data.GetSubKeyNames();
            nameMap = new Dictionary <string, TimeZone>(subKeyNames.Length);
            foreach (string name in subKeyNames)
            {
                using (RegistryKey key = data.OpenSubKey(name))
                {
                    UITimeZone item = new UITimeZone(name, key);
                    Items.Add(item);
                    nameMap.Add(item.StandardName, item);
                }
            }

            ((List <TimeZone>)Items).Sort(Comparer <TimeZone> .Default);
        }
Example #2
0
        /// <summary>
        /// Compares the current instance with another object of the same type.
        /// </summary>
        /// <param name="other">An object to compare with this instance.</param>
        /// <returns>A 32-bit integer that indicates the relative order
        /// of the entities being compared.</returns>
        /// <exception cref="ArgumentException"><paramref name="other"/>
        /// is not the same type as this instance.</exception>
        int IComparable.CompareTo(object other)
        {
            if (other == null)
            {
                return(1);
            }
            if (!this.GetType().IsInstanceOfType(other))
            {
                throw new ArgumentException(null, "other");
            }
            UITimeZone otherZone = (UITimeZone)other;
            TimeSpan   thisBias  = actualSettings.ZoneBias;
            TimeSpan   otherBias = otherZone.actualSettings.ZoneBias;

            if (thisBias == otherBias)
            {
                return(StringComparer.InvariantCultureIgnoreCase.
                       Compare(description, otherZone.description));
            }
            else
            {
                return(thisBias.CompareTo(otherBias));
            }
        }