Ejemplo n.º 1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            string Temp = reader.Value.ToString();

            short Value = short.Parse(Temp);

            return(TimeZoneKey.GetTimeZoneKey(Value));
        }
Ejemplo n.º 2
0
        public static ReadOnlyCollection <TimeZoneInfo> GetSystemTimeZones()
        {
            if (systemTimeZones == null)
            {
                systemTimeZones = new List <TimeZoneInfo> ();
#if !NET_2_1
                if (TimeZoneKey != null)
                {
                    foreach (string id in TimeZoneKey.GetSubKeyNames())
                    {
                        try {
                            systemTimeZones.Add(FindSystemTimeZoneById(id));
                        } catch {}
                    }

                    return(new ReadOnlyCollection <TimeZoneInfo> (systemTimeZones));
                }
#endif
#if MONODROID
                foreach (string id in ZoneInfoDB.GetAvailableIds())
                {
                    systemTimeZones.Add(ZoneInfoDB.GetTimeZone(id));
                }
#elif MONOTOUCH
                if (systemTimeZones.Count == 0)
                {
                    foreach (string name in GetMonoTouchNames())
                    {
                        using (Stream stream = GetMonoTouchData(name)) {
                            systemTimeZones.Add(BuildFromStream(name, stream));
                        }
                    }
                }
#elif LIBC
                string[] continents = new string [] { "Africa", "America", "Antarctica", "Arctic", "Asia", "Atlantic", "Brazil", "Canada", "Chile", "Europe", "Indian", "Mexico", "Mideast", "Pacific", "US" };
                foreach (string continent in continents)
                {
                    try {
                        foreach (string zonepath in Directory.GetFiles(Path.Combine(TimeZoneDirectory, continent)))
                        {
                            try {
                                string id = String.Format("{0}/{1}", continent, Path.GetFileName(zonepath));
                                systemTimeZones.Add(FindSystemTimeZoneById(id));
                            } catch (ArgumentNullException) {
                            } catch (TimeZoneNotFoundException) {
                            } catch (InvalidTimeZoneException) {
                            } catch (Exception) {
                                throw;
                            }
                        }
                    } catch {}
                }
#else
                throw new NotImplementedException("This method is not implemented for this platform");
#endif
            }
            return(new ReadOnlyCollection <TimeZoneInfo> (systemTimeZones));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new client options set with default values.
 /// </summary>
 public PrestoClientSessionConfig()
 {
     this.Host                 = _DEFAULT_HOST;
     this.Port                 = _DEFAULT_PORT;
     this.User                 = Environment.GetEnvironmentVariable("USERNAME") ?? Environment.GetEnvironmentVariable("USER");
     this.CheckInterval        = _QUERY_STATE_CHECK_INTERVAL;
     this.IgnoreSslErrors      = false;
     this.UseSsl               = false;
     this.Version              = PrestoApiVersion.V1;
     this.ClientTags           = new HashSet <string>();
     this.Debug                = false;
     this.Properties           = new Dictionary <string, string>();
     this.PreparedStatements   = new Dictionary <string, string>();
     this.TimeZone             = TimeZoneKey.GetTimeZoneKey(0);
     this.Locale               = CultureInfo.CurrentCulture;
     this.ClientRequestTimeout = _DEFAULT_TIMEOUT;
 }
Ejemplo n.º 4
0
        public static TimeZoneInfo FindSystemTimeZoneById(string id)
        {
            //FIXME: this method should check for cached values in systemTimeZones
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
#if !NET_2_1
            if (TimeZoneKey != null)
            {
                RegistryKey key = TimeZoneKey.OpenSubKey(id, false);
                if (key == null)
                {
                    throw new TimeZoneNotFoundException();
                }
                return(FromRegistryKey(id, key));
            }
#endif
#if MONODROID
            var timeZoneInfo = ZoneInfoDB.GetTimeZone(id);
            if (timeZoneInfo == null)
            {
                throw new TimeZoneNotFoundException();
            }
            return(timeZoneInfo);
#else
            // Local requires special logic that already exists in the Local property (bug #326)
            if (id == "Local")
            {
                return(Local);
            }
#if MONOTOUCH
            using (Stream stream = GetMonoTouchData(id)) {
                return(BuildFromStream(id, stream));
            }
#elif LIBC
            string filepath = Path.Combine(TimeZoneDirectory, id);
            return(FindSystemTimeZoneByFileName(id, filepath));
#else
            throw new NotImplementedException();
#endif
#endif
        }
Ejemplo n.º 5
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            TimeZoneKey Key = (TimeZoneKey)value;

            writer.WriteRawValue(Key.Key.ToString());
        }