/// <summary> /// Helper method called when user select a Rest action /// </summary> /// <param name="restAction"></param> private void SwitchToRestAction(RestAction restAction, string path) { ShowResponse(null); var requestPath = string.Empty; string restActionStr = restAction.ToString(); _viewModel[RestActionViewModel.SELECTED_REST_ACTION] = restActionStr; if (!String.IsNullOrWhiteSpace(path)) { var account = AccountManager.GetAccount(); requestPath = String.Format(path, ApiVersionStrings.VersionNumber, account.UserId); _viewModel[RestActionViewModel.REQUEST_PATH] = requestPath; } HashSet <string> names = RestActionViewHelper.GetNamesOfControlsToShow(restActionStr); foreach (TextBox tb in new[] { tbApiVersion, tbObjectType, tbObjectId, tbExternalIdField, tbExternalId, tbFieldList, tbFields, tbSoql, tbSosl, tbRequestPath, tbRequestBody, tbRequestMethod }) { tb.Visibility = names.Contains(tb.Name) ? Visibility.Visible : Visibility.Collapsed; tb.BorderThickness = new Thickness(0, 0, 0, 0); } if (!String.IsNullOrWhiteSpace(path)) { tbRequestPath.Text = requestPath; } }
/// <summary> /// Helper method called when user select a Rest action /// </summary> /// <param name="restAction"></param> private void SwitchToRestAction(RestAction restAction) { ShowResponse(null); string restActionStr = restAction.ToString(); _viewModel[RestActionViewModel.SELECTED_REST_ACTION] = restActionStr; HashSet <string> names = RestActionViewHelper.GetNamesOfControlsToShow(restActionStr); foreach (TextBox tb in new TextBox[] { tbApiVersion, tbObjectType, tbObjectId, tbExternalIdField, tbExternalId, tbFieldList, tbFields, tbSoql, tbSosl, tbRequestPath, tbRequestBody, tbRequestMethod }) { tb.Visibility = names.Contains(tb.Name) ? Visibility.Visible : Visibility.Collapsed; } }
/// <summary> /// When page is navigated to, we first parse the rest action name out of the URI /// Then we hide/show the input controls that should be visible for that action /// </summary> /// <param name="e"></param> protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); string restActionStr = e.Parameter.ToString(); _viewModel[RestActionViewModel.SELECTED_REST_ACTION] = restActionStr; HashSet <string> names = RestActionViewHelper.GetNamesOfControlsToShow(restActionStr); foreach (TextBox tb in new TextBox[] { tbApiVersion, tbObjectType, tbObjectId, tbExternalIdField, tbExternalId, tbFieldList, tbFields, tbSoql, tbSosl, tbRequestPath, tbRequestBody, tbRequestMethod }) { tb.Visibility = names.Contains(tb.Name) ? Visibility.Visible : Visibility.Collapsed; } }
/// <summary> /// Helper method to show a RestResponse (formatted) in the result webview control /// </summary> /// <param name="response"></param> private void ShowResponse(RestResponse response) { wbResult.NavigateToString(RestActionViewHelper.BuildHtml(response)); }