Ejemplo n.º 1
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.");
                }
            }
        }
Ejemplo n.º 2
0
        public void Parse(CompileContext context, System.Xml.XmlNode node)
        {
            XmlAttribute att = node.Attributes["Namespace"];

            nsp = att.InnerText;
            att = node.Attributes["ContextName"];
            if (att != null)
            {
                applicationContext = att.InnerText;
            }

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

                Type type = context.ResolveType(child.Prefix, child.LocalName);

                if (type != null && type.GetInterface("SharpMedia.Graphics.GUI.Widgets.IWidget") != null)
                {
                    ASTWidget widget = new ASTWidget();
                    widget.Parse(context, child);
                    children.Add(widget);
                }
                else if (type != null && type.GetInterface("SharpMedia.Graphics.GUI.IStateStyle") != null)
                {
                    Styles.ASTStyle style = new Styles.ASTStyle();
                    style.Parse(context, child);
                    children.Add(style);
                }
                else if (type != null && type.GetInterface("SharpMedia.Graphics.GUI.Animations.IAnimation") != null)
                {
                    Animations.ASTAnimation animation = new Animations.ASTAnimation(type);
                    animation.Parse(context, child);
                    children.Add(animation);
                }
                else
                {
                    throw new ParseException("Invalid type of not one of style/widget/animation.");
                }
            }

            context.ApplicationContextType = applicationContext;
        }