Пример #1
0
        public void Parse(CompileContext context, System.Xml.XmlNode node)
        {
            // We go for each attribute.
            foreach (XmlAttribute att in node.Attributes)
            {
                if (att.NodeType != XmlNodeType.Attribute)
                {
                    continue;
                }

                // We try to parse it.
                properties.Add(att.LocalName, ParsingHelper.ParseValue(context, type, att.Name, att.InnerText));
            }

            // And for each child.
            foreach (XmlNode child in node.ChildNodes)
            {
                if (child.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                properties.Add(child.LocalName, ParsingHelper.ParseValue(context, type, child));
            }
        }
Пример #2
0
        void ProcessChild(CompileContext context, XmlNode node)
        {
            if (node.NodeType != XmlNodeType.Element)
            {
                return;
            }


            if (node.Prefix == StandardPrefixes.Variable)
            {
                throw new NotSupportedException("Variables not yet supported.");
            }
            else if (node.Prefix == StandardPrefixes.Value || node.Prefix == StandardPrefixes.Property)
            {
                if (node.Name == "Style")
                {
                    styleLink = node["Style"].InnerText;
                }
                else
                {
                    values.Add(node.LocalName, ParsingHelper.ParseValue(context, changeType, node));
                }
            }
            else
            {
                if (type.GetInterface("SharpMedia.Graphics.GUI.Widgets.Containers.IContainer") == null)
                {
                    throw new ParseException(string.Format("Only containers can have child widgets, " +
                                                           "{0} is not a container.", name));
                }

                Type resolveType = context.ResolveType(node.Prefix, node.LocalName);

                if (resolveType != null && resolveType.GetInterface("SharpMedia.Graphics.GUI.Widgets.IWidget") != null)
                {
                    // We have a child element.
                    ASTWidget widget = new ASTWidget();
                    children.Add(node.LocalName, widget);

                    widget.Parse(context, node);
                }
                else
                {
                    throw new ParseException("Only widgets are acceptable as children.");
                }
            }
        }
Пример #3
0
 void ProcessAttribute(CompileContext context, XmlAttribute node)
 {
     values.Add(node.LocalName, ParsingHelper.ParseValue(context, changeType, node.LocalName, node.InnerText));
 }