public void LoadModel(JSONDataSourceModel m) { // Keep all the http parameters locally, we will need them in order to provide the custom HTTP parameter dialog _tmpParams = m.HttpParameters; _tmpHeaders = m.HttpHeaders; // Fill in the rest of the view using model data directInputR.Checked = m.UriBindingType == ParamBinding.CustomValue; variableR.Checked = m.UriBindingType == ParamBinding.Variable; inputLaneR.Checked = m.UriBindingType == ParamBinding.InputField; inputLaneR.Enabled = _inputs.Count > 0; inputLaneCb.SelectedItem = m.UriBindingValue; uiWebURL.Text = m.UriBindingValue.ToString(); switch (m.WebMethod) { case "GET": getRadio.Checked = true; break; case "POST": postRadio.Checked = true; break; case "PUT": putRadio.Checked = true; break; case "DELETE": delRadio.Checked = true; break; default: getRadio.Checked = true; break; } if (String.IsNullOrEmpty(m.CookieVariable)) { cookieVarTb.Text = ""; } else { cookieVarTb.Text = m.CookieVariable; } }
/// <summary> /// Returns the current view configuration into a model object /// </summary> /// <returns></returns> public JSONDataSourceModel SaveToModel() { JSONDataSourceModel result = new JSONDataSourceModel(); if (variableR.Checked) { result.UriBindingType = ParamBinding.Variable; result.UriBindingValue = uiWebURL.Text; } else if (directInputR.Checked) { result.UriBindingType = ParamBinding.CustomValue; result.UriBindingValue = uiWebURL.Text; } else if (inputLaneR.Checked) { result.UriBindingType = ParamBinding.InputField; result.UriBindingValue = inputLaneCb.SelectedItem.ToString(); } else { throw new ApplicationException("Invalid Input model specified. Please contact the developer."); } if (getRadio.Checked) { result.WebMethod = "GET"; } else if (postRadio.Checked) { result.WebMethod = "POST"; } else if (putRadio.Checked) { result.WebMethod = "PUT"; } else if (delRadio.Checked) { result.WebMethod = "DELETE"; } result.HttpParameters = GetHttpParameters(); result.HttpHeaders = GetHttpHeaders(); result.CookieVariable = String.IsNullOrEmpty(cookieVarTb.Text) ? null : cookieVarTb.Text; return(result); }
public JSONSourceComponentModel() { DataSource = new JSONDataSourceModel(); DataMapping = new JSONDataMappingModel(); AdvancedSettings = new JSONAdvancedSettingsModel(); }
public static JSONDataSourceModel LoadFromJson(string jsonConfig) { JSONDataSourceModel res = JsonConvert.DeserializeObject <JSONDataSourceModel>(jsonConfig); return(res); }