示例#1
0
        public override ObservableList <ApplicationAPIModel> ParseDocument(string FileName, bool avoidDuplicatesNodes = false)
        {
            ObservableList <ApplicationAPIModel> AAMSList = new ObservableList <ApplicationAPIModel>();
            ApplicationAPIModel AAM = new ApplicationAPIModel();

            AAM.Name = Path.GetFileNameWithoutExtension(FileName);
            ObservableList <AppModelParameter> AppModelParameters = new ObservableList <AppModelParameter>();
            XmlDocument doc = new XmlDocument();

            doc.Load(FileName);
            XMLDocExtended XDE = new XMLDocExtended(doc);

            if (avoidDuplicatesNodes)
            {
                XDE.RemoveDuplicatesNodes();
            }

            IEnumerable <XMLDocExtended>       NodeList = XDE.GetEndingNodes(false);
            ObservableList <AppModelParameter> AMPList  = new ObservableList <AppModelParameter>();

            foreach (XMLDocExtended XDN in NodeList)
            {
                string UniqPlaceHolder = "{" + GetPlaceHolderName(XDN.LocalName.ToUpper()) + "}";
                XDN.Value = UniqPlaceHolder;
                AMPList.Add(new AppModelParameter(UniqPlaceHolder, string.Empty, XDN.LocalName, XDN.XPath, new ObservableList <OptionalValue>()));

                if (XDN.Attributes != null && XDN.Attributes.Count > 0)
                {
                    foreach (XmlAttribute XmlAttribute in XDN.Attributes)
                    {
                        if (!string.IsNullOrEmpty(XmlAttribute.Prefix))
                        {
                            continue;
                        }

                        string UniqAttributePlaceHolder = "{" + GetPlaceHolderName(XmlAttribute.LocalName.ToUpper()) + "}";
                        XmlAttribute.Value = UniqAttributePlaceHolder;
                        AMPList.Add(new AppModelParameter(UniqAttributePlaceHolder, string.Empty, XmlAttribute.LocalName, XDN.XPath, new ObservableList <OptionalValue>()));
                    }
                }
            }

            AAM.RequestBody        = XDE.XMLString;
            AAM.AppModelParameters = AMPList;
            AAMSList.Add(AAM);
            AllPlaceHolders.Clear();
            return(AAMSList);
        }
示例#2
0
        private ObservableList <ApplicationAPIModel> GetParameters(XmlDocument doc, ObservableList <ApplicationAPIModel> AAMSList, bool avoidDuplicatesNodes)
        {
            ApplicationAPIModel AAM = new ApplicationAPIModel();

            AAM.Name = Path.GetFileNameWithoutExtension(doc.BaseURI);
            XMLDocExtended XDE = new XMLDocExtended(doc);

            if (avoidDuplicatesNodes)
            {
                XDE.RemoveDuplicatesNodes();
            }

            IEnumerable <XMLDocExtended>       NodeList = XDE.GetEndingNodes(false);
            ObservableList <AppModelParameter> AMPList  = GetParamList(NodeList);

            AAM.RequestBody        = XDE.XMLString;
            AAM.AppModelParameters = AMPList;
            AAMSList.Add(AAM);
            AllPlaceHolders.Clear();
            return(AAMSList);
        }