예제 #1
0
		private void ResolveContentElement(XmlReader reader, Theme theme)
		{
		}
예제 #2
0
		private Theme ResolveThemeFile(string themeName)
		{
			if(string.IsNullOrWhiteSpace(themeName))
				return null;

			string fileName = Path.Combine(_path, themeName, "theme.xml");

			if(!File.Exists(fileName))
				return null;

			Theme theme = new Theme(themeName);

			using(var reader = XmlReader.Create(fileName, new XmlReaderSettings()
			{
				CloseInput = true,
				IgnoreComments = true,
				IgnoreProcessingInstructions = true,
				IgnoreWhitespace = true,
				ValidationType = ValidationType.None,
			}))
			{
				//移到根节点
				reader.MoveToContent();

				theme.Title = reader.GetAttribute("title");
				theme.Description = reader.GetAttribute("description");

				if(string.IsNullOrWhiteSpace(theme.Title))
					theme.Title = themeName;

				while(reader.Read())
				{
					if(reader.NodeType != XmlNodeType.Element)
						continue;

					switch(reader.Name)
					{
						case "component":
							this.ResolveComponentElement(reader, theme);
							break;
						case "content":
							this.ResolveContentElement(reader, theme);
							break;
						case "include":
							theme.Includes.Add(new IncludeElement(reader.GetAttribute("name")));
							break;
						default:
							throw new ThemeException("Invalid '" + reader.Name + "' of element in this '" + fileName + "' theme file.");
					}
				}
			}

			return theme;
		}
예제 #3
0
		private void ResolveComponentElement(XmlReader reader, Theme theme)
		{
			reader = reader.ReadSubtree();

			if(reader != null && reader.ReadState == ReadState.Initial)
				reader.Read();

			int depth = reader.Depth;
			ComponentElement component = new ComponentElement(reader.GetAttribute("name"));

			while(reader.Read())
			{
				if(reader.NodeType == XmlNodeType.Element)
				{
					switch(reader.Name)
					{
						case "file":
							component.Files.Add(new FileElement(reader.GetAttribute("name").Replace('\\', '/').TrimStart('/')));
							break;
						case "dependencies":
							this.ResolveDependencyElement(reader, component);
							break;
						default:
							throw new ThemeException("Invalid '" + reader.Name + "' of element in this '" + theme.Name + "' theme.");
					}
				}
			}

			theme.Components.Add(component);
		}