예제 #1
0
        internal virtual DeserializeResponse Deserialize(string payload)
        {
            using (new MethodLogger(s_logger))
            {
                var doc = XDocument.Parse(payload);
                var xph = new XPathHelper(doc, Namespaces);
                int.TryParse(xph.GetTechReturnCode()?.Value, out var techCode);
                int.TryParse(xph.GetBusReturnCode()?.Value, out var busCode);
                int.TryParse(xph.GetNumSegments()?.Value, out var numSegments);
                int.TryParse(xph.GetSegmentNumber()?.Value, out var segmentNo);
                bool.TryParse(xph.GetSegmentNumber()?.Attribute(XmlNames.lastSegment)?.Value, out var lastSegment);
                Enum.TryParse <TransactionPhase>(xph.GetTransactionPhase()?.Value, out var transPhase);

                var dr = new DeserializeResponse
                {
                    BusinessReturnCode  = busCode,
                    TechnicalReturnCode = techCode,
                    NumSegments         = numSegments,
                    SegmentNumber       = segmentNo,
                    LastSegment         = lastSegment,
                    TransactionId       = xph.GetTransactionID()?.Value,
                    Phase      = transPhase,
                    ReportText = xph.GetReportText()?.Value
                };

                s_logger.LogDebug("DeserializeResponse: {response}", dr);
                return(dr);
            }
        }