示例#1
0
        public static IParsingResult GetPostParsingValidationResult(XmlCurrencyTransactionEntry[] records)
        {
            if (records.All(r => r.IsValid))
            {
                return(XmlParsingResult.Create(true, null, records));
            }

            var errors = string.Join("\r\n", records.Where(r => !r.IsValid).Select(r => r.SummaryError));

            Trace.TraceError(errors);
            return(XmlParsingResult.Create(false, errors, records));
        }
        public async Task <IParsingResult> ParseTransactionsAsync(Stream stream)
        {
            try
            {
                using (var sr = new StreamReader(stream))
                {
                    var stringToDeserialize = await sr.ReadToEndAsync();

                    var xmlTransactions = DeserializeFromXmlStringAsync(stringToDeserialize).Validate();
                    return(XmlParsingStrategyEntryValidator.GetPostParsingValidationResult(xmlTransactions));
                }
            }
            catch (InvalidOperationException ex)
            {
                Trace.TraceError(ex.ExpandException(), ex);
                return(XmlParsingResult.Create(false, ex.Message, null));
            }
        }