#region License Information /* HeuristicLab * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.Text; using HeuristicLab.Common; using HeuristicLab.Core; namespace HeuristicLab.Clients.Hive.CloudManager.Model { public class Subscription : Item { public string SubscriptionID { get; set; } public string SubscriptionName { get; set; } public string SubscriptionStatus { get; set; } public int MaxCoreCount { get; set; } public int MaxHostedServices { get; set; } public int MaxStorageAccounts { get; set; } public int CurrentCoreCount { get; set; } public int CurrentHostedServices { get; set; } public int CurrentStorageAccounts { get; set; } public string CertificateThumbprint { get; set; } public bool SaveToConfig { get; set; } public bool DiscoverServices { get; set; } public Subscription() { } public Subscription(Subscription original, Cloner cloner) { this.SubscriptionID = original.SubscriptionID; this.SubscriptionName = original.SubscriptionName; this.SubscriptionStatus = original.SubscriptionStatus; this.MaxCoreCount = original.MaxCoreCount; this.MaxHostedServices = original.MaxHostedServices; this.MaxStorageAccounts = original.MaxStorageAccounts; this.CurrentCoreCount = original.CurrentCoreCount; this.CurrentHostedServices = original.CurrentHostedServices; this.CurrentStorageAccounts = original.CurrentStorageAccounts; this.CertificateThumbprint = original.CertificateThumbprint; this.SaveToConfig = original.SaveToConfig; this.DiscoverServices = original.DiscoverServices; } //public Subscription(Subscription original, Cloner cloner) {} public override string ToString() { StringBuilder sb = new StringBuilder(); sb.AppendFormat("AzureSubscription: Id={0}, Name={1}, CoreCount={2}/{3}, HostedServices={4}/{5};", SubscriptionID, SubscriptionName, CurrentCoreCount, MaxCoreCount, CurrentHostedServices, MaxHostedServices); return sb.ToString(); } public override int GetHashCode() { return base.GetHashCode(); } public override bool Equals(object obj) { if (obj == null) return false; Subscription sub = obj as Subscription; if ((this.SubscriptionID == sub.SubscriptionID)) return true; else return false; } public override IDeepCloneable Clone(Cloner cloner) { return new Subscription(this, cloner); } public void Merge(Subscription subscription) { if (!this.Equals(subscription)) { throw new ArgumentException("Objects must be equal to be merged.", "subscription"); } this.SubscriptionName = subscription.SubscriptionName; this.SubscriptionStatus = subscription.SubscriptionStatus; this.MaxCoreCount = subscription.MaxCoreCount; this.MaxHostedServices = subscription.MaxHostedServices; this.MaxStorageAccounts = subscription.MaxStorageAccounts; this.CurrentCoreCount = subscription.CurrentCoreCount; this.CurrentHostedServices = subscription.CurrentHostedServices; this.CurrentStorageAccounts = subscription.CurrentStorageAccounts; this.CertificateThumbprint = subscription.CertificateThumbprint; this.SaveToConfig = subscription.SaveToConfig; this.DiscoverServices = subscription.DiscoverServices; } public string GetSettingString() { return SubscriptionID + ";" + CertificateThumbprint; } public static Subscription ParseSettingString(string settingString) { int idxSeparator = settingString.IndexOf(';'); string subId = settingString.Substring(0, idxSeparator); int length = settingString.Length - 1 - idxSeparator; string certThumbprint = settingString.Substring(idxSeparator + 1, length); Subscription sub = new Subscription(); sub.SubscriptionID = subId; sub.CertificateThumbprint = certThumbprint; return sub; } } }