コード例 #1
0
        public static ArrayList ParseFromXml(XmlNode root, IList entities, IPropertyContainer entity, Hashtable sqltypes, Hashtable types, ParserValidationDelegate vd)
        {
            ArrayList   finders  = new ArrayList();
            XmlNodeList elements = null;

            foreach (XmlNode n in root.ChildNodes)
            {
                if (n.Name.Equals("finders"))
                {
                    elements = n.ChildNodes;
                    break;
                }
            }
            if (elements != null)
            {
                foreach (XmlNode node in elements)
                {
                    if (node.NodeType == XmlNodeType.Comment)
                    {
                        continue;
                    }
                    ReportExtractionFinderElement finder = new ReportExtractionFinderElement();
                    finder.Name   = node.Attributes["name"].Value;
                    finder.Fields = PropertyElement.ParseFromXml(GetChildNodeByName(node, PROPERTIES), entities, entity, sqltypes, types, true, vd);
                    BuildElement(node, entity, finder, vd);
                    finders.Add(finder);
                }
            }

            return(finders);
        }
コード例 #2
0
 /// <summary>
 /// Parse only method. Parses and adds all entities found in the given node and adds them to the given
 /// list.
 /// </summary>
 /// <param name="node"></param>
 /// <param name="finderElements"></param>
 public static new void ParseFromXml(XmlNode node, IList finderElements)
 {
     if (node != null && finderElements != null)
     {
         foreach (XmlNode finderNode in node.ChildNodes)
         {
             if (finderNode.NodeType.Equals(XmlNodeType.Element))
             {
                 ReportExtractionFinderElement finderElement = new ReportExtractionFinderElement();
                 BuildElement(finderNode, finderElement);
                 finderElements.Add(finderElement);
             }
         }
     }
 }
コード例 #3
0
        /// <summary>
        /// Second pass parse and validation.
        /// </summary>
        /// <param name="options">Configuration options.</param>
        /// <param name="doc">Document being parsed.</param>
        /// <param name="sqltypes">List of sql types defined.</param>
        /// <param name="types">List of .Net types defined.</param>
        /// <param name="entities">List of EntityElement objects defined.</param>
        /// <param name="vd">Validation delegate for error reporting.</param>
        /// <returns>Validated list of report extractions.</returns>
        public static ArrayList ParseFromXml(Configuration options, XmlDocument doc, Hashtable sqltypes, Hashtable types, IList entities, ParserValidationDelegate vd)
        {
            ArrayList   reportExtractions = new ArrayList();
            XmlNodeList elements          = doc.DocumentElement.GetElementsByTagName("reportextraction");

            foreach (XmlNode node in elements)
            {
                if (node.NodeType == XmlNodeType.Comment)
                {
                    continue;
                }
                ReportExtractionElement reportExtraction = new ReportExtractionElement();
                if (node.Attributes[NAME] != null)
                {
                    reportExtraction.Name = node.Attributes[NAME].Value;
                }
                else
                {
                    vd(ParserValidationArgs.NewError("A report extraction must have a name."));
                }
                if (node.Attributes[HINTS] != null)
                {
                    reportExtraction.Hints = (string)(node.Attributes[HINTS].Value);
                }
                if (node.Attributes[HAVING] != null)
                {
                    reportExtraction.Having = (string)(node.Attributes[HAVING].Value);
                }

                reportExtraction.EntityReferences = EntityReferenceElement.ParseFromXml(options, GetChildNodeByName(node, ENTITY_REFERENCES), reportExtraction, types, sqltypes, entities, vd);
                XmlNode computedProperties = GetChildNodeByName(node, COMPUTED_PROPERTIES);
                if (computedProperties != null)
                {
                    reportExtraction.ComputedProperties = PropertyElement.ParseFromXml(computedProperties, entities, reportExtraction, sqltypes, types, false, vd);
                }
                reportExtraction.ValidateFilters(vd);
                reportExtraction.ValidateExpressions(vd);
                reportExtraction.ValidateUniqueNames(vd);
                reportExtraction.ValidateDatabases(vd);
                reportExtractions.Add(reportExtraction);
                reportExtraction.Having = Configuration.PrepareExpression(reportExtraction.Having, reportExtraction, "having attribute in report extraction " + reportExtraction.Name, vd);

                // Make sure finders get prepared expressions!
                reportExtraction.Comparers = ComparerElement.ParseFromXml(node, entities, reportExtraction, sqltypes, types, vd);
                reportExtraction.Finders   = ReportExtractionFinderElement.ParseFromXml(node, entities, reportExtraction, sqltypes, types, vd);
            }
            return(reportExtractions);
        }
コード例 #4
0
        /// <summary>
        /// Parse only method. Parses and adds all entities found in the given node and adds them to the given
        /// list.
        /// </summary>
        /// <param name="node">Node to look in for the report extractions.</param>
        /// <param name="ReportExtractionElements">List of report extractions created (returned)</param>
        public static void ParseFromXml(XmlNode node, IList ReportExtractionElements)
        {
            if (node != null && ReportExtractionElements != null)
            {
                foreach (XmlNode entityNode in node.ChildNodes)
                {
                    if (entityNode.NodeType.Equals(XmlNodeType.Element))
                    {
                        ReportExtractionElement reportExtractionElement = new ReportExtractionElement();

                        reportExtractionElement.Name   = GetAttributeValue(entityNode, NAME, reportExtractionElement.Name);
                        reportExtractionElement.Hints  = GetAttributeValue(entityNode, HINTS, reportExtractionElement.Name);
                        reportExtractionElement.Having = GetAttributeValue(entityNode, HAVING, reportExtractionElement.Name);

                        EntityReferenceElement.ParseFromXml(GetChildNodeByName(entityNode, ENTITY_REFERENCES), reportExtractionElement.entityReferences);
                        PropertyElement.ParseFromXml(GetChildNodeByName(entityNode, COMPUTED_PROPERTIES), reportExtractionElement.ComputedProperties);
                        ComparerElement.ParseFromXml(GetChildNodeByName(entityNode, COMPARERS), reportExtractionElement.Comparers);
                        ReportExtractionFinderElement.ParseFromXml(GetChildNodeByName(entityNode, FINDERS), reportExtractionElement.Finders);
                        ReportExtractionElements.Add(reportExtractionElement);
                    }
                }
            }
        }