private ParamPanel getParamPanel(XReader xReader, string nodeName) { var result = new ParamPanel(); var reader = new XReader() { XmlNode = xReader.XmlNode, NodeName = nodeName }; var xmlHelper = new XHelper(); var target = xmlHelper.TRead <ParamPanel>(reader).FirstOrDefault(); if (target == null) { return(result); } var instance = target.Instance; if (instance == null) { return(result); } result = instance; result.ParamFields = getParamFields(new XReader() { XmlNode = target.XRow.Node }); return(result); }
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; }
/// <summary> /// Reads the atom type mappings from the data file. /// </summary> /// <returns>a <see cref="IReadOnlyDictionary{TKey, TValue}"/> with atom type mappings. <see langword="null"/>, if some reading error occurred.</returns> public IReadOnlyDictionary <string, string> ReadAtomTypeMappings() { IReadOnlyDictionary <string, string> mappings = null; var setting = new XmlReaderSettings { DtdProcessing = DtdProcessing.Parse, ValidationFlags = XmlSchemaValidationFlags.None }; var handler = new OWLAtomTypeMappingHandler(); var parser = XmlReader.Create(input, setting); var reader = new XReader { Handler = handler }; try { var doc = XDocument.Load(parser); reader.Read(doc); mappings = handler.GetAtomTypeMappings(); } catch (IOException exception) { Trace.TraceError(nameof(IOException) + ": " + exception.Message); Debug.WriteLine(exception); } catch (XmlException saxe) { Trace.TraceError(nameof(XmlException) + ": " + saxe.Message); Debug.WriteLine(saxe); } return(mappings ?? Dictionaries.Empty <string, string>()); }
private Select getSelect(XmlNode node) { var result = new Select(); var reader = new XReader() { XmlNode = node, NodeName = "Select" }; var xmlHelper = new XHelper(); var target = xmlHelper.TRead <Select>(reader).FirstOrDefault(); if (target == null) { return(result); } result = target.Instance; reader = new XReader() { XmlNode = target.XRow.Node }; result.ParamPanel = getParamPanel(reader, "ParamPanel"); result.MainGrid = getGridPanel(reader, "MainGrid"); result.MainDetail = getParamPanel(reader, "MainDetail"); result.SummaryGrid = getGridPanel(reader, "SummaryGrid"); result.DetailGrid = getGridPanel(reader, "DetailGrid"); IniUiBizCommands(reader, result); return(result); }
private void IniUiBizCommands(XReader reader, UiBiz biz) { biz.DataValues = getDataValues(reader, "DataValues\\DataValue"); biz.TrimCommands = getCommands(reader, "TrimCommands\\Command"); biz.VerifyCommands = getCommands(reader, "VerifyCommands\\Command"); biz.ExcuteCommand = getCommands(reader, "ExcuteCommands\\Command").FirstOrDefault(); }
public static XReader GetConfigFileReader(string name) { string fullConfigFilename = BaseDir + name + ".Config"; XReader xr = new XReader(fullConfigFilename); return(xr); }
private Crud getCrud(XmlNode node) { var reader = new XReader() { XmlNode = node, NodeName = "Crud" }; var xmlHelper = new XHelper(); var list = xmlHelper.TRead <Crud>(reader); var result = new Crud(); var first = list.FirstOrDefault(); if (first != null && first.Instance != null) { result = first.Instance; } result.Primarykey = getPrimarykey(reader); string ss = getDeleteFlag(reader); if (!string.IsNullOrWhiteSpace(ss)) { result.DeleteFlag = ss; } result.Uniques = getUniques(reader); result.SeqFields = getSeqFields(reader); return(result); }
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); }); } }); }
/// <summary> /// 获取配置文件 /// </summary> /// <param name="name"></param> /// <returns></returns> private void iniMapperXml(FileInfo fi) { var instances = new McUIInfo[0]; XReader reader = new XReader() { XmlFile = fi.FullName, NodeName = "McUI" }; var mapper = new XHelper(); instances = mapper.TMapper <McUIInfo>(reader); if (instances == null || instances.Length == 0) { return; } foreach (McUIInfo ui in instances) { string fileName = Path.Combine(fi.Directory.FullName, ui.Uri); fileName = new FileInfo(fileName).FullName; log.Debug(ui.Name + " = " + fileName); UiHelper uiHelper = new UiHelper(); new UiXHelper().IniUiHelper(uiHelper, fileName); uiHelper.Name = ui.Name; if (!uiHelperStore.ContainsKey(ui.Name)) { uiHelperStore.Add(ui.Name, uiHelper); } } }
/// <summary> /// Triggers the XML parsing of the data file and returns the read Isotopes. /// It turns of XML validation before parsing. /// </summary> /// <returns>a List of Isotope's. Returns an empty list is some reading error occurred.</returns> public IReadOnlyList <IIsotope> ReadIsotopes() { var reader = new XReader(); var handler = new IsotopeHandler(); reader.Handler = handler; try { var settings = new XmlReaderSettings { ValidationType = ValidationType.None, ValidationFlags = System.Xml.Schema.XmlSchemaValidationFlags.None }; var xreader = XmlReader.Create(input, settings); var doc = XDocument.Load(xreader); reader.Read(doc); return(handler.Isotopes); } catch (Exception exception) { Trace.TraceError($"{exception.GetType().Name}: {exception.Message}"); Debug.WriteLine(exception); } return(Array.Empty <IIsotope>()); }
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(); }
// private functions /// <summary> /// Reads a ChemFile object from input. /// </summary> /// <returns>ChemFile with the content read from the input</returns> private IChemFile ReadChemFile(IChemObjectBuilder bldr) { IChemFile cf = null; XmlReaderSettings setting = new XmlReaderSettings { ValidationFlags = XmlSchemaValidationFlags.None }; InChIHandler handler = new InChIHandler(bldr); try { var r = new XReader { Handler = handler }; XDocument doc = XDocument.Load(input); r.Read(doc); cf = handler.ChemFile; } catch (IOException e) { Trace.TraceError($"IOException: {e.Message}"); Debug.WriteLine(e); } catch (XmlException saxe) { Trace.TraceError($"SAXException: {saxe.Message}"); Debug.WriteLine(saxe); } return(cf); }
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); }
private AppBehind() { var r = new XReader { Directory = @".", FileName = @"Setting.config" }; r.Parse(); WindowHeight = int.Parse(r.Node.Find(@"SettingDef").Find(@"Window").Find(@"Height").NodeValue); WindowWidth = int.Parse(r.Node.Find(@"SettingDef").Find(@"Window").Find(@"Width").NodeValue); FontFamily = r.Node.Find(@"SettingDef").Find(@"Window").Find(@"FontFamily").NodeValue; FontSize = double.Parse(r.Node.Find(@"SettingDef").Find(@"Window").Find(@"FontSize").NodeValue); DataGridRowHeightPlus = double.Parse(r.Node.Find(@"SettingDef").Find(@"DataGrid").Find(@"RowHeightPlus").NodeValue); RunInitialize = @"Yes".Equals(r.Node.Find(@"SettingDef").Find(@"Initialize").NodeValue); ClonePriorTables = new List <string>(); r.Node.Find(@"SettingDef").Find(@"Clone").Find(@"PriorTables").Children .ForEach(c => ClonePriorTables.Add(c.NodeValue)); MainWindowCaptions = new MainWindowCaptions(r.Node); FileBrowseCaptions = new FileBrowseCaptions(r.Node); OFWindowCaptions = new OFWindowCaptions(r.Node); TableListCaptions = new TableListCaptions(r.Node); QueryStringInputCaptions = new QueryStringInputCaptions(r.Node); StringStorageCaptions = new StringStorageCaptions(r.Node); StringCardCaptions = new StringCardCaptions(r.Node); BinaryStorageCaptions = new BinaryStorageCaptions(r.Node); BinaryCardCaptions = new BinaryCardCaptions(r.Node); TagMasterCaptions = new TagMasterCaptions(r.Node); TagCardCaptions = new TagCardCaptions(r.Node); CloneCaptions = new CloneCaptions(r.Node); }
private GridPanel getGridPanel(XReader xReader, string nodeName) { var result = new GridPanel(); var reader = new XReader() { XmlNode = xReader.XmlNode, NodeName = nodeName }; var xmlHelper = new XHelper(); var targets = xmlHelper.TRead <GridPanel>(reader); var target = targets.FirstOrDefault(); if (target == null) { return(result); } result = target.Instance; result.Columns = getGridColumns(new XReader() { XmlNode = target.XRow.Node }); result.ColumnCount = result.Columns.Count; result.TotalColumns = getTotalColumns(new XReader() { XmlNode = target.XRow.Node }); return(result); }
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["configuration"]["connections"]; foreach (XReader item in xr.Children) { try { string decoder = item["$decoder"].Value; string decodeMethod = item["$method"].Value; Type typ = Type.GetType(item["$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 functions private IChemFile ReadChemFile(IChemFile file) { Debug.WriteLine("Started parsing from input..."); var setting = new XmlReaderSettings { DtdProcessing = DtdProcessing.Parse, ValidationFlags = XmlSchemaValidationFlags.None, XmlResolver = new CMLResolver() }; XmlReader parser; if (input == null) { Debug.WriteLine($"Parsing from URL: {url}"); parser = XmlReader.Create(url, setting); } else { Debug.WriteLine("Parsing from Reader"); parser = XmlReader.Create(input, setting); } CMLHandler handler = new CMLHandler(file); // copy the manually added conventions foreach (var conv in userConventions.Keys) { handler.RegisterConvention(conv, userConventions[conv]); } var reader = new XReader { Handler = handler }; try { var doc = XDocument.Load(parser); reader.Read(doc); } catch (IOException e) { var error = "Error while reading file: " + e.Message; Trace.TraceError(error); Debug.WriteLine(e); throw new CDKException(error, e); } catch (XmlException saxe) { string error = "Error while parsing XML: " + saxe.Message; Trace.TraceError(error); Debug.WriteLine(saxe); throw new CDKException(error, saxe); } return(file); }
private List <GridColumn> getGridColumns(XReader xReader) { var reader = new XReader() { XmlNode = xReader.XmlNode, NodeName = "GridColumn" }; var xmlHelper = new XHelper(); return(xmlHelper.TMapper <GridColumn>(reader).ToList <GridColumn>()); }
public static void XFile(string arg) { using (FileStream stream = new FileStream(arg, FileMode.Open)) using (BinaryReader reader = new BinaryReader(stream)) { XFile file = new XFile(reader); string modelFormat = Config.GetValueOrDefault("Models", "Format", "DAE"); if (modelFormat == "OBJ") { bool splitMaterials = Config.GetValueOrDefault("OBJ", "SplitByMaterial", "False").ToLower() == "true"; Console.WriteLine(" Writing OBJ file..."); XUtils.ExportOBJ(file.Objects[0][1].Object, Path.ChangeExtension(arg, ".obj"), SharpDX.Matrix.RotationX(-SharpDX.MathUtil.PiOverTwo), true, ".dds", splitMaterials); } else if (modelFormat == "DAE") { BHDFile bhd = null; if (File.Exists(Path.ChangeExtension(arg, ".bhd"))) { Console.WriteLine(" Reading BHD..."); bhd = new BHDFile(Path.ChangeExtension(arg, ".bhd")); } /*if (bhd == null) * { * Console.WriteLine("[ERROR]: No BHD file with matching name! Aborting."); * throw new Exception(); * }*/ Console.WriteLine(" Writing DAE file..."); bool stripUnusedMaterials = Config.GetValueOrDefault("DAE", "StripUnusedMaterials", "False").ToLower() == "true"; Collada.Utils.ExportCOLLADA(file, bhd, Path.ChangeExtension(arg, ".dae"), SharpDX.Matrix.RotationX(-SharpDX.MathUtil.PiOverTwo), true, ".dds", stripUnusedMaterials); } else if (modelFormat == "TXT") { Console.WriteLine(" Dumping X tokens..."); stream.Position = 0; XHeader header = new XHeader(reader); List <XTemplate> templates = new List <XTemplate>(); List <XObject> objects = new List <XObject>(); XReader xreader = new XReader(reader, header, templates, objects); using (StreamWriter writer = new StreamWriter(Path.ChangeExtension(arg, ".txt"))) { foreach (XToken token in xreader.Tokens) { writer.WriteLine(token.ToString()); } } } else { Console.WriteLine(" [ERROR]: Invalid model format specified in LOMNTool.ini! (LOMNTool.ini:[Models].Format)"); } } }
public void OnPluginsLoad(DeskWall sender, PluginItem plugin) { XReader xr = new XReader(ConfigFilePath); bool display = (xr["Plugin"]["Style"]["$Display"].Value == "true"); //NtForm.BgImgDir = BaseDir + "\\" + xr["Plugin"]["Style"]["$BackgroundDir"].Value; NtForm.NtIcon.Visible = display; NtForm.NtIcon.Icon = new Icon(BaseDir + "\\tray.ico"); Application.Run(NtForm); }
private List <SeqField> getSeqFields(XReader xReader) { var reader = new XReader() { XmlNode = xReader.XmlNode, NodeName = "SeqField" }; var xmlHelper = new XHelper(); var result = xmlHelper.TMapper <SeqField>(reader); return(result.ToList <SeqField>()); }
private List <JavaScript> getJavaScripts(XmlNode node) { var reader = new XReader() { XmlNode = node, NodeName = "JavaScript" }; var xmlHelper = new XHelper(); var result = xmlHelper.TMapper <JavaScript>(reader); return(result.ToList <JavaScript>()); }
private string getDeleteFlag(XReader xReader) { var reader = new XReader() { XmlNode = xReader.XmlNode, NodeName = "DeleteFlag" }; var xmlHelper = new XHelper(); var result = xmlHelper.TMapper <string>(reader); return(result.FirstOrDefault()); }
private List <Unique> getUniques(XReader xReader) { var reader = new XReader() { XmlNode = xReader.XmlNode, NodeName = "Unique" }; var xmlHelper = new XHelper(); var result = xmlHelper.TMapper <Unique>(reader); return(result.ToList <Unique>()); }
private List <Caption> getCaptions(XReader xReader) { var reader = new XReader() { XmlNode = xReader.XmlNode, NodeName = "Caption" }; var xmlHelper = new XHelper(); var result = xmlHelper.TMapper <Caption>(reader); return(result.ToList <Caption>()); }
private Primarykey getPrimarykey(XReader xReader) { var reader = new XReader() { XmlNode = xReader.XmlNode, NodeName = "Primarykey" }; var xmlHelper = new XHelper(); var result = xmlHelper.TMapper <Primarykey>(reader); return(result.FirstOrDefault()); }
private List <Command> getCommands(XReader xReader, string nodeName) { var reader = new XReader() { XmlNode = xReader.XmlNode, NodeName = "Command" }; var xmlHelper = new XHelper(); var result = xmlHelper.TMapper <Command>(reader); return(result.ToList <Command>()); }
private List <DataValue> getDataValues(XReader xReader, string nodeName) { var reader = new XReader() { XmlNode = xReader.XmlNode, NodeName = nodeName }; var xmlHelper = new XHelper(); var result = xmlHelper.TMapper <DataValue>(reader); return(result.ToList <DataValue>()); }
public static EntryDictionary Unmarshal(TextReader reader) { var handler = new DictionaryHandler(); var r = new XReader { Handler = handler }; var doc = XDocument.Load(reader); r.Read(doc); return(handler.Dictionary); }
private void Init(string arg1dir, string arg2file) { XReader x = new XReader(); x.SetDirectory(arg1dir); x.SetFileName(arg2file); x.Parse(); x.GetNode().GetChildren()[0].GetChildren().ForEach(item => { AddBinding(item); }); }
private UiData getUiData(XmlNode node) { var reader = new XReader() { XmlNode = node }; var result = new UiData(); List <Caption> lst = getCaptions(reader); result.AddRangeCaption(lst); result.Crud = getCrud(node); return(result); }
public void SetUp() { reader = new XReader(xml); }