Exemplo n.º 1
0
        public void Update(string name, XElement value, HttpRequestMessage request)
        {
            XElement original = GetOriginal(value);

            var service = new XmlModificationService(name, request.GetQueryNameValuePairs());

            if (original == null)
            {
                service.Update(value);
            }
            else
            {
                original.Remove();
                service.Update(value, original);
            }
        }
Exemplo n.º 2
0
        public HttpResponseMessage Create(string name, XElement value, HttpRequestMessage request)
        {
            XmlModificationService modificationService = new XmlModificationService(name, request.GetQueryNameValuePairs());

            string mediaType = request.GetResponseMediaType();

            switch (mediaType)
            {
            case "application/json":
            {
                modificationService.Create(value, out string json);
                return(CreateHttpResponseMessage(json, request));
            }

            case "application/xml":
            {
                modificationService.Create(value, out XElement element);
                return(CreateHttpResponseMessage(element, request));
            }

            default:
                throw new NotSupportedException(mediaType.ToString());
            }
        }