A collection of elements of type WindowsTimeZone
Inheritance: System.Collections.CollectionBase
Beispiel #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);
        }
Beispiel #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();
            }
        }
Beispiel #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);
        }
Beispiel #4
0
 public Enumerator(WindowsTimeZoneCollection collection)
 {
     this.wrapped = ((System.Collections.CollectionBase)collection).GetEnumerator();
 }
Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #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();
            }
        }