コード例 #1
0
        private XmlCamt053Entry FillNtryFromXml(XmlNode xmlNodeNtry)
        {
            XmlCamt053Entry xmlCamt053Entry = new XmlCamt053Entry();

            GetValuesFromNtryList(xmlNodeNtry, xmlCamt053Entry);                     // Recursive call

            return(xmlCamt053Entry);
        }
コード例 #2
0
        private static void GetValueFromXmlNode(XmlNode xmlNode, XmlCamt053Entry xmlCamt053Entry)
        {
            Type xmlCamt053EntryType = xmlCamt053Entry.GetType();

            PropertyInfo[] propertyInfos = xmlCamt053EntryType.GetProperties();

            foreach (var propertyInfo in propertyInfos)
            {
                if (propertyInfo.Name.Equals(xmlNode.Name))
                {
                    var nodeValue = xmlNode.InnerText;
                    propertyInfo.SetValue(xmlCamt053Entry, nodeValue);
                }
            }
        }
コード例 #3
0
 // Recursive iteration with a XmlNode over begin xml file or node eg root node
 private static void GetValuesFromNtryList(XmlNode xmlNode, XmlCamt053Entry xmlCamt053Entry)
 {
     if (xmlNode.HasChildNodes)
     {
         for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
         {
             GetValuesFromNtryList(xmlNode.ChildNodes[i], xmlCamt053Entry);                     // Recursive call
         }
     }
     if (xmlNode.Value != null || xmlNode.InnerText != "")
     {
         // Console.WriteLine($"{xmlNode.Name} - {xmlNode.InnerText}");
         GetValueFromXmlNode(xmlNode, xmlCamt053Entry);
     }
 }
コード例 #4
0
        private XmlCamt053Entry CreateXmlCamt053Entry(string xmlResult)
        {
            var  xmlCamt053Entry = new XmlCamt053Entry();
            Type xmlCamtTagsType = xmlCamt053Entry.GetType();

            PropertyInfo[] xmlTagsProperties = xmlCamtTagsType.GetProperties();

            foreach (var xmlTagsPropertie in xmlTagsProperties)
            {
                var valueFromXml = this.GetValueBetweenTags(xmlTagsPropertie.Name, xmlResult);

                xmlCamt053Entry.GetType()
                .GetProperty(xmlTagsPropertie.Name)
                .SetValue(xmlCamt053Entry, valueFromXml);
            }
            return(xmlCamt053Entry);
        }
コード例 #5
0
        private string SetEntriesFromCamt(XmlCamt053 xmlCamt, string xml)
        {
            string ntryTagName = "Ntry";
            string beginTag    = $"<{ntryTagName}>";
            string endTag      = $"</{ntryTagName}>";

            string[] xmlTags   = xml.Split(@"<");
            string   xmlResult = "";
            bool     isMatch   = false;

            for (int i = 0; i < xmlTags.Length; i++)
            {
                if (Regex.IsMatch(@"<" + xmlTags[i], beginTag))
                {
                    isMatch = true;
                    i++;
                }
                if (Regex.IsMatch(@"<" + xmlTags[i], endTag))
                {
                    isMatch = false;
                    XmlCamt053Entry xmlCamt053Entry = this.CreateXmlCamt053Entry(xmlResult);

                    // xmlCamt.Ntry.Add(xmlCamt053Entry.NtryRef, xmlCamt053Entry);
                }

                if (isMatch)
                {
                    xmlResult += $"<{xmlTags[i]}";
                }
                if (!isMatch)
                {
                    xmlResult = string.Empty;
                }
            }
            return("");
        }