// // Summary: // Initializes a new instance of the PSSeriviceProperties class from old XSCL service properties. public PSSeriviceProperties(XTable.ServiceProperties properties) { if (properties != null) { this.Logging = new LoggingProperties() { Version = properties.Logging.Version, RetentionDays = properties.Logging.RetentionDays, LoggingOperations = (LoggingOperations)Enum.Parse(typeof(LoggingOperations), properties.Logging.LoggingOperations.ToString(), true), }; this.HourMetrics = new MetricsProperties() { Version = properties.HourMetrics.Version, RetentionDays = properties.HourMetrics.RetentionDays, MetricsLevel = (MetricsLevel)Enum.Parse(typeof(MetricsLevel), properties.HourMetrics.MetricsLevel.ToString(), true), }; this.MinuteMetrics = new MetricsProperties() { Version = properties.MinuteMetrics.Version, RetentionDays = properties.MinuteMetrics.RetentionDays, MetricsLevel = (MetricsLevel)Enum.Parse(typeof(MetricsLevel), properties.MinuteMetrics.MetricsLevel.ToString(), true), }; this.DefaultServiceVersion = properties.DefaultServiceVersion; this.Cors = PSCorsRule.ParseCorsRules(properties.Cors); } }
// // Summary: // Initializes a new instance of the PSSeriviceProperties class from track 2 service properties. public PSSeriviceProperties(TableServiceProperties properties) { if (properties != null) { this.Logging = PSSeriviceProperties.ConvertLoggingProperties(properties.Logging); this.HourMetrics = PSSeriviceProperties.ConvertMetricsProperties(properties.HourMetrics); this.MinuteMetrics = PSSeriviceProperties.ConvertMetricsProperties(properties.MinuteMetrics); this.DefaultServiceVersion = string.Empty; this.Cors = PSCorsRule.ParseCorsRules(properties.Cors); } }
// // Summary: // Initializes a new instance of the PSSeriviceProperties class. public PSSeriviceProperties(ServiceProperties properties) { if (properties != null) { this.Logging = properties.Logging; this.HourMetrics = properties.HourMetrics; this.MinuteMetrics = properties.MinuteMetrics; this.DefaultServiceVersion = properties.DefaultServiceVersion; this.Cors = PSCorsRule.ParseCorsRules(properties.Cors); } }
// // Summary: // Initializes a new instance of the PSSeriviceProperties class. public PSSeriviceProperties(ServiceProperties properties) { if (properties != null) { this.Logging = properties.Logging; this.HourMetrics = properties.HourMetrics; this.MinuteMetrics = properties.MinuteMetrics; this.DefaultServiceVersion = properties.DefaultServiceVersion; this.Cors = PSCorsRule.ParseCorsRules(properties.Cors); this.DeleteRetentionPolicy = PSDeleteRetentionPolicy.ParsePSDeleteRetentionPolicy(properties.DeleteRetentionPolicy); this.StaticWebsite = PSStaticWebsiteProperties.ParsePSStaticWebsiteProperties(properties.StaticWebsite); } }
public override void ExecuteCmdlet() { ServiceProperties currentServiceProperties = Channel.GetStorageServiceProperties(ServiceType, GetRequestOptions(ServiceType), OperationContext); List<PSCorsRule> ruleList = new List<PSCorsRule>(); foreach (var corsRule in currentServiceProperties.Cors.CorsRules) { PSCorsRule psCorsRule = new PSCorsRule(); psCorsRule.AllowedOrigins = this.ListToArray(corsRule.AllowedOrigins); psCorsRule.AllowedHeaders = this.ListToArray(corsRule.AllowedHeaders); psCorsRule.ExposedHeaders = this.ListToArray(corsRule.ExposedHeaders); psCorsRule.AllowedMethods = this.ConvertCorsHttpMethodToString(corsRule.AllowedMethods); psCorsRule.MaxAgeInSeconds = corsRule.MaxAgeInSeconds; ruleList.Add(psCorsRule); } WriteObject(ruleList.ToArray()); }
/// <summary> /// Parse Cors Rules from XSCL to PSCorsRule Array /// </summary> /// <param name="corsProperties">Cors Rules from XSCL</param> /// <returns>PSCorsRule Array</returns> public static PSCorsRule[] ParseCorsRules(CorsProperties corsProperties) { List <PSCorsRule> ruleList = new List <PSCorsRule>(); if (corsProperties != null && corsProperties.CorsRules != null) { foreach (var corsRule in corsProperties.CorsRules) { PSCorsRule psCorsRule = new PSCorsRule(); psCorsRule.AllowedOrigins = ListToArray(corsRule.AllowedOrigins); psCorsRule.AllowedHeaders = ListToArray(corsRule.AllowedHeaders); psCorsRule.ExposedHeaders = ListToArray(corsRule.ExposedHeaders); psCorsRule.AllowedMethods = ConvertCorsHttpMethodToString(corsRule.AllowedMethods); psCorsRule.MaxAgeInSeconds = corsRule.MaxAgeInSeconds; ruleList.Add(psCorsRule); } } return(ruleList.ToArray()); }
/// <summary> /// Parse Cors Rules from OLD XSCL to PSCorsRule Array /// </summary> /// <param name="tableCorsRules">Cors Rules from XSCL</param> /// <returns>PSCorsRule Array</returns> public static PSCorsRule[] ParseCorsRules(IList <TableCorsRule> tableCorsRules) { List <PSCorsRule> ruleList = new List <PSCorsRule>(); if (tableCorsRules != null) { foreach (TableCorsRule corsRule in tableCorsRules) { PSCorsRule psCorsRule = new PSCorsRule(); psCorsRule.AllowedOrigins = corsRule.AllowedOrigins.Split(','); psCorsRule.AllowedHeaders = corsRule.AllowedHeaders.Split(','); psCorsRule.ExposedHeaders = corsRule.ExposedHeaders.Split(','); psCorsRule.AllowedMethods = corsRule.AllowedMethods.Split(','); psCorsRule.MaxAgeInSeconds = corsRule.MaxAgeInSeconds; ruleList.Add(psCorsRule); } } return(ruleList.ToArray()); }