예제 #1
0
파일: TestXReader.cs 프로젝트: mind0n/hive
		public static void Test()
		{
			XReader xr = new XReader(AppDomain.CurrentDomain.BaseDirectory + @"..\..\Temp.xml");
			Console.WriteLine(xr["root"]["add"]["$name"].Value);
			XReader du = xr.Duplicate<XReader>();
			xr.Reset()["root"]["add"].SetValue("$name", "Modified");
			xr.Reset()["root"].SetValue("new", "Created");
			xr.Reset()["root"]["new"].SetValue("$name", "Newly created");
			xr.Reset()["root"].SetValue("", "Modified Root Content");
			xr.Reset()["root"]["Temp"].SetValue("$test", "ok");
			xr.Reset()["root"]["temp"].SetValue(null, "ok");
			xr.Reset()["root"]["temp"].SetValue(null, "success");
			xr.Save();
			Console.WriteLine(xr.Reset()["root"].Value);
			for (int i = 1; i <= 1; i++)
			{
				Console.WriteLine("============================");
				foreach (XReader child in xr.Reset()["root"])
				{
					Console.WriteLine(child.Name);
				}
				Console.WriteLine("----------------------------");
				xr.Reset()["root"].EnumChilds(delegate(object ii)
				{
					XReader item = (XReader)ii;
					Console.WriteLine(item.Name);
					return true;
				});
				Console.WriteLine("****************************");
			}
			Console.WriteLine(du.NodeContent<object>());
			Console.ReadKey();
		}
예제 #2
0
		public static void TestXmlHellper()
		{
			XmlDocument xd = new XmlDocument();
			XReader xr = new XReader(xd);
			xr["abc"]["test"]["$attr"].Value = "ok";
			xr["abc"]["test"].Value = "success";
			xr["abc"]["test"]["success"].Value = "done!";
			xr.Save("d:\\temp.xml");
			xr = new XReader("d:\\temp.xml");
			Logger.Log(xr["abc"]["test"]["$attr"].Value);
			Logger.Log(xr["abc"]["test"]["success"].Value);
			Logger.Log(xr["abc"]["test"].Value);
		}
예제 #3
0
		public void GenerateConfigFile()
		{
			using (XReader xr = new XReader(ConfigFile))
			{
				//rootDir = xr.Reset()["root"]["$BaseDir"].Value;
				xr.Reset()["root"].RemoveChild("Script");
				xd = xr.Reset().NodeContent<XmlDocument>();
				scriptFiles.Clear();
				DiskHelper.EnumFile(rootDir, new DiskHelper.BoolDlgString(ScriptFileEnumHandler));
				scriptFiles.Sort(Comparer);
				foreach (ScriptItem file in scriptFiles)
				{
					XReader item = xr.Reset()["root"].AddValue("Script", null) as XReader;
					string url = DiskHelper.MapUrl(file.FullPath, rootDir);
					item.SetValue("$Src", file.FullPath);
				}
				xr.Save();
			}
		}