Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Model/HostedService.cs @ 8614

Last change on this file since 8614 was 7577, checked in by spimming, 13 years ago

#1680:

  • Check if role instance list is not null (while deploying a package)
  • Remove a hosted service when it's deleted
File size: 3.3 KB
RevLine 
[7326]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
[7433]22using System;
[7326]23using System.Collections.Generic;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26
27namespace HeuristicLab.Clients.Hive.CloudManager.Model {
28  public class HostedService : Item {
29    public string ServiceName { get; set; }
30    public string Url { get; set; }
[7402]31    public Subscription Subscription { get; set; }
[7326]32    public HostedServiceProperties HostedServiceProperties { get; set; }
33    public List<Deployment> Deployments { get; set; }
34
35    public HostedService() {
36
37    }
38
39    public HostedService(HostedService original, Cloner cloner) {
40      this.ServiceName = original.ServiceName;
41      this.Url = original.Url;
[7402]42      this.Subscription = cloner.Clone(original.Subscription);
43      this.HostedServiceProperties = cloner.Clone(original.HostedServiceProperties);
[7326]44      this.Deployments = new List<Deployment>(original.Deployments);
45    }
46
47    public override bool Equals(object obj) {
48      if (obj == null)
49        return false;
50      HostedService sub = obj as HostedService;
51      if ((this.ServiceName == sub.ServiceName))
52        return true;
53      else
54        return false;
55    }
56
57    public override string ToString() {
58      return string.Format("HostedService: Name={0}, Url={1}", ServiceName, Url);
59    }
60
61    public override IDeepCloneable Clone(Cloner cloner) {
62      return new HostedService(this, cloner);
63    }
[7433]64
65    public void Merge(HostedService hostedService) {
66      if (!this.Equals(hostedService)) {
67        throw new ArgumentException("Objects must be equal to be merged.", "subscription");
68      }
69      this.ServiceName = hostedService.ServiceName;
70      this.Url = hostedService.Url;
71      this.Subscription = hostedService.Subscription;
72      this.HostedServiceProperties = hostedService.HostedServiceProperties;
73
74      foreach (Deployment dep in hostedService.Deployments) {
75        int idx = this.Deployments.IndexOf(dep);
76        if (idx != -1) {
77          this.Deployments[idx].Merge(dep);
78        } else {
79          this.Deployments.Add(dep);
80        }
81      }
82
[7577]83      List<Deployment> listToDelete = new List<Deployment>();
[7433]84      foreach (Deployment dep in this.Deployments) {
85        int idx = hostedService.Deployments.IndexOf(dep);
86        if (idx == -1) {
[7577]87          //this.Deployments.Remove(dep);
88          listToDelete.Add(dep);
[7433]89        }
90      }
[7577]91      foreach (Deployment d in listToDelete) {
92        this.Deployments.Remove(d);
93      }
[7433]94    }
[7326]95  }
96}
Note: See TracBrowser for help on using the repository browser.