public static void SetParentSyncState(IEnumerable <ServiceQuota> children, QuotaSyncState syncState) { if (children != null) { foreach (var child in children) { child.QuotaSyncState = syncState; } } }
public static void SetParentSyncState(IEnumerable<ServiceQuota> children, QuotaSyncState syncState) { if (children != null) { foreach (var child in children) { child.QuotaSyncState = syncState; } } }
/// <summary> /// Your documentation here. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/XXXXX.aspx /// for more information) /// </summary> /// <param name='planId'> /// Required. Your documentation here. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// Your documentation here. /// </returns> public async Task <PlanGetResult> GetAsync(string planId, CancellationToken cancellationToken) { // Validate if (planId == null) { throw new ArgumentNullException("planId"); } // Tracing bool shouldTrace = TracingAdapter.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = TracingAdapter.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("planId", planId); TracingAdapter.Enter(invocationId, this, "GetAsync", tracingParameters); } // Construct URL string url = ""; url = url + "/plans/"; url = url + Uri.EscapeDataString(planId); List <string> queryParameters = new List <string>(); queryParameters.Add("api-version=" + Uri.EscapeDataString(this.Client.ApiVersion)); if (queryParameters.Count > 0) { url = url + "?" + string.Join("&", queryParameters); } string baseUrl = this.Client.BaseUri.AbsoluteUri; // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl[baseUrl.Length - 1] == '/') { baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); } if (url[0] == '/') { url = url.Substring(1); } url = baseUrl + "/" + url; url = url.Replace(" ", "%20"); // Create HTTP transport objects HttpRequestMessage httpRequest = null; try { httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Get; httpRequest.RequestUri = new Uri(url); // Set Headers // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { TracingAdapter.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { TracingAdapter.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; if (statusCode != HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); if (shouldTrace) { TracingAdapter.Error(invocationId, ex); } throw ex; } // Create Result PlanGetResult result = null; // Deserialize Response if (statusCode == HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); result = new PlanGetResult(); JToken responseDoc = null; if (string.IsNullOrEmpty(responseContent) == false) { responseDoc = JToken.Parse(responseContent); } if (responseDoc != null && responseDoc.Type != JTokenType.Null) { PlanDefinition planInstance = new PlanDefinition(); result.Plan = planInstance; JToken nameValue = responseDoc["name"]; if (nameValue != null && nameValue.Type != JTokenType.Null) { string nameInstance = ((string)nameValue); planInstance.Name = nameInstance; } JToken displayNameValue = responseDoc["displayName"]; if (displayNameValue != null && displayNameValue.Type != JTokenType.Null) { string displayNameInstance = ((string)displayNameValue); planInstance.DisplayName = displayNameInstance; } JToken descriptionValue = responseDoc["description"]; if (descriptionValue != null && descriptionValue.Type != JTokenType.Null) { string descriptionInstance = ((string)descriptionValue); planInstance.Description = descriptionInstance; } JToken serviceQuotasArray = responseDoc["serviceQuotas"]; if (serviceQuotasArray != null && serviceQuotasArray.Type != JTokenType.Null) { foreach (JToken serviceQuotasValue in ((JArray)serviceQuotasArray)) { ServiceQuotaDefinition serviceQuotaDefinitionInstance = new ServiceQuotaDefinition(); planInstance.ServiceQuotas.Add(serviceQuotaDefinitionInstance); JToken resourceProviderIdValue = serviceQuotasValue["resourceProviderId"]; if (resourceProviderIdValue != null && resourceProviderIdValue.Type != JTokenType.Null) { string resourceProviderIdInstance = ((string)resourceProviderIdValue); serviceQuotaDefinitionInstance.ResourceProviderId = resourceProviderIdInstance; } JToken resourceProviderNamespaceValue = serviceQuotasValue["resourceProviderNamespace"]; if (resourceProviderNamespaceValue != null && resourceProviderNamespaceValue.Type != JTokenType.Null) { string resourceProviderNamespaceInstance = ((string)resourceProviderNamespaceValue); serviceQuotaDefinitionInstance.ResourceProviderNamespace = resourceProviderNamespaceInstance; } JToken resourceProviderDisplayNameValue = serviceQuotasValue["resourceProviderDisplayName"]; if (resourceProviderDisplayNameValue != null && resourceProviderDisplayNameValue.Type != JTokenType.Null) { string resourceProviderDisplayNameInstance = ((string)resourceProviderDisplayNameValue); serviceQuotaDefinitionInstance.ResourceProviderDisplayName = resourceProviderDisplayNameInstance; } JToken locationValue = serviceQuotasValue["location"]; if (locationValue != null && locationValue.Type != JTokenType.Null) { string locationInstance = ((string)locationValue); serviceQuotaDefinitionInstance.Location = locationInstance; } JToken quotaSyncStateValue = serviceQuotasValue["quotaSyncState"]; if (quotaSyncStateValue != null && quotaSyncStateValue.Type != JTokenType.Null) { QuotaSyncState quotaSyncStateInstance = ((QuotaSyncState)Enum.Parse(typeof(QuotaSyncState), ((string)quotaSyncStateValue), true)); serviceQuotaDefinitionInstance.QuotaSyncState = quotaSyncStateInstance; } JToken quotaSettingsValue = serviceQuotasValue["quotaSettings"]; if (quotaSettingsValue != null && quotaSettingsValue.Type != JTokenType.Null) { string quotaSettingsInstance = quotaSettingsValue.ToString(Newtonsoft.Json.Formatting.Indented); serviceQuotaDefinitionInstance.QuotaSettings = quotaSettingsInstance; } } } } } result.StatusCode = statusCode; if (shouldTrace) { TracingAdapter.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }