Exemplo n.º 1
0
        private void parseMsgEl(XmlNode node, DDMap ddmap)
        {
            if (!node.HasChildNodes)
            {
                return;
            }
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.Name == "field")
                {
                    DDField fld = FieldsByName[childNode.Attributes["name"].Value];
                    if (childNode.Attributes["required"].Value == "Y")
                    {
                        fld.Required = true;
                        ddmap.ReqFields.Add(fld.Tag);
                    }
                    if (!ddmap.IsField(fld.Tag))
                    {
                        ddmap.Fields.Add(fld.Tag, fld);
                    }

                    // if first field in group, make it the DELIM <3 FIX
                    if ((ddmap.GetType() == typeof(DDGrp) && ((DDGrp)ddmap).Delim == 0))
                    {
                        ((DDGrp)ddmap).Delim = fld.Tag;
                    }
                }
                else if (childNode.Name == "group")
                {
                    DDField fld = FieldsByName[childNode.Attributes["name"].Value];
                    DDGrp   grp = new DDGrp();
                    if (childNode.Attributes["required"].Value == "Y")
                    {
                        fld.Required = true;
                        ddmap.ReqFields.Add(fld.Tag);
                        grp.Required = true;
                    }
                    if (!ddmap.IsField(fld.Tag))
                    {
                        ddmap.Fields.Add(fld.Tag, fld);
                    }
                    grp.NumFld = fld.Tag;
                    parseMsgEl(childNode, grp);
                    ddmap.Groups.Add(fld.Tag, grp);
                }
                else if (childNode.Name == "component")
                {
                    String  name     = childNode.Attributes["name"].Value;
                    XmlNode compNode = RootDoc.SelectSingleNode("//components/component[@name='" + name + "']");
                    parseMsgEl(compNode, ddmap);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Parse a message element
        /// </summary>
        /// <param name="node"></param>
        /// <param name="ddmap"></param>
        /// <param name="componentRequired">
        /// If non-null, parsing is inside a component that is required (true) or not (false).
        /// If null, parser is not inside a component.
        /// </param>
        private void parseMsgEl(XmlNode node, DDMap ddmap, bool? componentRequired)
        {
            /*
            // This code is great for debugging DD parsing issues.
            string s = "+ " + node.Name;
            if (node.Attributes["name"] != null)
                s += " | " + node.Attributes["name"].Value;
            Console.WriteLine(s);
            */

            if (!node.HasChildNodes) { return; }
            foreach (XmlNode childNode in node.ChildNodes)
            {
                /*
                // Continuation of code that's great for debugging DD parsing issues.
                s = "    + " + childNode.Name;
                if (node.Attributes["name"] != null)
                    s += " | " + childNode.Attributes["name"].Value;
                Console.WriteLine(s);
                */

                if( childNode.Name == "field" )
                {
                    DDField fld = FieldsByName[childNode.Attributes["name"].Value];
                    XmlAttribute req = childNode.Attributes["required"];
                    if (req != null && req.Value == "Y"
                        && (componentRequired == null || componentRequired.Value == true))
                    {
                        ddmap.ReqFields.Add(fld.Tag);
                    }
                    if (!ddmap.IsField(fld.Tag))
                    {
                        ddmap.Fields.Add(fld.Tag, fld);
                    }

                    // if first field in group, make it the DELIM
                    if ((ddmap.GetType() == typeof(DDGrp) && ((DDGrp)ddmap).Delim == 0))
                    {
                        ((DDGrp)ddmap).Delim = fld.Tag;
                    }
                }
                else if(childNode.Name == "group")
                {
                    DDField fld = FieldsByName[childNode.Attributes["name"].Value];
                    DDGrp grp = new DDGrp();
                    XmlAttribute req = childNode.Attributes["required"];
                    if (req != null && req.Value == "Y"
                        && (componentRequired == null || componentRequired.Value == true))
                    {
                        ddmap.ReqFields.Add(fld.Tag);
                        grp.Required = true;
                    }
                    if (!ddmap.IsField(fld.Tag))
                    {
                        ddmap.Fields.Add(fld.Tag, fld);
                    }
                    grp.NumFld = fld.Tag;
                    parseMsgEl(childNode, grp);
                    ddmap.Groups.Add(fld.Tag, grp);
                }
                else if (childNode.Name == "component")
                {
                    String name = childNode.Attributes["name"].Value;
                    XmlNode compNode = RootDoc.SelectSingleNode("//components/component[@name='" + name + "']");
                    XmlAttribute req = childNode.Attributes["required"];
                    bool? compRequired = (req != null && req.Value == "Y");
                    parseMsgEl(compNode, ddmap, compRequired);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Parse a message element
        /// </summary>
        /// <param name="node"></param>
        /// <param name="ddmap"></param>
        /// <param name="componentRequired">
        /// If non-null, parsing is inside a component that is required (true) or not (false).
        /// If null, parser is not inside a component.
        /// </param>
        private void ParseMsgEl(XmlNode node, DDMap ddmap, bool?componentRequired)
        {
            /*
             * // This code is great for debugging DD parsing issues.
             * string s = "+ " + node.Name;  // node.Name is probably "message"
             * if (node.Attributes["name"] != null)
             *  s += " | " + node.Attributes["name"].Value;
             * Console.WriteLine(s);
             */

            string messageTypeName = (node.Attributes["name"] != null) ? node.Attributes["name"].Value : node.Name;

            if (!node.HasChildNodes)
            {
                return;
            }
            foreach (XmlNode childNode in node.ChildNodes)
            {
                /*
                 * // Continuation of code that's great for debugging DD parsing issues.
                 * s = "    + " + childNode.Name;  // childNode.Name is probably "field"
                 * if (childNode.Attributes["name"] != null)
                 *  s += " | " + childNode.Attributes["name"].Value;
                 * Console.WriteLine(s);
                 */

                var fieldName = (childNode.Attributes["name"] != null) ? childNode.Attributes["name"].Value : "no-name";

                if (childNode.Name == "field")
                {
                    if (FieldsByName.ContainsKey(fieldName) == false)
                    {
                        throw new Exception(
                                  $"Field '{fieldName}' is used in '{messageTypeName}', but is not defined in <fields> set.");
                    }

                    DDField      fld = FieldsByName[fieldName];
                    XmlAttribute req = childNode.Attributes["required"];
                    if (req != null && req.Value == "Y" &&
                        (componentRequired == null || componentRequired.Value == true))
                    {
                        ddmap.ReqFields.Add(fld.Tag);
                    }
                    if (!ddmap.IsField(fld.Tag))
                    {
                        ddmap.Fields.Add(fld.Tag, fld);
                    }

                    // if first field in group, make it the DELIM
                    if ((ddmap.GetType() == typeof(DDGrp) && ((DDGrp)ddmap).Delim == 0))
                    {
                        ((DDGrp)ddmap).Delim = fld.Tag;
                    }
                }
                else if (childNode.Name == "group")
                {
                    DDField      fld = FieldsByName[fieldName];
                    DDGrp        grp = new DDGrp();
                    XmlAttribute req = childNode.Attributes["required"];
                    if (req != null && req.Value == "Y" &&
                        (componentRequired == null || componentRequired.Value == true))
                    {
                        ddmap.ReqFields.Add(fld.Tag);
                        grp.Required = true;
                    }
                    if (!ddmap.IsField(fld.Tag))
                    {
                        ddmap.Fields.Add(fld.Tag, fld);
                    }
                    grp.NumFld = fld.Tag;
                    ParseMsgEl(childNode, grp);
                    ddmap.Groups.Add(fld.Tag, grp);

                    // if first field in group, make it the DELIM
                    if ((ddmap.GetType() == typeof(DDGrp) && ((DDGrp)ddmap).Delim == 0))
                    {
                        ((DDGrp)ddmap).Delim = fld.Tag;
                    }
                }
                else if (childNode.Name == "component")
                {
                    XmlNode      compNode     = RootDoc.SelectSingleNode("//components/component[@name='" + fieldName + "']");
                    XmlAttribute req          = childNode.Attributes["required"];
                    bool?        compRequired = (req != null && req.Value == "Y");
                    ParseMsgEl(compNode, ddmap, compRequired);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Parse a message element
        /// </summary>
        /// <param name="node"></param>
        /// <param name="ddmap"></param>
        /// <param name="componentRequired">
        /// If non-null, parsing is inside a component that is required (true) or not (false).
        /// If null, parser is not inside a component.
        /// </param>
        private void parseMsgEl(XmlNode node, DDMap ddmap, bool?componentRequired)
        {
            /*
             * // This code is great for debugging DD parsing issues.
             * string s = "+ " + node.Name;
             * if (node.Attributes["name"] != null)
             *  s += " | " + node.Attributes["name"].Value;
             * Console.WriteLine(s);
             */

            if (!node.HasChildNodes)
            {
                return;
            }
            foreach (XmlNode childNode in node.ChildNodes)
            {
                /*
                 * // Continuation of code that's great for debugging DD parsing issues.
                 * s = "    + " + childNode.Name;
                 * if (node.Attributes["name"] != null)
                 *  s += " | " + childNode.Attributes["name"].Value;
                 * Console.WriteLine(s);
                 */

                if (childNode.Name == "field")
                {
                    DDField      fld = FieldsByName[childNode.Attributes["name"].Value];
                    XmlAttribute req = childNode.Attributes["required"];
                    if (req != null && req.Value == "Y" &&
                        (componentRequired == null || componentRequired.Value == true))
                    {
                        ddmap.ReqFields.Add(fld.Tag);
                    }
                    if (!ddmap.IsField(fld.Tag))
                    {
                        ddmap.Fields.Add(fld.Tag, fld);
                    }

                    // if first field in group, make it the DELIM
                    if ((ddmap.GetType() == typeof(DDGrp) && ((DDGrp)ddmap).Delim == 0))
                    {
                        ((DDGrp)ddmap).Delim = fld.Tag;
                    }
                }
                else if (childNode.Name == "group")
                {
                    DDField      fld = FieldsByName[childNode.Attributes["name"].Value];
                    DDGrp        grp = new DDGrp();
                    XmlAttribute req = childNode.Attributes["required"];
                    if (req != null && req.Value == "Y" &&
                        (componentRequired == null || componentRequired.Value == true))
                    {
                        ddmap.ReqFields.Add(fld.Tag);
                        grp.Required = true;
                    }
                    if (!ddmap.IsField(fld.Tag))
                    {
                        ddmap.Fields.Add(fld.Tag, fld);
                    }
                    grp.NumFld = fld.Tag;
                    parseMsgEl(childNode, grp);
                    ddmap.Groups.Add(fld.Tag, grp);
                }
                else if (childNode.Name == "component")
                {
                    String       name         = childNode.Attributes["name"].Value;
                    XmlNode      compNode     = RootDoc.SelectSingleNode("//components/component[@name='" + name + "']");
                    XmlAttribute req          = childNode.Attributes["required"];
                    bool?        compRequired = (req != null && req.Value == "Y");
                    parseMsgEl(compNode, ddmap, compRequired);
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Parse a message element
        /// </summary>
        /// <param name="node"></param>
        /// <param name="ddmap"></param>
        /// <param name="componentRequired">
        /// If non-null, parsing is inside a component that is required (true) or not (false).
        /// If null, parser is not inside a component.
        /// </param>
        private void parseMsgEl(XmlNode node, DDMap ddmap, bool? componentRequired)
        {
            if (!node.HasChildNodes) { return; }
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if( childNode.Name == "field" )
                {
                    DDField fld = FieldsByName[childNode.Attributes["name"].Value];
                    if (childNode.Attributes["required"].Value == "Y"
                        && (componentRequired==null || componentRequired.Value==true))
                    {
                        ddmap.ReqFields.Add(fld.Tag);
                    }
                    if (!ddmap.IsField(fld.Tag))
                    {
                        ddmap.Fields.Add(fld.Tag, fld);
                    }

                    // if first field in group, make it the DELIM <3 FIX
                    if ((ddmap.GetType() == typeof(DDGrp) && ((DDGrp)ddmap).Delim == 0))
                    {
                        ((DDGrp)ddmap).Delim = fld.Tag;
                    }
                }
                else if(childNode.Name == "group")
                {
                    DDField fld = FieldsByName[childNode.Attributes["name"].Value];
                    DDGrp grp = new DDGrp();
                    if (childNode.Attributes["required"].Value == "Y"
                        && (componentRequired == null || componentRequired.Value == true))
                    {
                        ddmap.ReqFields.Add(fld.Tag);
                        grp.Required = true;
                    }
                    if (!ddmap.IsField(fld.Tag))
                    {
                        ddmap.Fields.Add(fld.Tag, fld);
                    }
                    grp.NumFld = fld.Tag;
                    parseMsgEl(childNode, grp);
                    ddmap.Groups.Add(fld.Tag, grp);
                }
                else if (childNode.Name == "component")
                {
                    String name = childNode.Attributes["name"].Value;
                    XmlNode compNode = RootDoc.SelectSingleNode("//components/component[@name='" + name + "']");
                    bool? compRequired = (childNode.Attributes["required"].Value == "Y");
                    parseMsgEl(compNode, ddmap, compRequired);
                }
            }
        }