/// <summary> /// Enumerate infos of all cloud services. /// </summary> public List <CloudServiceInfo> GetServices() { // TODO: Redesign to make it self-contained (so that we don't need to pass the name as well) return(_blobs.ListBlobNames(CloudServiceStateName.GetPrefix()) .Select(name => System.Tuple.Create(name, _blobs.GetBlob(name, _runtimeSerializer))) .Where(pair => pair.Item2.HasValue) .Select(pair => new CloudServiceInfo { ServiceName = pair.Item1.ServiceName, IsStarted = pair.Item2.Value == CloudServiceState.Started }) .ToList()); }
/// <summary> /// Enumerate the names of all cloud services. /// </summary> public List <string> GetServiceNames() { return(_blobs.ListBlobNames(CloudServiceStateName.GetPrefix()) .Select(reference => reference.ServiceName).ToList()); }
/// <summary> /// Remove the state information of a cloud service /// </summary> public void ResetServiceState(string serviceName) { var blobRef = new CloudServiceStateName(serviceName); _blobProvider.DeleteBlob(blobRef); }
/// <summary> /// Enable a cloud service /// </summary> public void EnableService(string serviceName) { var blobRef = new CloudServiceStateName(serviceName); _blobProvider.PutBlob(blobRef, CloudServiceState.Started); }
/// <summary> /// Toggle the state of a cloud service /// </summary> public void ToggleServiceState(string serviceName) { var blobRef = new CloudServiceStateName(serviceName); _blobProvider.UpdateIfNotModified( blobRef, s => s.HasValue ? (s.Value == CloudServiceState.Started ? CloudServiceState.Stopped : CloudServiceState.Started) : CloudServiceState.Started); }