public static CodeFormatType Read(XmlReader reader)
        {
            CodeFormatType result = new CodeFormatType();

            result.Name = reader.GetAttribute("name");
            XmlReadHelper.ReadList(reader, Node, delegate() {
                switch (reader.LocalName)
                {
                case "Value":
                    string displayName = reader.GetAttribute("_displayName");
                    string name        = reader.ReadElementString();
                    result.values.Add(new KeyValuePair <string, string> (name, displayName ?? name));
                    return(true);
                }
                return(false);
            });
            return(result);
        }
        public static CodeFormatCategory Read(CodeFormatDescription descr, XmlReader reader)
        {
            CodeFormatCategory result = new CodeFormatCategory();

            result.IsOptionCategory = reader.LocalName == OptionCategoryNode;
            result.DisplayName      = reader.GetAttribute("_displayName");
            XmlReadHelper.ReadList(reader, result.IsOptionCategory ? OptionCategoryNode : Node, delegate() {
                switch (reader.LocalName)
                {
                case "Option":
                    result.options.Add(CodeFormatOption.Read(descr, reader));
                    return(true);

                case CodeFormatCategory.OptionCategoryNode:
                case CodeFormatCategory.Node:
                    result.subCategories.Add(CodeFormatCategory.Read(descr, reader));
                    return(true);
                }
                return(false);
            });
            return(result);
        }
Ejemplo n.º 3
0
        ICustomXmlSerializer ReadFrom(XmlReader reader)
        {
            NodeState result = new NodeState();

            result.NodeName = reader.GetAttribute(nameAttribute);
            if (!String.IsNullOrEmpty(reader.GetAttribute(expandedAttribute)))
            {
                result.Expanded = Boolean.Parse(reader.GetAttribute(expandedAttribute));
            }
            if (!String.IsNullOrEmpty(reader.GetAttribute(selectedAttribute)))
            {
                result.Selected = Boolean.Parse(reader.GetAttribute(selectedAttribute));
            }

            XmlReadHelper.ReadList(reader, reader.LocalName, delegate() {
                switch (reader.LocalName)
                {
                case "Option":
                    if (result.Options == null)
                    {
                        result.Options = new Dictionary <string, bool> ();
                    }
                    result.Options [reader.GetAttribute("id")]   = bool.Parse(reader.GetAttribute("value"));
                    return(true);

                case "Node":
                    if (result.ChildrenState == null)
                    {
                        result.ChildrenState = new List <NodeState> ();
                    }
                    result.ChildrenState.Add((NodeState)ReadFrom(reader));
                    return(true);
                }
                return(false);
            });
            return(result);
        }
Ejemplo n.º 4
0
        ICustomXmlSerializer ReadFrom(XmlReader reader, ExtensibleTreeView.TreeOptions parentOptions)
        {
            NodeState result = new NodeState();

            result.NodeName = reader.GetAttribute(nameAttribute);
            if (!String.IsNullOrEmpty(reader.GetAttribute(expandedAttribute)))
            {
                result.Expanded = Boolean.Parse(reader.GetAttribute(expandedAttribute));
            }
            if (!String.IsNullOrEmpty(reader.GetAttribute(selectedAttribute)))
            {
                result.Selected = Boolean.Parse(reader.GetAttribute(selectedAttribute));
            }

            XmlReadHelper.ReadList(reader, reader.LocalName, delegate() {
                switch (reader.LocalName)
                {
                case "Option":
                    if (result.Options == null)
                    {
                        result.Options = parentOptions != null ? parentOptions.CloneOptions(Gtk.TreeIter.Zero) : new ExtensibleTreeView.TreeOptions();
                    }
                    result.Options [reader.GetAttribute("id")]   = bool.Parse(reader.GetAttribute("value"));
                    return(true);

                case "Node":
                    if (result.ChildrenState == null)
                    {
                        result.ChildrenState = new List <NodeState> ();
                    }
                    result.ChildrenState.Add((NodeState)ReadFrom(reader, result.Options != null ? result.Options : parentOptions));
                    return(true);
                }
                return(false);
            });
            return(result);
        }
