public Response Post(ExchangeContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(content, nameof(content)); using var message = CreatePostRequest(content); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: case 202: return(message.Response); default: throw new RequestFailedException(message.Response); } }
public async Task <Response> PostAsync(ExchangeContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(content, nameof(content)); using var message = CreatePostRequest(content); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: case 202: return(message.Response); default: throw new RequestFailedException(message.Response); } }
internal HttpMessage CreatePostRequest(ExchangeContent content) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/providers/Microsoft.Capacity/exchange", false); uri.AppendQuery("api-version", _apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); var content0 = new Utf8JsonRequestContent(); content0.JsonWriter.WriteObjectValue(content); request.Content = content0; _userAgent.Apply(message); return(message); }
protected override void OnBecameVisible(bool oldState, bool forward) { var args = GetWindowParam(name); if (args != null && args.param1 is ExchangeContent) { _content = (ExchangeContent)args.param1; } var prop = ConfigManager.Get <PropItemInfo>(_content.itemId); Util.SetItemInfo(itemRoot, prop, 0, _content.ownCount, false); Util.SetText(itemRoot.GetComponent <Text>("numberdi/count"), Util.Format(ConfigText.GetDefalutString(199, 8), _content.ownCount)); Util.SetText(needCountText, Util.Format(ConfigText.GetDefalutString(199, 6), BuyCount.ToString())); Util.SetText(priceText, Util.Format(ConfigText.GetDefalutString(199, 7), BuyCount * prop.diamonds)); Util.SetText(levelText, Util.Format(ConfigText.GetDefalutString(199, 10), prop.buyLevel)); priceText.color = ColorGroup.GetColor(ColorManagerType.IsMoneyEnough, IsMoneyEnough); bool level = modulePlayer.level >= prop.buyLevel ? true : false; levelText.color = level ? Color.white : Color.red; exchangeButton?.SetInteractable(IsMoneyEnough && level); }
public virtual ArmOperation <ExchangeOperationResultResponse> PostExchange(WaitUntil waitUntil, ExchangeContent content, CancellationToken cancellationToken = default) { using var scope = ExchangeClientDiagnostics.CreateScope("TenantResourceExtensionClient.PostExchange"); scope.Start(); try { var response = ExchangeRestClient.Post(content, cancellationToken); var operation = new ReservationsArmOperation <ExchangeOperationResultResponse>(new ExchangeOperationResultResponseOperationSource(), ExchangeClientDiagnostics, Pipeline, ExchangeRestClient.CreatePostRequest(content).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public static void Show(ExchangeContent rContent) { SetWindowParam <Window_Exchange>(rContent); ShowAsync <Window_Exchange>(); }
public static ArmOperation <ExchangeOperationResultResponse> PostExchange(this TenantResource tenantResource, WaitUntil waitUntil, ExchangeContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(content, nameof(content)); return(GetExtensionClient(tenantResource).PostExchange(waitUntil, content, cancellationToken)); }
public static async Task <ArmOperation <ExchangeOperationResultResponse> > PostExchangeAsync(this TenantResource tenantResource, WaitUntil waitUntil, ExchangeContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(content, nameof(content)); return(await GetExtensionClient(tenantResource).PostExchangeAsync(waitUntil, content, cancellationToken).ConfigureAwait(false)); }