/// <summary> /// Get the service properties /// </summary> /// <param name="account">Cloud storage account</param> /// <param name="type">Service type</param> /// <param name="options">Request options</param> /// <param name="operationContext">Operation context</param> /// <returns>The service properties of the specified service type</returns> public XSCLProtocol.ServiceProperties GetStorageServiceProperties(StorageServiceType type, IRequestOptions options, XSCL.OperationContext operationContext) { XSCL.CloudStorageAccount account = StorageContext.StorageAccount; try { switch (type) { case StorageServiceType.Blob: return(account.CreateCloudBlobClient().GetServicePropertiesAsync((BlobRequestOptions)options, operationContext).Result); case StorageServiceType.Queue: return(account.CreateCloudQueueClient().GetServicePropertiesAsync((QueueRequestOptions)options, operationContext).Result); case StorageServiceType.File: FileServiceProperties fileServiceProperties = account.CreateCloudFileClient().GetServicePropertiesAsync((FileRequestOptions)options, operationContext).Result; XSCLProtocol.ServiceProperties sp = new XSCLProtocol.ServiceProperties(); sp.Clean(); sp.Cors = fileServiceProperties.Cors; sp.HourMetrics = fileServiceProperties.HourMetrics; sp.MinuteMetrics = fileServiceProperties.MinuteMetrics; return(sp); default: throw new ArgumentException(Resources.InvalidStorageServiceType, "type"); } } catch (AggregateException e) when(e.InnerException is XSCL.StorageException) { throw e.InnerException; } }
/// <summary> /// Set service properties /// </summary> /// <param name="account">Cloud storage account</param> /// <param name="type">Service type</param> /// <param name="properties">Service properties</param> /// <param name="options">Request options</param> /// <param name="operationContext">Operation context</param> public void SetStorageServiceProperties(StorageServiceType type, XSCLProtocol.ServiceProperties properties, IRequestOptions options, XSCL.OperationContext operationContext) { XSCL.CloudStorageAccount account = StorageContext.StorageAccount; try { switch (type) { case StorageServiceType.Blob: Task.Run(() => account.CreateCloudBlobClient().SetServicePropertiesAsync(properties, (BlobRequestOptions)options, operationContext)).Wait(); break; case StorageServiceType.Queue: Task.Run(() => account.CreateCloudQueueClient().SetServicePropertiesAsync(properties, (QueueRequestOptions)options, operationContext)).Wait(); break; case StorageServiceType.File: if (null != properties.Logging) { throw new InvalidOperationException(Resources.FileNotSupportLogging); } FileServiceProperties fileServiceProperties = new FileServiceProperties(); fileServiceProperties.Cors = properties.Cors; fileServiceProperties.HourMetrics = properties.HourMetrics; fileServiceProperties.MinuteMetrics = properties.MinuteMetrics; Task.Run(() => account.CreateCloudFileClient().SetServicePropertiesAsync(fileServiceProperties, (FileRequestOptions)options, operationContext)).Wait(); break; default: throw new ArgumentException(Resources.InvalidStorageServiceType, "type"); } } catch (AggregateException e) when(e.InnerException is XSCL.StorageException) { throw e.InnerException; } }