Ejemplo n.º 5
0
        public static CodeTemplate Read(XmlReader reader)
        {
            Debug.Assert(reader.LocalName == Node);

            var result = new CodeTemplate();

            XmlReadHelper.ReadList(reader, Node, delegate() {
                //Console.WriteLine (reader.LocalName);
                switch (reader.LocalName)
                {
                case HeaderNode:
                    XmlReadHelper.ReadList(reader, HeaderNode, delegate() {
                        switch (reader.LocalName)
                        {
                        case GroupNode:
                            result.Group = reader.ReadElementContentAsString();
                            return(true);

                        case VersionNode:
                            result.Version = reader.ReadElementContentAsString();
                            return(true);

                        case MimeNode:
                            result.MimeType = reader.ReadElementContentAsString();
                            return(true);

                        case ContextNode:
                            result.CodeTemplateContext = (CodeTemplateContext)Enum.Parse(typeof(CodeTemplateContext), reader.ReadElementContentAsString());
                            return(true);

                        case ShortcutNode:
                            result.Shortcut = reader.ReadElementContentAsString();
                            return(true);

                        case DescriptionNode:
                            result.Description = reader.ReadElementContentAsString();
                            return(true);

                        case TemplateTypeNode:
                            result.CodeTemplateType = (CodeTemplateType)Enum.Parse(typeof(CodeTemplateType), reader.ReadElementContentAsString());
                            return(true);
                        }
                        return(false);
                    });
                    return(true);

                case VariablesNode:
                    XmlReadHelper.ReadList(reader, VariablesNode, delegate() {
                        //Console.WriteLine ("var:" + reader.LocalName);
                        switch (reader.LocalName)
                        {
                        case CodeTemplateVariable.Node:
                            var var = CodeTemplateVariable.Read(reader);
                            result.variableDecarations [var.Name] = var;
                            return(true);
                        }
                        return(false);
                    });
                    return(true);

                case CodeNode:
                    result.Code = reader.ReadElementContentAsString();
                    return(true);
                }
                return(false);
            });
            //Console.WriteLine ("result:" + result);
            return(result);
        }
Ejemplo n.º 6
0
        public static DocConfig Read(XmlReader reader)
        {
            DocConfig result = new DocConfig();

            XmlReadHelper.ReadList(reader, "DocFood", delegate() {
                switch (reader.LocalName)
                {
                case "WordLists":
                    XmlReadHelper.ReadList(reader, reader.LocalName, delegate() {
                        switch (reader.LocalName)
                        {
                        case "List":
                            string name         = reader.GetAttribute("name");
                            List <string> words = new List <string> ();
                            XmlReadHelper.ReadList(reader, reader.LocalName, delegate() {
                                switch (reader.LocalName)
                                {
                                case "Word":
                                    words.Add(reader.ReadElementString());
                                    return(true);
                                }
                                return(false);
                            });
                            result.WordLists[name] = words;
                            return(true);
                        }
                        return(false);
                    });
                    return(true);

                case "WordExpansion":
                    XmlReadHelper.ReadList(reader, reader.LocalName, delegate() {
                        switch (reader.LocalName)
                        {
                        case "Word":
                            result.WordExpansions[reader.GetAttribute("from")] = reader.GetAttribute("to");
                            return(true);
                        }
                        return(false);
                    });
                    return(true);

                case "Macros":
                    XmlReadHelper.ReadList(reader, reader.LocalName, delegate() {
                        switch (reader.LocalName)
                        {
                        case "Macro":
                            result.Macros[reader.GetAttribute("tag")] = reader.GetAttribute("value");
                            return(true);
                        }
                        return(false);
                    });
                    return(true);

                case "Rules":
                    result.Rules = Node.ReadNodeList(reader, "Rules");
                    return(true);
                }
                return(false);
            });
            return(result);
        }