//---------- private static int fileMaintenanceDriver(FileStream infile) { XMLObject xmlobj; try { xmlobj = new XMLObject(50, gDefType); } catch (Exception) { Console.Error.WriteLine("fileMaintenanceDriver(): " + "cannot instantiate XMLObject()"); return(FAIL); } int result; for (; ;) { result = xmlobj.parseFile(infile); if (result != XMLObject.SUCCESS) { break; } xmlobj.dump(); // Console.WriteLine(xmlobj.generateXML()); // Console.WriteLine(); } return(result); } // end fileMaintenanceDriver() function
private void MainTree_Selected(object sender, RoutedEventArgs e) { XMLObject xmlObject = (XMLObject)MainTree.SelectedItem; ContentText.Text = xmlObject.InnerXml; MainList.ItemsSource = xmlObject.Attributes; }
internal static object DBExport(this XMLObject xmlobject) { if (xmlobject != null) { return(xmlobject.Id); } return(DBNull.Value); }
/// <summary> /// 对象写入 row /// </summary> /// <param name="obj"></param> /// <param name="row"></param> /// <param name="xmlDic"></param> public static void WriteRowObject(object obj, IRow row, Dictionary <int, XMLObject> xmlDic) { foreach (int index in xmlDic.Keys) { XMLObject xmlObject = xmlDic[index]; object result = XMLRead.GetObjectMethodResult(xmlObject, obj); SetValue(row, index, result); } }
private void CheckContent(string c_SampleResultFile) { List <EntropyResult> erl1 = (List <EntropyResult>)XMLObject.XMLToObject(c_SampleResultFile, typeof(List <EntropyResult>)); List <EntropyResult> erl2 = (List <EntropyResult>)XMLObject.XMLToObject(ec.ResultFile, typeof(List <EntropyResult>)); Assert.IsTrue(erl1.Count == erl2.Count); foreach (EntropyResult er1 in erl1) { CheckContentItem(erl1, er1); } }
/// <summary>Konstruktor, ami betölti az eddig feldolgozott fájlok információit.</summary> public TextAnalyticsFilesInfo() { if (File.Exists(c_dbFile)) { ta = (TextAnalyticsXML)XMLObject.XMLToObject(c_dbFile, typeof(TextAnalyticsXML)); } else { ta = new TextAnalyticsXML(); } }
private void LabelOpen_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Data (*.xml)|*.xml"; if (openFileDialog1.ShowDialog() == true) { XMLObject xMLObject = new XMLObject(); ListPorcceses.list_P = xMLObject.DeserializeToObject(openFileDialog1.FileName); Update(); } }
private void SumThreadResult() { try { SumPartialResults(); CalcEntropy(); XMLObject.ObjectToXML(ResultFile, resultList); IsRunCalculation = false; } catch (Exception ex) { IsRunCalculation = false; throw new EntropyCalculatorException(C_SumResultError, ex); } }
private void InternalLink(HistoricalEvent evt, PropertyInfo idProp, PropertyInfo classProp) { var Id = idProp.GetValue(this, null) as int?; XMLObject obj = null; if (Id.HasValue && Id.Value != -1) { if (classProp.PropertyType == typeof(Site)) { obj = World.Sites.ContainsKey(Id.Value) ? World.Sites[Id.Value] : null; } else if (classProp.PropertyType == typeof(Entity)) { obj = World.Entities.ContainsKey(Id.Value) ? World.Entities[Id.Value] : null; } else if (classProp.PropertyType == typeof(HistoricalFigure)) { obj = World.HistoricalFigures.ContainsKey(Id.Value) ? World.HistoricalFigures[Id.Value] : null; } else if (classProp.PropertyType == typeof(Structure)) { var thisSite = this.GetType().GetProperty("Site", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(evt, null) as Site; if (thisSite != null) { obj = thisSite.GetStructure(Id.Value); } } else if (classProp.PropertyType == typeof(Artifact)) { obj = World.Artifacts.ContainsKey(Id.Value) ? World.Artifacts[Id.Value] : null; } else if (classProp.PropertyType == typeof(WorldConstruction)) { WorldConstruction wc; if (!World.WorldConstructions.TryGetValue(Id.Value, out wc)) { wc = new WorldConstruction(Id.Value, World); World.WorldConstructions[Id.Value] = wc; } obj = wc; } else if (classProp.PropertyType == typeof(Region)) { obj = World.Regions.ContainsKey(Id.Value) ? World.Regions[Id.Value] : null; } } classProp.SetValue(this, obj, null); }
public static void Test() { SearchEngineResult result = GetSearchResult(); Console.WriteLine(result); XMLObject xmlObject = result.ToXMLObject(); Console.WriteLine(xmlObject.ToString()); XMLObject newXmlObject = new XMLObject(xmlObject.ToString()); Console.WriteLine(newXmlObject.ToString()); SearchEngineResult newResult = SearchEngineResult.GetSearchEngineResultFromXMLObject(newXmlObject); Console.WriteLine(newResult); Console.WriteLine(result.ToString() == newResult.ToString()); }
private void LoadLogic() { if (!File.Exists(C_DefaultLogicFile)) { throw new EntropyCalculatorException(string.Format(C_LogicFileNotExist, C_DefaultLogicFile)); } try { logic = (EntropyCalculationLogic)XMLObject.XMLToObject( CalculationLogic, typeof(EntropyCalculationLogic)); } catch (Exception ex) { throw new EntropyCalculatorException(string.Format(C_LoadLogicError, C_DefaultLogicFile), ex); } }
private void AddElement() { if (string.IsNullOrEmpty(AddName) || string.IsNullOrEmpty(AddDOB) || string.IsNullOrEmpty(AddNumberOfWidgets)) { AddErrorVisibility = Visibility.Visible; } else { AddErrorVisibility = Visibility.Hidden; string newName = AddName; DateTime newDOB = DateTime.Parse(AddDOB); int newNumberOfWidgets = Convert.ToInt32(AddNumberOfWidgets); XMLObject newObject = new XMLObject(newName, newDOB, newNumberOfWidgets); objects_.Add(newObject); } }
private void LabelSaving_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Title = "Save"; DateTime dateTime = DateTime.Today; saveFileDialog1.FileName = $"Data_{dateTime.Day}_{dateTime.Hour}_{dateTime.Minute}_{dateTime.Second}.xml"; saveFileDialog1.DefaultExt = "txt"; saveFileDialog1.Filter = "Data (*.xml)|*.xml"; saveFileDialog1.FilterIndex = 2; saveFileDialog1.RestoreDirectory = true; if (saveFileDialog1.ShowDialog() == true) { XMLObject xMLObject = new XMLObject(); xMLObject.Pith = saveFileDialog1.FileName; xMLObject.SerializeToXml(ListPorcceses.list_P); } }
public void TestXMLObject() { A a1 = new A() { sA = "sA szöveg", iA = 1, dA = 2.3, bA = true }; a1.b.Add(new B() { sB = "sB 1 szöveg" }); a1.b.Add(new B() { sB = "sB 2 szöveg" }); const string c_TestXMLFile = @"RunTimeTest\a.xml"; XMLObject.ObjectToXML(c_TestXMLFile, a1); A a2 = (A)XMLObject.XMLToObject(c_TestXMLFile, typeof(A)); Assert.IsTrue(a1.sA == a2.sA); Assert.IsTrue(a1.iA == a2.iA); Assert.IsTrue(a1.dA == a2.dA); Assert.IsTrue(a1.bA == a2.bA); Assert.IsTrue(a1.b.Count == 2); Assert.IsTrue(a1.b.Count == a2.b.Count); Assert.IsTrue(a1.b[0].sB == a2.b[0].sB); Assert.IsTrue(a1.b[1].sB == a2.b[1].sB); const string cSA = "sA másik szöveg"; a2.sA = cSA; XMLObject.ObjectToXML(c_TestXMLFile, a2); A a3 = (A)XMLObject.XMLToObject(c_TestXMLFile, typeof(A)); Assert.IsTrue(a3.sA == cSA); }
public XMLData(XmlDocument document) { XMLString = document.InnerXml; XMLObject = XMLParser.Parser(document); }
void ExecuteMethod(XMLObject finalObj) { Debug.Log(finalObj.methodName + " / " + string.Join(", ", finalObj.parameters.ToArray())); }
void FindMethod(XMLObject obj) { if (obj.progressionIndex == 0) { nav.MoveToRoot(); nav.MoveToFirstChild(); } if (nav.HasChildren) { if (obj.commandWords.Length >= obj.progressionIndex) { int childCount = nav.SelectChildren(XPathNodeType.All).Count; nav.MoveToFirstChild(); for (int i = 0; i < childCount; i++) { if (nav.GetAttribute("synonyms", string.Empty) != "") { string[] synonyms = nav.GetAttribute("synonyms", string.Empty).Split(' '); foreach (string synonym in synonyms) { if (synonym == obj.commandWords[obj.progressionIndex]) { obj.xmlPath.Add(nav.Name); obj.progressionIndex++; FindMethod(obj); return; } } } else if (nav.Name[0] == '_') { obj.xmlPath.Add(nav.Name); obj.parameters.Add(obj.commandWords[obj.progressionIndex]); obj.progressionIndex++; FindMethod(obj); return; } else if (nav.Name == "method") { obj.xmlPath.Add(nav.Name); obj.progressionIndex++; obj.methodName = nav.Value; ExecuteMethod(obj); return; } nav.MoveToNext(); } } else { /////////////DEFAULT } } else { Debug.Log("XML has no child nodes at level: " + nav.Name); } }
public XMLData(string XmlString) { XMLString = XmlString; XMLObject = XMLParser.Parser(XmlString); }
public void ExportZu_ZhongDiTu(JTSYQ jtsyqGroup, string saveDir) { IList <JZX> jzxs = JZXCustom.SetJZX(jtsyqGroup.GroupJTSYQ); string mxdPath = saveDir + "\\" + System.IO.Path.GetFileName(JTSYQCustom.JTSYQZDTMxd); string mdbPath = saveDir + "\\" + System.IO.Path.GetFileName(JTSYQCustom.JTSYQZDTMdb); //1、复制maxd FileUtils.CopyFile(JTSYQCustom.JTSYQZDTMxd, mxdPath); //2、复制数据库 FileUtils.CopyFile(JTSYQCustom.JTSYQZDTMdb, mdbPath); //打开工作文件 MapDocumentClass mapDocument = new MapDocumentClass(); mapDocument.Open(mxdPath, ""); AxMapControl mapControl = ArcGisUtils.axMapControl; IMap map = mapDocument.Map[0]; mapControl.Map = map; //3、设置数据源,数据源是相对路径,不需要设置 //4、复制shap JTSYQCustom.SaveMap(jtsyqGroup.GroupJTSYQ); JTSYQCustom.SaveJTSYQBZMap(map, jtsyqGroup.GroupJTSYQ); IList <JZD> jzds = JZDCustom.SaveMap(jtsyqGroup); JZXCustom.SaveJZXMap(jzxs); JZXCustom.SaveJZXBZMap(map, jzxs); JZDCustom.SaveJZDBZMap(map, jzds); double scale = 100.0; mapControl.Extent = JTSYQCustom.SetExtent(jtsyqGroup.GroupJTSYQ); double num = (double)((int)((map.MapScale + 30.0) / scale) * scale + scale); //mapControl.MapScale = 329; ArcGisUtils.ChangeMapScale(mapDocument, num); //5、替换文字内容, int index = 0; for (int a = 0; a > -1; a++) { string tufu = jtsyqGroup.TuFu; if (Utils.IsStrNull(tufu)) { MessageBox.Show("你还没有生成图幅号!!!:" + jtsyqGroup.QLR); ArcGisUtils.Refresh(); return; } index = tufu.IndexOf("、", index + 1); if (index == -1) { break; } if (a % 2 != 0) { jtsyqGroup.TuFu = tufu.Insert(index + 1, "\n"); } } Dictionary <string, XMLObject> xmlObjectDic = XMLRead.XmlToObjects(JTSYQCustom.JTSYQ_Reflect, true); XMLObject xmlObject = new XMLObject { Column = "BLC", Deafult = "1:" + num }; xmlObjectDic.Add("BLC", xmlObject); ArcGisService.ReplaceText(jtsyqGroup, xmlObjectDic, mapDocument); //使用的xml缓存,必须移除 xmlObjectDic.Remove("BLC"); //6、工程文件保留 mapDocument.Save(); mapDocument.Close(); ArcGisUtils.Refresh(); }
public void ExportCun_GongShiTuActions(XZDM cunXZDM, string saveDir) { //IList<JTSYQ> jtsyqs = null; //得到所有界址短线 IList <JZX> jzxs = JZXCustom.SetJZX(cunXZDM.JTSYQS); //从中删除本村的界址短线 for (int a = 0; a < jzxs.Count; a++) { JZX jzx = jzxs[a]; string str = jzx.BM.Substring(0, 12); if (str == cunXZDM.DJZQDM) { jzxs.RemoveAt(a); a--; } } string mxdPath = saveDir + "\\" + System.IO.Path.GetFileName(JTSYQCustom.JTSYQGSTMxd); string mdbPath = saveDir + "\\" + System.IO.Path.GetFileName(JTSYQCustom.JTSYQGSTMDB); //1、复制maxd FileUtils.CopyFile(JTSYQCustom.JTSYQGSTMxd, mxdPath); //2、复制数据库 FileUtils.CopyFile(JTSYQCustom.JTSYQZDTMdb, mdbPath); //打开工作文件 MapDocumentClass mapDocument = new MapDocumentClass(); mapDocument.Open(mxdPath, ""); AxMapControl mapControl = ArcGisUtils.axMapControl; IMap map = mapDocument.Map[0]; mapControl.Map = map; //3、设置数据源,数据源是相对路径,不需要设置 //4、复制 本村的界址线shap JTSYQCustom.SaveMap(cunXZDM.JTSYQS); //设置本村的界址点标注 JTSYQCustom.SaveJTSYQBZMap(map, cunXZDM.JTSYQS); JZXCustom.SaveJZXMap(jzxs); JZXCustom.SaveJZXBZMap(map, jzxs); double scale = 100.0; // mapControl.Extent = JTSYQCustom.SetExtent(cunXZDM.JTSYQS); ArcGisUtils.axMapControl.Extent = JTSYQCustom.GetLayer().AreaOfInterest; double num = (double)((int)((map.MapScale + 30.0) / scale) * scale + scale); //mapControl.MapScale = 329; ArcGisUtils.ChangeMapScale(mapDocument, num); //5、替换文字内容, Dictionary <string, XMLObject> xmlObjectDic = XMLRead.XmlToObjects(JTSYQCustom.XZDM_Reflect, true); XMLObject xmlObject = new XMLObject { Column = "BLC", Deafult = "1:" + num }; xmlObjectDic.Add("BLC", xmlObject); ArcGisService.ReplaceText(cunXZDM, xmlObjectDic, mapDocument); //使用的xml缓存,必须移除 xmlObjectDic.Remove("BLC"); //6、工程文件保留 mapDocument.Save(); mapDocument.Close(); ArcGisUtils.Refresh(); }
private void ModifyMap(XMLObject nextItem) { if (nextItem is HE_CreatedSite || nextItem is HE_ReclaimSite || nextItem is HE_NewSiteLeader || nextItem is HE_SiteTakenOver || nextItem is HE_SiteAbandoned || nextItem is HE_DestroyedSite) { var evt = (HistoricalEvent)nextItem; Color penCol; if (nextItem is HE_CreatedSite) { penCol = (nextItem as HE_CreatedSite).Entity?.Civilization?.Color ?? Color.White; } else if (nextItem is HE_ReclaimSite) { penCol = (nextItem as HE_ReclaimSite).Entity_Civ.Civilization?.Color ?? Color.White; } else if (nextItem is HE_NewSiteLeader) { penCol = (nextItem as HE_NewSiteLeader).Entity_Attacker.Civilization?.Color ?? Color.White; } else if (nextItem is HE_SiteTakenOver) { penCol = (nextItem as HE_SiteTakenOver).Entity_Attacker.Civilization.Color; } else if (nextItem is HE_SiteAbandoned) { penCol = Color.White; } else // if (nextItem is HE_DestroyedSite) { penCol = Color.White; } var g = Graphics.FromImage(_stretchedMap); var loc = new Point(); var markerSize = new SizeF(7.0f, 7.0f); if (_siteSize.Width > 7) { markerSize.Width = (int)_siteSize.Width; } if (_siteSize.Height > 7) { markerSize.Height = (int)_siteSize.Height; } loc.X = (int)(evt.Location.X * _siteSize.Width + _siteSize.Width / 2 - markerSize.Width / 2); loc.Y = (int)(evt.Location.Y * _siteSize.Height + _siteSize.Height / 2 - markerSize.Height / 2); using (var p = new Pen(penCol)) { p.Width = 2; g.DrawEllipse(p, loc.X, loc.Y, markerSize.Width, markerSize.Height); } g.Dispose(); } else { var worldConstruction = nextItem as HE_CreatedWorldConstruction; if (worldConstruction == null) { return; } var evt = worldConstruction; var g = Graphics.FromImage(_stretchedMap); var from = new Point(); var to = new Point(); @from.X = (int)(evt.Site_1.Location.X * _siteSize.Width + _siteSize.Width / 2); @from.Y = (int)(evt.Site_1.Location.Y * _siteSize.Height + _siteSize.Height / 2); to.X = (int)(evt.Site_2.Location.X * _siteSize.Width + _siteSize.Width / 2); to.Y = (int)(evt.Site_2.Location.Y * _siteSize.Height + _siteSize.Height / 2); var lineColor = Color.White; if (evt.Entity?.Civilization != null) { lineColor = evt.Entity.Civilization.Color; } using (var p = new Pen(lineColor)) { p.Width = 2; g.DrawLine(p, @from, to); } g.Dispose(); } }