Add() public method

Adds an instance of type WindowsTimeZone to the end of this WindowsTimeZoneCollection.
public Add ( WindowsTimeZone value ) : void
value WindowsTimeZone /// The WindowsTimeZone to be added to the end of this WindowsTimeZoneCollection. ///
return void
Ejemplo n.º 1
0
        private static WindowsTimeZoneCollection LoadTimeZonesFromRegistry()
        {
            WindowsTimeZoneCollection tzs = new WindowsTimeZoneCollection();

            RegistryKey timeZoneListKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", false);

            string[] timeZoneKeyNames = timeZoneListKey.GetSubKeyNames();
            foreach (string timeZoneKeyName in timeZoneKeyNames)
            {
                RegistryKey     timeZoneKey     = timeZoneListKey.OpenSubKey(timeZoneKeyName);
                WindowsTimeZone windowsTimeZone =
                    new WindowsTimeZone(
                        timeZoneKey.GetValue("Display") as string,
                        timeZoneKey.GetValue("Dlt") as string,
                        timeZoneKey.GetValue("Std") as string,
                        (int)timeZoneKey.GetValue("Index"),
                        timeZoneKey.GetValue("TZI") as byte[]);

                tzs.Add(windowsTimeZone);
            }
            tzs.SortByTimeZoneBias();
            return(tzs);
        }
Ejemplo n.º 2
0
        private static WindowsTimeZoneCollection LoadTimeZonesFromRegistry()
        {
            WindowsTimeZoneCollection tzs = new WindowsTimeZoneCollection();

            RegistryKey timeZoneListKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", false);
            string[] timeZoneKeyNames = timeZoneListKey.GetSubKeyNames();
            foreach (string timeZoneKeyName in timeZoneKeyNames)
            {
                RegistryKey timeZoneKey = timeZoneListKey.OpenSubKey(timeZoneKeyName);
                WindowsTimeZone windowsTimeZone =
                    new WindowsTimeZone(
                    timeZoneKey.GetValue("Display") as string,
                    timeZoneKey.GetValue("Dlt") as string,
                    timeZoneKey.GetValue("Std") as string,
                    (int)timeZoneKey.GetValue("Index" ),
                    timeZoneKey.GetValue("TZI") as byte[] );

                tzs.Add( windowsTimeZone );
            }
            tzs.SortByTimeZoneBias();
            return tzs;
        }