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(); }
public object RereadConfigFile() { string rlt = "", script = ""; XReader xr = new XReader(); XReader xrClient; xr.Load(AppDomain.CurrentDomain.BaseDirectory + "ClientLib.Config"); xrClient = xr.Reset()["configuration"]["client"]; string defType = xrClient.Reset()["$DefaultScriptType"].Value; string clientBasePath = xrClient.Reset()["$BaseUrl"].Value; if (!string.IsNullOrEmpty(clientBasePath) && clientBasePath[clientBasePath.Length - 1] != '/') { clientBasePath += '/'; } foreach (XReader cx in xrClient) { if (string.IsNullOrEmpty(defType)) { defType = "text/javascript"; } if (cx.Name == "Script") { rlt += "<script src='" + clientBasePath + cx.Reset()["$url"].Value + "' type='" + defType + "'></script>\n"; } } script += "<script type='text/javascript'>"; script += "var FC$ = {BaseUrl:'" + clientBasePath + "'};"; script += "</script>"; rlt = script + rlt; return rlt; }
public object RereadConfigFile() { string rlt = "", script = ""; XReader xr = new XReader(); XReader xrClient; xr.Load(AppDomain.CurrentDomain.BaseDirectory + "ClientLib.Config"); xrClient = xr.Reset()["configuration"]["client"]; string defType = xrClient.Reset()["$DefaultScriptType"].Value; string clientBasePath = xrClient.Reset()["$BaseUrl"].Value; if (!string.IsNullOrEmpty(clientBasePath) && clientBasePath[clientBasePath.Length - 1] != '/') { clientBasePath += '/'; } foreach (XReader cx in xrClient) { if (string.IsNullOrEmpty(defType)) { defType = "text/javascript"; } if (cx.Name == "Script") { rlt += "<script src='" + clientBasePath + cx.Reset()["$url"].Value + "' type='" + defType + "'></script>\n"; } } script += "<script type='text/javascript'>"; script += "var FC$ = {BaseUrl:'" + clientBasePath + "'};"; script += "</script>"; rlt = script + rlt; return(rlt); }
protected static void ReadConfigFile() { //FileStream fs; string path = string.Empty, file = "DB.Config"; Page p = new Page(); list = new Dictionary <string, Db>(); XmlDocument x = new XmlDocument(); try { //path = p.Server.MapPath(file); path = AppDomain.CurrentDomain.BaseDirectory + file; } catch (Exception e) { Exceptions.LogOnly(e); path = Directory.GetCurrentDirectory() + "\\" + file; } if (!System.IO.File.Exists(path)) { throw Exceptions.Log("Config file not found: " + path); } x.Load(path); XReader n = new XReader(x); XReader xr = n.Reset()["configuration"]["connections"]; foreach (XReader item in xr) { try { string decoder = item.Reset()["$decoder"].Value; string decodeMethod = item.Reset()["$method"].Value; Type typ = Type.GetType(item.Reset()["$type"].Value); Db db = (Db)Activator.CreateInstance(typ); //new Db(item.Value, item["$type"].Value, item["$url"].Value); if (string.IsNullOrEmpty(decoder)) { db.ConnStr = item.Value; } else { string decoded; if (string.IsNullOrEmpty(decodeMethod)) { decodeMethod = "Decode"; } decoded = (string)ClassHelper.Invoke(Type.GetType(decoder), decodeMethod, BindingFlags.Static | BindingFlags.Public | BindingFlags.InvokeMethod, new object[] { item.Value }); db.ConnStr = decoded; } list[item.Name] = db; } catch (Exception err) { Exceptions.LogOnly(err); throw err; } } }
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.Reset()["Plugin"]["$File"].Value); typName = xr.Reset()["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); } } }