Пример #1
0
		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
		protected void InitWidget(string baseDir)
		{
			string IconName, IconSrc;
			XReader xr = new XReader(baseDir + "Widget.Config");
			IconName = xr["Widget"]["$Text"].Value;
			IconSrc = xr.Reset()["Widget"]["Img"]["$Src"].Value;

			EventListViewItem item = new EventListViewItem(IconName);
			item.OnItemLaunch += new EventListViewItem.MouseActionHandler(delegate(EventListViewItem oSender, MouseEventArgs oEvtArgs)
			{
				LaunchMailGenerator();
			});
			item.ImageIndex = 0;
			item.SubItems.Add("None");
			imgIcons.Images.Add(Image.FromFile(baseDir + IconSrc));
			lvMain.LargeImageList = imgIcons;
			lvMain.Columns.Add("Application Name", 150);
			lvMain.Columns.Add("Shortcut Key", 90);
			lvMain.Items.Add(item);

			EventTreeNode tn = new EventTreeNode();
			tn.MouseOnClick += new EventTreeNode.MouseActionHandler(delegate(EventTreeNode node, MouseEventArgs mEvt)
			{
				LaunchMailGenerator();
			});
			tn.Text = "Outlook Mail Generator";

			tvMain.Nodes.Add(tn);
			tvMain.NodeMouseClick += new TreeNodeMouseClickEventHandler(tvMain_NodeMouseClick);
		}
Пример #3
0
        protected XReader GetInstance()
        {
            XReader xr = new XReader();

            InitInstance(xr);
            return(xr);
        }
Пример #4
0
        protected XReader GetInstance(XmlNode xn)
        {
            XReader xr = new XReader(xn);

            InitInstance(xr);
            return(xr);
        }
Пример #5
0
        protected XReader GetInstance(XmlAttribute xa)
        {
            XReader xr = new XReader(xa);

            InitInstance(xr);
            return(xr);
        }
Пример #6
0
		public object RereadConfigFile()
		{
			string rlt = "", script = "";
			XReader xr = new XReader();
			XReader xrClient;
			xr.Load(AppDomain.CurrentDomain.BaseDirectory + "ClientLib.Config");
			xrClient = xr["configuration"]["client"];
			List<XReader> cl = xrClient.Children;
			string defType = xrClient["$DefaultScriptType"].Value;
			string clientBasePath = xrClient["$BaseUrl"].Value;
			if (!string.IsNullOrEmpty(clientBasePath) && clientBasePath[clientBasePath.Length - 1] != '/')
			{
				clientBasePath += '/';
			}
			foreach (XReader cx in cl)
			{
				if (string.IsNullOrEmpty(defType))
				{
					defType = "text/javascript";
				}
				if (cx.Name == "Script")
				{
					rlt += "<script src='" + clientBasePath + cx["$url"].Value + "' type='" + defType + "'></script>\n";
				}
			}
			script += "<script type='text/javascript'>";
			script += "var FC$ = {BaseUrl:'" + clientBasePath + "'};";
			script += "</script>";
			rlt = script + rlt;
			return rlt;
		}
Пример #7
0
 public XReader(XmlDocument xdoc)
 {
     root     = xdoc;
     fullPath = null;
     nodePtr  = new XReader();
     Load(root, NodeReaderType.Node, true);
 }
Пример #8
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);
		}
Пример #9
0
		public XReader(string xmlfile)
		{
			rootDoc = new XmlDocument();
			if (!File.Exists(xmlfile))
			{
				StreamWriter sw = File.CreateText(xmlfile);
				sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
				sw.WriteLine("<root></root>");
				sw.Close();
			}
			rootDoc.Load(xmlfile);
			fullPath = xmlfile;
			nodePtr = new XReader();
			Load(rootDoc, NodeReaderType.Node, true);
		}
Пример #10
0
 public XReader(string xmlfile)
 {
     root = new XmlDocument();
     if (!File.Exists(xmlfile))
     {
         StreamWriter sw = File.CreateText(xmlfile);
         sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
         sw.WriteLine("<root></root>");
         sw.Close();
     }
     root.Load(xmlfile);
     fullPath = xmlfile;
     nodePtr  = new XReader();
     Load(root, NodeReaderType.Node, true);
 }
Пример #11
0
		protected void ReadFromConfig()
		{
			using (XReader xr = new XReader(ConfigFile))
			{
				rootUrl = xr.Reset()["root"]["$BaseDir"].Value;
				if (xr != null)
				{
					WriteLine("");
					foreach (object oChild in xr.Reset()["root"])
					{
						XReader child = oChild as XReader;
						if ("Script".Equals(child.Name) || "ExternScript".Equals(child.Name) || "CoreScript".Equals(child.Name))
						{
							string content = "<script src='" + rootUrl + child["$Src"].Value + "' type='text/javascript'></script>";
							WriteLine(content);
						}
					}
				}
				else
				{
					WriteLine("\n\n<!-- Incorrect config file format -->\n\n");
				}
			}
		}
