Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/CloudManagerClient.cs @ 7339

Last change on this file since 7339 was 7326, checked in by spimming, 12 years ago

#1680:

  • New model classes
  • New service operation methods added
  • License information added
File size: 3.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using HeuristicLab.Clients.Hive.CloudManager.Azure;
24using HeuristicLab.Clients.Hive.CloudManager.Model;
25using HeuristicLab.Common;
26using HeuristicLab.Core;
27
28namespace HeuristicLab.Clients.Hive.CloudManager {
29  [Item("CloudManagerClient", "Hive Cloud Manager Client.")]
30  public sealed class CloudManagerClient : IContent {
31    private static CloudManagerClient instance;
32    public static CloudManagerClient Instance {
33      get {
34        if (instance == null) instance = new CloudManagerClient();
35        return instance;
36      }
37    }
38
39    private CloudManagerClient() {
40      subscriptions = new ItemList<Subscription>();
41      azureProvider = new AzureProvider();
42    }
43
44    #region Properties
45    private IItemList<Subscription> subscriptions;
46    public IItemList<Subscription> Subscriptions {
47      get { return subscriptions; }
48      set {
49        if (value != subscriptions) {
50          subscriptions = value;
51          //fire event OnSubscriptionsChagned
52        }
53      }
54    }
55
56    private IAzureProvider azureProvider;
57    public IAzureProvider AzureProvider {
58      get { return azureProvider; }
59      set { azureProvider = value; }
60    }
61
62    #endregion
63
64    #region Events
65
66    public event EventHandler Refreshing;
67    private void OnRefreshing() {
68      EventHandler handler = Refreshing;
69      if (handler != null) handler(this, EventArgs.Empty);
70    }
71    public event EventHandler Refreshed;
72    private void OnRefreshed() {
73      var handler = Refreshed;
74      if (handler != null) handler(this, EventArgs.Empty);
75    }
76
77    #endregion
78
79    #region Refresh
80
81    public void Refresh() {
82      OnRefreshing();
83
84      try {
85        IItemList<Subscription> subs = new ItemList<Subscription>(Subscriptions);
86        foreach (Subscription subscription in subs) {
87          if (subscription.DiscoverServices) {
88            //Discover
89          }
90        }
91      }
92      catch {
93        throw;
94      }
95      finally {
96        OnRefreshed();
97      }
98    }
99
100    #endregion
101
102    public void Add(Subscription subscription) {
103      if (subscription == null) {
104        throw new ArgumentNullException("subscription", "Subscription must not be null.");
105      }
106      if (Subscriptions.Contains(subscription)) {
107        Subscriptions.Remove(subscription);
108      }
109      Subscriptions.Add(subscription);
110    }
111
112    public void Remove(Subscription subscription) {
113      if (subscription == null) {
114        throw new ArgumentNullException("subscription", "Subscription must not be null.");
115      }
116      if (Subscriptions.Contains(subscription)) {
117        Subscriptions.Remove(subscription);
118      }
119    }
120
121
122
123
124  }
125}
Note: See TracBrowser for help on using the repository browser.