IsField() public method

public IsField ( int tag ) : System.Boolean
tag int
return System.Boolean
コード例 #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);
                }
            }
        }
コード例 #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);
                }
            }
        }
コード例 #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);
                }
            }
        }
コード例 #4
0
 public bool IsTrailerField(int tag)
 {
     return(Trailer.IsField(tag));
 }
コード例 #5
0
 public bool IsHeaderField(int tag)
 {
     return(Header.IsField(tag));
 }
コード例 #6
0
        /// <summary>
        /// Parse a message element.  Its data is added to parameter `ddmap`.
        /// </summary>
        /// <param name="node">a message, group, or component node</param>
        /// <param name="ddmap">the still-being-constructed DDMap for this node</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);
                 */

                VerifyChildNode(childNode, node);

                var nameAttribute = childNode.Attributes["name"].Value;

                switch (childNode.Name)
                {
                case "field":
                case "group":
                    if (FieldsByName.ContainsKey(nameAttribute) == false)
                    {
                        throw new DictionaryParseException(
                                  $"Field '{nameAttribute}' is not defined in <fields> section.");
                    }
                    DDField fld = FieldsByName[nameAttribute];

                    bool required = (childNode.Attributes["required"]?.Value == "Y") && componentRequired.GetValueOrDefault(true);

                    if (required)
                    {
                        ddmap.ReqFields.Add(fld.Tag);
                    }

                    if (ddmap.IsField(fld.Tag) == false)
                    {
                        ddmap.Fields.Add(fld.Tag, fld);
                    }

                    // if this is in a group whose delim is unset, then this must be the delim (i.e. first field)
                    if (ddmap is DDGrp ddGroup && ddGroup.Delim == 0)
                    {
                        ddGroup.Delim = fld.Tag;
                    }

                    if (childNode.Name == "group")
                    {
                        DDGrp grp = new DDGrp();
                        grp.NumFld = fld.Tag;
                        if (required)
                        {
                            grp.Required = true;
                        }

                        ParseMsgEl(childNode, grp);
                        ddmap.Groups.Add(fld.Tag, grp);
                    }
                    break;

                case "component":
                    XmlNode compNode = RootDoc.SelectSingleNode("//components/component[@name='" + nameAttribute + "']");
                    ParseMsgEl(compNode, ddmap, (childNode.Attributes["required"]?.Value == "Y"));
                    break;

                default:
                    throw new DictionaryParseException($"Malformed data dictionary: child node type should be one of {{field,group,component}} but is '{childNode.Name}' within parent '{node.Name}/{messageTypeName}'");
                }
            }
        }
コード例 #7
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);
                }
            }
        }
コード例 #8
0
ファイル: DataDictionary.cs プロジェクト: BobRoss79/quickfixn
        /// <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);
                }
            }
        }