Пример #1
0
        /// <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());
        }
Пример #2
0
 /// <summary>
 /// Enumerate the names of all cloud services.
 /// </summary>
 public List <string> GetServiceNames()
 {
     return(_blobs.ListBlobNames(CloudServiceStateName.GetPrefix())
            .Select(reference => reference.ServiceName).ToList());
 }
Пример #3
0
		/// <summary>
		/// Remove the state information of a cloud service
		/// </summary>
		public void ResetServiceState(string serviceName)
		{
			var blobRef = new CloudServiceStateName(serviceName);
			_blobProvider.DeleteBlob(blobRef);
		}
Пример #4
0
		/// <summary>
		/// Enable a cloud service
		/// </summary>
		public void EnableService(string serviceName)
		{
			var blobRef = new CloudServiceStateName(serviceName);
			_blobProvider.PutBlob(blobRef, CloudServiceState.Started);
		}
Пример #5
0
		/// <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);
		}