2
// Copyright (C) 2009 Robert Dyer
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
14
// You should have received a copy of the GNU General Public License
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
19
using System.Collections.Generic;
22
namespace WeatherDocklet
25
/// A service to manage all weather sources.
27
public class WeatherService
29
const string ExtensionPath = "/Docky/WeatherSource";
32
/// A <see cref="System.Collections.Generic.Dictionary"/> of all weather sources.
34
public Dictionary<string, AbstractWeatherSource> Sources { get; protected set; }
37
/// Returns an <see cref="System.Collections.Generic.IEnumerable"/> of all possible weather sources ordered by Name.
39
public IEnumerable<AbstractWeatherSource> WeatherSources {
41
return Sources.Values.OrderBy (d => d.Name);
46
/// Returns an <see cref="System.Collections.Generic.IEnumerable"/> of all possible weather sources.
48
public static IEnumerable<AbstractWeatherSource> MAWeatherSources {
50
yield return GoogleWeatherSource.GetInstance ();
51
yield return WeatherChannelWeatherSource.GetInstance ();
52
yield return WunderWeatherSource.GetInstance ();
54
// get { return AddinManager.GetExtensionObjects (ExtensionPath).OfType<AbstractWeatherSource> (); }
58
/// Constructs and initializes a new WeatherService object.
60
public WeatherService()
62
// AddinManager.AddExtensionNodeHandler (ExtensionPath, HandleWeatherSourcesChanged);
69
Sources = new Dictionary<string, AbstractWeatherSource> ();
71
foreach (AbstractWeatherSource aws in MAWeatherSources)
72
Sources.Add (aws.Name, aws);
75
#region IDisposable implementation
77
public void Dispose ()
79
// AddinManager.RemoveExtensionNodeHandler (ExtensionPath, HandleWeatherSourcesChanged);