Exemple #1
0
        /// <summary>
        /// Returns an <see cref="IfpNode"/> instance from a supplied <see cref="XmlNode"/>.
        /// </summary>
        /// <param name="xmlNode">The base XML node.</param>
        /// <returns>A <see cref="IfpNode"/> instance.</returns>
        internal static IfpNode FromXmlNode(XmlNode xmlNode)
        {
            //Prepare
            IfpNode node = new IfpNode();

            //Setup
            node.itemType    = string_GetType(xmlNode.Attributes?["itemtype"]?.InnerText ?? string.Empty);
            node.inferOffset = !int.TryParse(xmlNode.Attributes?["offset"]?.InnerText, out node.fieldOffset);
            int.TryParse(xmlNode.Attributes?["reflexiveoffset"]?.InnerText, out node.tagBlockOffset);
            int.TryParse(xmlNode.Attributes?["reflexivesize"]?.InnerText, out node.tagBlockSize);
            int.TryParse(xmlNode.Attributes?["itemoffset"]?.InnerText, out node.itemOffset);
            int.TryParse(xmlNode.Attributes?["size"]?.InnerText, out node.length);
            int.TryParse(xmlNode.Attributes?["headersize"]?.InnerText, out node.headerSize);
            int.TryParse(xmlNode.Attributes?["value"]?.InnerText, out node.optionValue);
            int.TryParse(xmlNode.Attributes?["padalign"]?.InnerText, out node.alignment);
            int.TryParse(xmlNode.Attributes?["maxelements"]?.InnerText, out node.maxElements);
            bool.TryParse(xmlNode.Attributes?["visible"]?.InnerText, out node.visible);
            node.name   = xmlNode.Attributes?["name"]?.InnerText ?? string.Empty;
            node.@class = xmlNode.Attributes?["class"]?.InnerText ?? string.Empty;
            node.author = xmlNode.Attributes?["author"]?.InnerText ?? string.Empty;
            node.layer  = xmlNode.Attributes?["layer"]?.InnerText ?? string.Empty;
            node.label  = xmlNode.Attributes?["label"]?.InnerText ?? string.Empty;

            //Load Children
            if (xmlNode.ChildNodes != null)
            {
                foreach (XmlNode child in xmlNode.ChildNodes)
                {
                    node.Nodes.Add(FromXmlNode(child));
                }
            }

            //Determine Type
            node.Type = xmlNode_GetType(xmlNode);

            //Return
            return(node);
        }
Exemple #2
0
 /// <summary>
 /// Loads the IFP document from the specified <see cref="XmlDocument"/>.
 /// </summary>
 /// <param name="doc">The <see cref="XmlDocument"/> to load the <see cref="IfpDocument"/> from.</param>
 private void LoadFromXmlDocument(XmlDocument doc)
 {
     //Get Plugin
     try { main = IfpNode.FromXmlNode(doc["plugin"]); }
     catch (Exception ex) { throw new IfpException("An error occured while loading the plugin document.", ex); }
 }
Exemple #3
0
 /// <summary>
 /// Initializes a new <see cref="IfpDocument"/> instance.
 /// </summary>
 public IfpDocument()
 {
     //Setup
     main = new IfpNode();
 }