Example #1
0
        private async Task <IParseNode> GetRootParseNode(HttpResponseMessage response)
        {
            var responseContentType = response.Content.Headers?.ContentType?.MediaType?.ToLowerInvariant();

            if (string.IsNullOrEmpty(responseContentType))
            {
                throw new InvalidOperationException("no response content type header for deserialization");
            }
            using var contentStream = await response.Content.ReadAsStreamAsync();

            var rootNode = pNodeFactory.GetRootParseNode(responseContentType, contentStream);

            response.Dispose();
            return(rootNode);
        }
Example #2
0
        public IParseNode GetRootParseNode(string contentType, Stream content)
        {
            var node           = _concrete.GetRootParseNode(contentType, content);
            var originalBefore = node.OnBeforeAssignFieldValues;
            var originalAfter  = node.OnAfterAssignFieldValues;

            node.OnBeforeAssignFieldValues = (x) => {
                _onBefore?.Invoke(x);
                originalBefore?.Invoke(x);
            };
            node.OnAfterAssignFieldValues = (x) => {
                _onAfter?.Invoke(x);
                originalAfter?.Invoke(x);
            };
            return(node);
        }