public static CodeFormatOption Read(CodeFormatDescription descr, XmlReader reader)
        {
            CodeFormatOption result = new CodeFormatOption();

            result.Name        = reader.GetAttribute("name");
            result.DisplayName = reader.GetAttribute("_displayName");
            string example = reader.GetAttribute("example");

            if (!string.IsNullOrEmpty(example))
            {
                result.Example = descr.GetExample(example);
            }
            if (!reader.IsEmptyElement)
            {
                reader.Read();
                result.Example = reader.ReadElementString();
                reader.Read();
            }
            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);
        }
        public static CodeFormatDescription Read(XmlReader reader)
        {
            CodeFormatDescription result = new CodeFormatDescription();

            while (reader.Read())
            {
                if (reader.IsStartElement())
                {
                    switch (reader.LocalName)
                    {
                    case Node:
                        string fileVersion = reader.GetAttribute(VersionAttribute);
                        if (fileVersion != Version)
                        {
                            return(result);
                        }
                        result.MimeType = reader.GetAttribute("mimeType");
                        break;

                    case "Example":
                        string name = reader.GetAttribute("name");
                        result.examples[name] = reader.ReadElementString();
                        break;

                    case CodeFormatType.Node:
                        result.types.Add(CodeFormatType.Read(reader));
                        break;

                    case CodeFormatCategory.Node:
                        result.subCategories.Add(CodeFormatCategory.Read(result, reader));
                        break;
                    }
                }
            }
            return(result);
        }
	 	public static CodeFormatDescription Read (XmlReader reader)
		{
			CodeFormatDescription result = new CodeFormatDescription ();
			while (reader.Read ()) {
				if (reader.IsStartElement ()) {
					switch (reader.LocalName) {
					case Node:
						string fileVersion = reader.GetAttribute (VersionAttribute);
						if (fileVersion != Version) 
							return result;
						result.MimeType = reader.GetAttribute ("mimeType");
						break;
					case "Example":
						string name = reader.GetAttribute ("name");
						result.examples[name] = reader.ReadElementString ();
						break;
					case CodeFormatType.Node:
						result.types.Add (CodeFormatType.Read (reader));
						break;
					case CodeFormatCategory.Node:
						result.subCategories.Add (CodeFormatCategory.Read (result, reader));
						break;
					}
				}
			}
			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;
		}
		public static CodeFormatOption Read (CodeFormatDescription descr, XmlReader reader)
		{
			CodeFormatOption result = new CodeFormatOption ();
			result.Name        = reader.GetAttribute ("name");
			result.DisplayName = reader.GetAttribute ("_displayName");
			string example    = reader.GetAttribute ("example");
			if (!string.IsNullOrEmpty (example))
				result.Example = descr.GetExample (example);
			if (!reader.IsEmptyElement) {
				reader.Read ();
				result.Example = reader.ReadElementString ();
				reader.Read ();
			}
			return result;
		}