Esempio n. 1
0
        public IMarketFileParseResult Parse(Stream stream)
        {
            var context  = new Import810Model();
            var document = XDocument.Load(stream);

            var documentElement = document.Root;

            if (documentElement == null)
            {
                throw new InvalidOperationException();
            }

            var namespaces = documentElement.Attributes()
                             .Where(x => x.IsNamespaceDeclaration)
                             .GroupBy(x => (x.Name.Namespace == XNamespace.None) ? string.Empty : x.Name.LocalName,
                                      x => XNamespace.Get(x.Value))
                             .ToDictionary(x => x.Key, x => x.First());

            XNamespace empty;

            if (!namespaces.TryGetValue(string.Empty, out empty))
            {
                empty = XNamespace.None;
            }

            var countElement = documentElement.Element(empty + "TransactionCount");

            if (countElement != null)
            {
                context.TransactionAuditCount = (int)countElement;
            }

            context.InterchangeControlNbr = documentElement.GetChildText(empty + "InterchangeControlNbr");

            var headerElements = documentElement.Descendants(empty + "Header");

            foreach (var headerElement in headerElements)
            {
                var header = ParseHeader(headerElement, namespaces);
                context.AddHeader(header);
                context.TransactionActualCount++;
            }

            return(context);
        }
Esempio n. 2
0
 public Prism810Context()
 {
     model = new Import810Model();
     stack = new Stack <IType810Model>();
 }