本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Shared.Protocol.ServiceProperties类的典型用法代码示例。如果您正苦于以下问题:C# ServiceProperties类的具体用法?C# ServiceProperties怎么用?C# ServiceProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServiceProperties类属于Microsoft.WindowsAzure.Storage.Shared.Protocol命名空间,在下文中一共展示了ServiceProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FileServiceProperties
/// <summary>
/// Initializes a new instance of the <see cref="FileServiceProperties"/> class.
/// </summary>
public FileServiceProperties()
{
this.serviceProperties = new ServiceProperties();
this.serviceProperties.HourMetrics = null;
this.serviceProperties.MinuteMetrics = null;
this.serviceProperties.Logging = null;
}
示例2: SetServiceProperties
public Task SetServiceProperties(ServiceProperties properties, BlobRequestOptions requestOptions = null, OperationContext operationContext = null, CancellationToken cancellationToken = default(CancellationToken))
{
return AsyncTaskUtil.RunAsyncCancellable(
_inner.BeginSetServiceProperties(properties, requestOptions, operationContext, null, null),
_inner.EndSetServiceProperties,
cancellationToken);
}
示例3: StorageSettings
public StorageSettings(string storageName, ServiceProperties serviceProperties)
{
InitializeComponent();
this.Icon = Bitmaps.Azure_Explorer_ico;
labelStorageAccount.Text = string.Format(labelStorageAccount.Text, storageName);
_serviceProperties = serviceProperties;
}
示例4: InitializeCors
private void InitializeCors()
{
var tableServiceProperties = new ServiceProperties();
var tableClient =
new CloudStorageAccount(
new StorageCredentials(
CloudConfigurationManager.GetSetting("storageAccountName"),
CloudConfigurationManager.GetSetting("storageAccountKey")),
true).CreateCloudTableClient();
tableServiceProperties.HourMetrics = null;
tableServiceProperties.MinuteMetrics = null;
tableServiceProperties.Logging = null;
tableServiceProperties.Cors = new CorsProperties();
tableServiceProperties.Cors.CorsRules.Add(new CorsRule()
{
AllowedHeaders = new List<string>() { "*" },
AllowedMethods = CorsHttpMethods.Get | CorsHttpMethods.Head ,
//AllowedOrigins = new List<string>() { "http://ercenkbike.azurewebsites.net/" },
AllowedOrigins = new List<string>() { "*" },
ExposedHeaders = new List<string>() { "*" },
MaxAgeInSeconds = 1800 // 30 minutes
});
tableClient.SetServiceProperties(tableServiceProperties);
}
示例5: MyTestInitialize
public void MyTestInitialize()
{
props = DefaultServiceProperties();
if (TestBase.QueueBufferManager != null)
{
TestBase.QueueBufferManager.OutstandingBufferCount = 0;
}
}
示例6: MyClassInitialize
public static void MyClassInitialize(TestContext testContext)
{
CloudQueueClient client = GenerateCloudQueueClient();
startProperties = client.GetServiceProperties();
if (TestBase.QueueBufferManager != null)
{
TestBase.QueueBufferManager.OutstandingBufferCount = 0;
}
}
示例7: ExecuteCmdlet
public override void ExecuteCmdlet()
{
ServiceProperties currentServiceProperties = Channel.GetStorageServiceProperties(ServiceType, GetRequestOptions(ServiceType), OperationContext);
ServiceProperties serviceProperties = new ServiceProperties();
serviceProperties.Clean();
serviceProperties.Cors = currentServiceProperties.Cors;
serviceProperties.Cors.CorsRules.Clear();
Channel.SetStorageServiceProperties(ServiceType, serviceProperties,
GetRequestOptions(ServiceType), OperationContext);
}
示例8: ConfigureCors
private void ConfigureCors(ServiceProperties serviceProperties)
{
serviceProperties.Cors = new CorsProperties();
serviceProperties.Cors.CorsRules.Add(new CorsRule
{
AllowedHeaders = new[] { "*" },
AllowedMethods = CorsHttpMethods.Get | CorsHttpMethods.Head,
AllowedOrigins = new[] { "*" },
ExposedHeaders = new[] { "Cache-Control", "Content-Type", "Last-Modified", "ETag", "Accept-Ranges" },
MaxAgeInSeconds = 31536000
});
}
示例9: ConfigureCors
/// <summary>
/// Adds CORS rule to the service properties.
/// </summary>
/// <param name="serviceProperties">ServiceProperties</param>
private static void ConfigureCors(ServiceProperties serviceProperties)
{
serviceProperties.Cors = new CorsProperties();
serviceProperties.Cors.CorsRules.Add(new CorsRule()
{
AllowedHeaders = new List<string>() { "*" },
AllowedMethods = CorsHttpMethods.Put | CorsHttpMethods.Get | CorsHttpMethods.Head | CorsHttpMethods.Post,
AllowedOrigins = new List<string>() { "*" },
ExposedHeaders = new List<string>() { "*" },
MaxAgeInSeconds = 1800 // 30 minutes
});
}
示例10: SetServicePropertiesAsync
/// <summary>
/// Sets the properties of the table service asynchronously.
/// </summary>
/// <param name="tableClient">Cloud table client.</param>
/// <param name="serviceProperties">The table service properties.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Task.</returns>
public static Task SetServicePropertiesAsync(
this CloudTableClient tableClient,
ServiceProperties serviceProperties,
CancellationToken cancellationToken = default (CancellationToken))
{
ICancellableAsyncResult asyncResult = tableClient.BeginSetServiceProperties(serviceProperties, null, null);
CancellationTokenRegistration registration = cancellationToken.Register(p => asyncResult.Cancel(), null);
return Task.Factory.FromAsync(
asyncResult,
result =>
{
registration.Dispose();
tableClient.EndSetServiceProperties(result);
});
}
示例11: ExecuteCmdlet
public override void ExecuteCmdlet()
{
ServiceProperties serviceProperties = new ServiceProperties();
serviceProperties.Clean();
serviceProperties.Cors = new CorsProperties();
foreach (var corsRuleObject in this.CorsRules)
{
CorsRule corsRule = new CorsRule();
corsRule.AllowedHeaders = corsRuleObject.AllowedHeaders;
corsRule.AllowedOrigins = corsRuleObject.AllowedOrigins;
corsRule.ExposedHeaders = corsRuleObject.ExposedHeaders;
corsRule.MaxAgeInSeconds = corsRuleObject.MaxAgeInSeconds;
this.SetAllowedMethods(corsRule, corsRuleObject.AllowedMethods);
serviceProperties.Cors.CorsRules.Add(corsRule);
}
try
{
Channel.SetStorageServiceProperties(ServiceType, serviceProperties,
GetRequestOptions(ServiceType), OperationContext);
}
catch (StorageException se)
{
if ((null != se.RequestInformation) &&
((int)HttpStatusCode.BadRequest == se.RequestInformation.HttpStatusCode) &&
(null != se.RequestInformation.ExtendedErrorInformation) &&
(string.Equals(InvalidXMLNodeValueError, se.RequestInformation.ExtendedErrorInformation.ErrorCode, StringComparison.OrdinalIgnoreCase) ||
string.Equals(InvalidXMLDocError, se.RequestInformation.ExtendedErrorInformation.ErrorCode, StringComparison.OrdinalIgnoreCase)))
{
throw new InvalidOperationException(Resources.CORSRuleError);
}
else
{
throw;
}
}
if (PassThru)
{
WriteObject(this.CorsRules);
}
}
示例12: Main
static void Main(string[] args)
{
StorageCredentials storageCredentials = new StorageCredentials(args[0], args[1]);
CloudStorageAccount storageAccount = new CloudStorageAccount(storageCredentials, true);
var blobClient = storageAccount.CreateCloudBlobClient();
// Define our basics for quick op
ServiceProperties blobServiceProperties = new ServiceProperties()
{
HourMetrics = null,
MinuteMetrics = null,
Logging = null,
};
// Define our CORS rules (wide open here)
CorsRule corsRule = new CorsRule()
{
AllowedHeaders = new List<string>() { "*" },
AllowedMethods = CorsHttpMethods.Get | CorsHttpMethods.Post | CorsHttpMethods.Head | CorsHttpMethods.Put,
AllowedOrigins = new List<string>() { "*" },
ExposedHeaders = new List<string>() { "*", "Accept-Ranges", "Content-Range"},
MaxAgeInSeconds = 7200
};
// Set our rule
blobServiceProperties.Cors.CorsRules.Add(corsRule);
try
{
blobClient.SetServiceProperties(blobServiceProperties);
Console.Out.WriteLine("CORS is rollin' for " + args[0]);
}
catch (Exception e)
{
Console.Out.WriteLine(e.ToString());
}
}
示例13: SetServicePropertiesAsync
public IAsyncAction SetServicePropertiesAsync(ServiceProperties properties, BlobRequestOptions requestOptions, OperationContext operationContext)
{
BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(requestOptions, BlobType.Unspecified, this);
operationContext = operationContext ?? new OperationContext();
return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn(
this.SetServicePropertiesImpl(properties, modifiedOptions),
modifiedOptions.RetryPolicy,
operationContext,
token));
}
示例14: SetStorageServiceProperties
/// <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, ServiceProperties properties, IRequestOptions options, OperationContext operationContext)
{
CloudStorageAccount account = StorageContext.StorageAccount;
switch (type)
{
case StorageServiceType.Blob:
account.CreateCloudBlobClient().SetServiceProperties(properties, (BlobRequestOptions)options, operationContext);
break;
case StorageServiceType.Queue:
account.CreateCloudQueueClient().SetServiceProperties(properties, (QueueRequestOptions)options, operationContext);
break;
case StorageServiceType.Table:
account.CreateCloudTableClient().SetServiceProperties(properties, (TableRequestOptions)options, operationContext);
break;
default:
throw new ArgumentException(Resources.InvalidStorageServiceType, "type");
}
}
示例15: DefaultServiceProperties
private static ServiceProperties DefaultServiceProperties()
{
ServiceProperties props = new ServiceProperties();
props.Logging.LoggingOperations = LoggingOperations.None;
props.Logging.RetentionDays = null;
props.Logging.Version = "1.0";
props.HourMetrics.MetricsLevel = MetricsLevel.None;
props.HourMetrics.RetentionDays = null;
props.HourMetrics.Version = "1.0";
props.MinuteMetrics.MetricsLevel = MetricsLevel.None;
props.MinuteMetrics.RetentionDays = null;
props.MinuteMetrics.Version = "1.0";
props.Cors.CorsRules = new List<CorsRule>();
return props;
}