/// <summary> /// This method is used to retrieve the specified Editor Xml Model. /// </summary> /// <param name="client"><see cref="InspireClient"/> used to communication with the API endpoint.</param> /// <param name="model">Contains the component load editor model.</param> /// <returns>Returns the <see cref="MinimalEditorXmlModel"/> object that represents the editor record created.</returns> public static MinimalEditorXmlModel FindEditorComponent(this InspireClient client, EditorLoadModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (model.ComponentId == 0 && string.IsNullOrWhiteSpace(model.Href)) { throw new ArgumentException(Resources.InvalidEditorRequestMissingComponentErrorText, nameof(model)); } string queryTemplate = "&editorMode={0}&editorType={1}&schema={2}&version={3}&mapReferenceId={4}"; string query = string.Format(queryTemplate, model.EditorMode, model.EditorType, WebUtility.UrlEncode(model.SchemaType), WebUtility.UrlEncode(model.Version), model.MapReferenceId); if (model.ResolveReferences) { query += "&resolveReferences=true"; } if (model.ChangesetId != Guid.Empty) { query += "&changesetId=" + model.ChangesetId.ToString(); } if (model.EditorMode == EditorMode.Review) { query += "&reviewMode=" + model.ReviewMode.ToString(); } query = (model.ComponentId > 0 ? "componentId=" + model.ComponentId.ToString() : "href=" + model.Href) + query; var request = client.CreateRequest($"/Editor?{query}"); return(client.RequestContent <MinimalEditorXmlModel>(request)); }
public static MinimalEditorXmlModel GetEditorComponent(this InspireClient client, EditorLoadModel model) { return(FindEditorComponent(client, model)); }