private void DeserializeContent() { if (this.contentDeserialized) { return; } this.contentDeserialized = true; string pageXml; ApplicationManager.Application.GetPageContent( this.ID, out pageXml, PageInfo.piBasic, // 'piBasic' is the default XMLSchema.xs2013); Debug.Assert(!string.IsNullOrEmpty(pageXml)); var textReader = new StringReader(pageXml); var xmlReaderSettings = new XmlReaderSettings(); xmlReaderSettings.IgnoreComments = true; xmlReaderSettings.IgnoreWhitespace = true; xmlReaderSettings.IgnoreProcessingInstructions = true; XmlReader xmlReader = XmlReader.Create(textReader, xmlReaderSettings); var patchStore = new PatchStore(); if (!PageContentFormatter.Instance.Deserialize(xmlReader, this, patchStore)) { throw new Exception("could not parse page content"); } patchStore.PerformPatchOperations(this); }
public void PatchStoreDescription_Ok_PatchStoreWithJustDescription() { var ps = new PatchStore() { Description = "A new description" }; var store = Patch("abc", ps); Assert.Equal(store.Description, ps.Description); }
public Store Patch(string resourceId, PatchStore resource) { const string tictailJsonReponse = "{" + "\"description\": \"A new description\"," + "}"; var endpointDummy = new TictailEndpoint(new Uri("https://api.somewhere.com"), "accesstoken_abcdefhiljklmnopqrstuvxuz"); var clientTest = new TictailClientTest(endpointDummy); clientTest.Content = tictailJsonReponse; var repository = new TictailRepository(clientTest); return(repository.Stores.Patch(resourceId, resource)); }
/// <summary> /// Patch (Update) a store /// </summary> /// <param name="storeId">ID of store to patch</param> /// <param name="store">Values which should be updated, null are ignored</param> public Store Patch(string storeId, PatchStore store) { if (string.IsNullOrEmpty(storeId)) { throw new Exception("You can't specify an empty storeId"); } var request = new RestRequest("v1/stores/{storeId}", Method.PATCH); request.AddUrlSegment("storeId", storeId); request.RequestFormat = DataFormat.Json; var serializer = new JsonSerializer { NullValueHandling = NullValueHandling.Ignore }; string bodyContent; using (var writer = new StringWriter()) { serializer.Serialize(writer, store); bodyContent = writer.ToString(); } request.AddParameter("application/json", bodyContent, ParameterType.RequestBody); Store patchedStore; try { patchedStore = DeserializeGet(_client.ExecuteRequest(request, HttpStatusCode.OK).Content); } catch (KeyNotFoundException) { throw new Exception("No Store found with ID : " + storeId); } return(patchedStore); }