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