A collection of elements of type WindowsTimeZone
Inheritance: System.Collections.CollectionBase
Esempio n. 1
0
        private static WindowsTimeZoneCollection LoadTimeZonesFromXml()
        {
            WindowsTimeZoneCollection tzs = new WindowsTimeZoneCollection();
            XmlSerializer             ser = new XmlSerializer(tzs.GetType());

            using (StreamReader rs = new StreamReader(tzs.GetType().Assembly.GetManifestResourceStream(tzs.GetType().Namespace + ".WindowsTimeZoneCollection.xml")))
            {
                tzs = ser.Deserialize(rs) as WindowsTimeZoneCollection;
            }

            return(tzs);
        }
Esempio n. 2
0
        static WindowsTimeZone()
        {
            RegistryPermission permission = new RegistryPermission(
                RegistryPermissionAccess.Read,
                "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones");

            try
            {
                permission.Demand();
                timeZones = LoadTimeZonesFromRegistry();
            }
            catch //(Exception ex) //If we can't get into the Registry for any reason, try the fallback...
            {
                //SDH: Requires FullTrust
                //System.Diagnostics.Debug.WriteLine("Error: LoadTimeZonesFromRegistry " + ex.ToString());
                timeZones = LoadTimeZonesFromXml();
            }
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
 public Enumerator(WindowsTimeZoneCollection collection)
 {
     this.wrapped = ((System.Collections.CollectionBase)collection).GetEnumerator();
 }
Esempio n. 5
0
        private static WindowsTimeZoneCollection LoadTimeZonesFromXml()
        {
            WindowsTimeZoneCollection tzs = new WindowsTimeZoneCollection();
            XmlSerializer ser = new XmlSerializer(tzs.GetType());

            using (StreamReader rs = new StreamReader(tzs.GetType().Assembly.GetManifestResourceStream(tzs.GetType().Namespace + ".WindowsTimeZoneCollection.xml")))
            {
                tzs = ser.Deserialize(rs) as WindowsTimeZoneCollection;
            }

            return tzs;
        }
Esempio n. 6
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;
        }
Esempio n. 7
0
        static WindowsTimeZone()
        {
            RegistryPermission permission = new RegistryPermission(
                RegistryPermissionAccess.Read,
                "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones");

            try
            {
                permission.Demand();
                timeZones = LoadTimeZonesFromRegistry();
            }
            catch //(Exception ex) //If we can't get into the Registry for any reason, try the fallback...
            {
                //SDH: Requires FullTrust
                //System.Diagnostics.Debug.WriteLine("Error: LoadTimeZonesFromRegistry " + ex.ToString());
                timeZones = LoadTimeZonesFromXml();
            }
        }