/// <summary>
            /// Builds a OpenWeatherConfiguration object.
            /// </summary>
            /// <returns></returns>
            public OpenWeatherMapConfiguration Build()
            {
                var config = new OpenWeatherMapConfiguration(this.apiKey);

                config.version   = this.version;
                config.cacheTime = this.cacheTime;
                config.mode      = this.mode;

                return(config);
            }
Esempio n. 2
0
        /// <summary>
        /// Initialize OpenWeatherMap, this needs to be called before any API calls
        /// can be made. This should only be done once.
        /// </summary>
        /// <param name="config">Configuration for the OpenWeatherMap API.</param>
        public static void Initialize(OpenWeatherMapConfiguration config)
        {
            if (OpenWeatherMap.instance == null)
            {
                OpenWeatherMap.instance = new OpenWeatherMap(config);

                return;
            }

            System.Console.WriteLine(
                string.Format(
                    "{0} - Initialize(): {0} is already initialized. Ignoring call.",
                    typeof(OpenWeatherMap).Name));
        }
Esempio n. 3
0
 private OpenWeatherMap(OpenWeatherMapConfiguration config)
 {
     this.endpoint = string.Format("http://api.openweathermap.org/data/{0}", config.Version);
     this.config   = config;
 }