Пример #12
0
		private void ReadConfiguration()
		{
			XReader xr = new XReader(FullConfigFilename);
			BaseDir = AppDomain.CurrentDomain.BaseDirectory;
			PluginDirectory = AppDomain.CurrentDomain.BaseDirectory + xr["Config"]["Plugins"]["$Directory"].Value;
			if (PluginDirectory[PluginDirectory.Length - 1] != '\\')
			{
				PluginDirectory += '\\';
			}

			LoadPlugins();
		}
Пример #13
0
		public XReader(XmlDocument xdoc)
		{
			rootDoc = xdoc;
			fullPath = null;
			nodePtr = new XReader();
			Load(rootDoc, NodeReaderType.Node, true);
		}
Пример #14
0
		private void DirectoryOnEnum(string path)
		{
			XReader xr;
			string rlt = path;
			if (File.Exists(path))
			{
				string typName;
				Assembly asm;
				xr = new XReader(path);
				try
				{
					//instanceType = xr["Plugin"]["$Instance"].Value;
					asm = Assembly.LoadFrom(PluginDirectory + xr["Plugin"]["$File"].Value);
					typName = xr["Plugin"]["$Type"].Value;
					//						ModuleBase module = (ModuleBase)asm.CreateInstance(typName);
					FunctionModule module = (FunctionModule)CreateModuleInstanceByTypeName(typName, asm);
					if (module == null)
					{
						return;
					}
					module.BaseDir = path;
					//module.ConfigFileFullPath = path + "\\Plugin.Config";
					PluginItem pl = new PluginItem();
					pl.Asm = asm;
					pl.Module = module;
					bool isRegisted = RegistPlugin(pl);
					if (OnPluginsLoad != null)
					{
						//OnPluginsLoad(this, pl);
						ClassHelper.AsyncInvokeDelegates(OnPluginsLoad, DelegateInvoke_PreInvokeCallback, DelegateInvoke_PostInvokeCallback, new object[] { this, pl });
					}
				}
				catch (Exception e)
				{
					//MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
					Exceptions.Log(e);
				}
			}
		}
Пример #15
0
		public override object AddValue(string key, object value)
		{
			object o = base.AddValue(key, value);
			XReader rlt = new XReader(o, rootDoc);
			return rlt;
		}
Пример #16
0
		protected void InitInstance(XReader xr)
		{
			xr.Mode = Mode;
			xr.curtDoc = curtDoc;
		}
Пример #17
0
		protected override void Init()
		{
			XReader xr = new XReader(ConfigFilePath);
			BackupDir = xr["Plugin"]["$BackupPath"].Value;
			if (!Directory.Exists(BackupDir) || BackupDir.IndexOf(':') < 0)
			{
				BackupDir = BaseDir + '\\' + BackupDir;
			}
			IconMenuItem = Notifier.AdjustMenuItem(System.Windows.Forms.MenuMerge.Add, "Sticky Note", delegate(object sender, EventArgs e)
			{
				if (Windows.Count <= 0)
				{
					StickyForm sf = RegistNewWindow();
					sf.ShowWindow();
				}
				else
				{
					EnumWindows(delegate(StickyForm wi)
					{
						//wi.Invoke(wi.ShowWindow);
						wi.ShowWindow();
						return true;
					});
				}
			});
		}
Пример #18
0
		protected XReader GetInstance(XmlAttribute xa)
		{
			XReader xr = new XReader(xa);
			InitInstance(xr);
			return xr;
		}
Пример #19
0
		protected XReader GetInstance()
		{
			XReader xr = new XReader();
			InitInstance(xr);
			return xr;
		}
Пример #20
0
 protected void InitInstance(XReader xr)
 {
     xr.Mode    = Mode;
     xr.curtDoc = curtDoc;
 }
Пример #21
0
		protected XReader GetInstance(XmlNode xn)
		{
			XReader xr = new XReader(xn);
			InitInstance(xr);
			return xr;
		}
Пример #22
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();
			}
		}
Пример #23
0
		protected override void Render(System.Web.UI.HtmlTextWriter writer)
		{
			ConfigFile = FsConfig.BaseDir + "ClientScript.Config";
			if (string.IsNullOrEmpty(Content))
			{
				using (XReader xr = new XReader(ConfigFile))
				{
					rootUrl = xr.Reset()["root"]["$BaseDir"].Value;
					if (!string.IsNullOrEmpty(rootUrl))
					{
						rootUrl = rootUrl.ToLower();
						rootDir = DiskHelper.MapPath(rootUrl);
						PathInfo pi = new PathInfo(rootDir);
						rootDirName = pi.CurrentDirName;
					}
					else
					{
						rootDir = DiskHelper.MapPath("/FsWeb/ClientLib");
						rootUrl = "/FsWeb/ClientLib/";
						DirectoryInfo di = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "FsWeb\\ClientLib\\");
						rootDirName = di.Name.ToLower();
					}
					GenerateConfigFile();
				}
			}
			Content = "";
			ReadFromConfig();
			writer.WriteLine(Content);
		}
Пример #24
0
Файл: Fs.cs Проект: mind0n/hive
		public static XReader GetConfigFileReader(string name)
		{
			string fullConfigFilename = BaseDir + name + ".Config";
			XReader xr = new XReader(fullConfigFilename);
			return xr;
		}