/// <summary> /// 中心店信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CenterInfo_Click(object sender, RoutedEventArgs e) { if (_centersInfo == null) { _centersInfo = new CenterSInfo(); } if (!_checkText.checkNumIsEmpty(this.centerID3.Text)) { return; } if (!_checkText.checkNumIsEmpty(this.ProdectID3.Text)) { return; } if (!_checkText.checkNumIsEmpty(this.StocksNum3.Text)) { return; } if (!_checkText.checkTextIsEmpty(this.ProdectName3.Text)) { return; } _centersInfo.MarketName = this.centerName3.Text; _centersInfo.CenterID = Convert.ToInt32(this.centerID3.Text); _centersInfo.prodectID = Convert.ToInt32(this.ProdectID3.Text); _centersInfo.prodectNum = Convert.ToInt32(this.StocksNum3.Text); _centersInfo.prodectName = this.ProdectName3.Text; string data = XMLSerialization.Serialize(_centersInfo); addInfo("CenterInfo", data); }
void Load() { try { OptionsXML xml = XMLSerialization.FileToObject <OptionsXML>(GetFilePath()); if (xml != null) { UISetFrameRate(xml.targetFrameRate); UISetVSyncCount(xml.vSyncCount); UISetRefreshRate(xml.targetRefreshRate); UISetMaxQueuedFrames(xml.maxQueuedFrames); UISetMouseSpeed(xml.mouseSpeed); UISetMouseButton(xml.useButtonInsteadOfMouseMove, xml.inputKey); UISetFPSFontSize(xml.FPSFontSize); UISetFrameFontSize(xml.FrameFontSize); UISetFrameChangeColor(xml.frameChangeColor); Apply(); } } catch (Exception ex) { Debug.LogError("Failed to Load Options - " + ex.Message); } }
public void CObjXMLSerializationTest() { string fileName = "CSerializationTest.xml"; XMLSerialization <C> serializer = new XMLSerialization <C>(fileName, c); serializer.Serialize(); string serializedContent = File.ReadAllText(fileName); Assert.AreEqual(serializedContent, @"<root xmlns:json=""http://james.newtonking.com/projects/json"" json:id=""1"" json:type=""Zad2Serializer.ObjectModel.C, Zad2Serializer""> <Name>Michał</Name> <LastName>Kowalski</LastName> <Number>5321</Number> <Date>2020-01-02T00:00:00</Date> <ObjA json:id=""2"" json:type=""Zad2Serializer.ObjectModel.A, Zad2Serializer""> <Name>Dominik</Name> <LastName>Karski</LastName> <Number>4124</Number> <Date>2019-12-01T00:00:00</Date> <ObjB json:id=""3"" json:type=""Zad2Serializer.ObjectModel.B, Zad2Serializer""> <Name>Sebastian</Name> <LastName>Kujawski</LastName> <Number>9669</Number> <Date>2019-10-01T00:00:00</Date> <ObjC json:ref=""1"" /> </ObjB> </ObjA> </root>"); }
public IActionResult Post() { XMLSerialization serilization = new XMLSerialization(); serilization.DeSerializeFromXml("test.xml"); return(Ok()); }
void serviceClient_ImportInfoCompleted(object sender, ImportInfoCompletedEventArgs e) { if (e.Error == null) { string tmp = e.Result; string[] t = tmp.Split(';'); if (t[0] != "无信息") { Orders = XMLSerialization.Desrialize(Orders, t[0]); } if (Orders.Count <= 0) { } else { if (t[1] != "无信息") { orderMarket = XMLSerialization.Desrialize(orderMarket, t[1]); AddMarkGif(orderMarket[0]); this.warn.Width = 65; this.warn.Height = 65; } } } }
/// <summary> /// 找总店 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void serviceClient_SearchProdectsByIDCompleted(object sender, SearchDetailsByIDCompletedEventArgs e) { if (e.Error == null) { //查到总店信息 string tmp = e.Result; if (tmp != "无信息") { CenterMarketInfo = XMLSerialization.Desrialize(CenterMarketInfo, tmp); oradrsForm = new oradrForm(); oradrsForm.warnMarks = this.warnMarks; oradrsForm.markLayer = this.markLayer; oradrsForm.VecObj = this.vecObj; oradrsForm.mapContainer = this.mapContainer; oradrsForm.graphicsLayer = this.graphicsLayer; oradrsForm.markInfo = orderMarket[0]; oradrsForm.orders = Orders; oradrsForm.CenterMarketInfo = CenterMarketInfo[0]; oradrsForm.initInfo(); oradrsForm.Show(); } else { MessageBox.Show("没有订货信息"); } } }
private void chargerToolStripMenuItem_Click(object sender, EventArgs e) { chargerToolStripMenuItem.Enabled = false; if (Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Production")) { foreach (string f in Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Production", "Production*.xml")) { try { Production production = XMLSerialization <Production> .Deserialize(f); production.EtatProductionChange += Prod_EtatProductionChange; production.ProductionReussie += Prod_QteProductionChange; production.ErreurEstApparue += Prod_ErreurEstApparue; mesProductions.Add(production.Type, production); AddProductionToIHM(production); } catch (UnauthorizedAccessException e1) { MessageBox.Show("L'utilisateur ne possède pas les droits de lecture du dossier", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception e2) { MessageBox.Show("L'opération est invalide", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("Le dossier n'existe pas", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void LoadContent(ContentManager content) { var tiles = new List <Tile>(); XMLSerialization.LoadXML(out tiles, string.Format("Content\\{0}_map.xml", _mapName)); if (tiles != null) { _tiles = tiles; _tiles.Sort((n, i) => n.ZPos > i.ZPos ? 1 : 0); foreach (var tile in this._tiles) { tile.LoadContent(content); tile.ManagerCamera = _managerCamera; } } var tilesCollision = new List <TileCollision>(); XMLSerialization.LoadXML(out tilesCollision, string.Format("Content\\{0}_map_collision.xml", _mapName)); if (tilesCollision != null) { _tileCollisions = tilesCollision; _tileCollisions.ForEach(t => t.ManagerCamera = _managerCamera); } }
public void LoadContent(ContentManager content) { var tiles = new List <Tile>(); XMLSerialization.LoadXML(out tiles, $"Content\\Maps\\{_mapName}_map.xml"); if (tiles != null) { _tiles = tiles; _tiles.Sort((n, i) => n.ZPos > i.ZPos ? 1 : 0); foreach (var tile in _tiles) { tile.LoadContent(content); tile.ManagerCamera = _managerCamera; } } var tileCollisions = new List <TileCollision>(); XMLSerialization.LoadXML(out tileCollisions, $"Content\\Maps\\{_mapName}_map_collision.xml"); if (tileCollisions != null) { _tileCollisions = tileCollisions; _tileCollisions.ForEach(t => t.ManagerCamera = _managerCamera); } }
public void SafingService_SafeFile_IsTrue() { //arrange var XML = new XMLSerialization(); var safe = new SafingService(); var mdi = new MetadataItem(); var adding = new AddingClass(); var file = new FileMove(); var Benutzer = "Adrian"; var Bezeichnung = "Test"; var Stichwoerter = "Test2"; DateTime Erfassungsdatum = DateTime.Now; var filepath = @"C:\Users\addik\Desktop\test1\testen.docx"; var IsRemoveEnabled = false; var SelectedTypItem = "Verträge"; DateTime?Valutadata = DateTime.Now; Guid guid = Guid.NewGuid(); //act mdi = adding.createMetadataItem(Benutzer, Bezeichnung, Stichwoerter, Erfassungsdatum, filepath, IsRemoveEnabled, SelectedTypItem, Valutadata, guid); safe.SafeFile(file, mdi); var result = File.Exists($@"{mdi.SavePath}\{mdi.XMLFileName}"); //Assert Assert.IsTrue(result); }
public IActionResult Get() { //This function creates the template to get the serialized object from to form the attack XMLSerialization serilization = new XMLSerialization(); serilization.SerializeToXml("test.xml"); return(Ok()); }
//Get settings from UI, set to ConfigData, and save public void SaveSoundConfig() { //Get settings from UI UpdateSoundConfig(); //Save to XML file XMLSerialization.Serialize <C_ConfigSettings>(ConfigData, _configFileName); }
void SaveToFile() { OptionsXML xml = new OptionsXML(); xml.Set(Application.targetFrameRate, QualitySettings.vSyncCount, Screen.currentResolution.refreshRate, QualitySettings.maxQueuedFrames, (int)MouseTranslate.mouseSpeed, MouseTranslate.useButtonInsteadOfMouseMove, MouseTranslate.inputKey, FPSFontText.fontSize, FrameFontText.fontSize, frame.changeColors); XMLSerialization.ToXMLFile(xml, GetFilePath()); }
public void XMLSerialization_Deserialize_IsTrue() { //arrange var XML = new XMLSerialization(); var mdi = new MetadataItem(); //act mdi = XML.DeserializeObject(path + @"2019\5e60a267-f59d-49a1-a735-b53180caca1a_Metadata.xml"); //Assert Assert.IsTrue(mdi.XMLFileName.Equals("5e60a267-f59d-49a1-a735-b53180caca1a_Metadata.xml")); }
public void TestWriteXML() { Let l = new Let(9363, 4, 0.125, 2); Posiljaoc p = new Posiljaoc("Amela", "Spica", "2901994175003", "+38762-282-330", "bla"); double cijena = l.izracunajCijenu(); UneseniLet ul = new UneseniLet(p, l, 1, cijena); Lufthansa lf = new Lufthansa(); lf.letovi.Add(ul); XMLSerialization.WriteXML <List <UneseniLet> >(lf.letovi); }
private void xmlButton_Click(object sender, RoutedEventArgs e) { String actorPath = Environment.CurrentDirectory.ToString() + "\\Serialization\\XML\\Actors.xml"; String employeePath = Environment.CurrentDirectory.ToString() + "\\Serialization\\XML\\Employees.xml"; String scenePath = Environment.CurrentDirectory.ToString() + "\\Serialization\\XML\\Scenes.xml"; String filmPath = Environment.CurrentDirectory.ToString() + "\\Serialization\\XML\\Films.xml"; XMLSerialization serialization = new XMLSerialization(); SerializeData(serialization, actorPath, employeePath, scenePath, filmPath); }
static void Main(string[] args) { RestaurantHandler listRestaurants = new RestaurantHandler(); RestaurantCrud crud = new RestaurantCrud(); var restaurants = crud.LoadRestaurants(); foreach (var place in restaurants) { listRestaurants.AddRestaurant(place); } //crud.addRestaurant(listRestaurants); foreach (Restaurant place in listRestaurants.restaurants) { place.displayInfo(); } /* * string input; * Console.WriteLine("Enter a name or partial restaurant name to select"); * input = Console.ReadLine().ToString(); * listRestaurants.SelectRestaurant(input); * listRestaurants.AddReviewToThisRestaurant(); * listRestaurants.DisplayTheseReviews(); */ XMLSerialization restaurantXMLHandler = new XMLSerialization(); RestaurantHandler xmlRestaurantList; xmlRestaurantList = restaurantXMLHandler.ReadListFromXML(); foreach (Restaurant place in xmlRestaurantList.restaurants) { listRestaurants.restaurants.Add(place); } foreach (Restaurant place in listRestaurants.restaurants) { place.displayInfo(); } crud.addMultipleRestaurants(listRestaurants); }
////////////////////////////////////////// //Get settings, set to MapLayout, and save public void SaveMapLayout() { MapLayout = new C_MapLayout(); MapLayout.tileLocations = Board.instance.GetMarkedTiles(); MapLayout.buildingTypeIDs = Buildings.instance.GetBuildingTypes(); MapLayout.buildingLocations = Buildings.instance.GetBuildingLocations(); MapLayout.tileAttributes = Board.instance.GetTileAttributes(); //Save to XML file XMLSerialization.Serialize <C_MapLayout>(MapLayout, _fullFileNamePath); }
public string addData(string type, string info) { string rlt = ""; string strSql = ""; info = xmlChang(info); ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["markets"].ToString(); switch (type) { case "marketsInfo": { DataClasses.marketsInfo market = new DataClasses.marketsInfo(); market = XMLSerialization.Desrialize(market, info); strSql = "insert into marketsInfos values (" + market.X + "," + market.Y + "," + market.CenterFlag + "," + market.MarketID + ",'" + market.MarketName + "','" + market.Address + "'," + market.CenterID + ")"; break; } case "prodectsInfo": { DataClasses.prodectsInfo prodect = new DataClasses.prodectsInfo(); prodect = XMLSerialization.Desrialize(prodect, info); strSql = "insert into prodectsInfo values ('" + prodect.MarketName + "'," + prodect.MarketID + "," + prodect.ProdectID + "," + prodect.Price + "," + prodect.SaleNum + "," + prodect.InstocksNum + "," + prodect.PreNum + "," + prodect.ReceNum + ",'" + prodect.ProdectName + "'," + prodect.InerPrice + ")"; break; } case "CenterInfo": { DataClasses.CenterSInfo center = new DataClasses.CenterSInfo(); center = XMLSerialization.Desrialize(center, info); strSql = "insert into Centers_ProdectsInfos values ('" + center.MarketName + "'," + center.CenterID + "," + center.prodectID + ",'" + center.prodectName + "'," + center.prodectNum + ")"; break; } case "Financial": { DataClasses.FinancialInfo financial = new DataClasses.FinancialInfo(); financial = XMLSerialization.Desrialize(financial, info); strSql = "insert into Financial_statement values ('" + financial.MarketName + "'," + financial.MarketID + "," + financial.totalAmount + "," + financial.SaleAmount + "," + financial.InerAmount + ")"; } break; } if (!upp(strSql)) { rlt = "添加失败!"; return(rlt); } return("添加成功!"); }
/// <summary> /// Start XMLSerialization loading a Monster object /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLoadMonster_Click(object sender, RoutedEventArgs e) { XMLSerialization xmlSerialization = new XMLSerialization(); xmlSerialization.LoadMonster(); Monster loadedMonster = xmlSerialization.Monster; ClearMonsterStats(); if (loadedMonster != null) { DisplayMonsterStats(loadedMonster); } }
public void AObjXMLDeserializationTest() { string fileName = "ADeserializationTest.xml"; XMLSerialization <A> serializer = new XMLSerialization <A>(fileName, a); serializer.Serialize(); XMLSerialization <A> tmp = new XMLSerialization <A>("ADeserializationTest.xml", a); A desResult = tmp.Deserialize(); Assert.AreEqual(desResult.Name, a.Name); Assert.AreEqual(desResult.LastName, a.LastName); Assert.AreEqual(desResult.Number, a.Number); Assert.AreEqual(desResult.Date, a.Date); }
public void BObjXMLDeserializationTest() { string fileName = "BDeserializationTest.xml"; XMLSerialization <B> serializer = new XMLSerialization <B>(fileName, b); serializer.Serialize(); XMLSerialization <B> tmp = new XMLSerialization <B>("BDeserializationTest.xml", b); B desResult = tmp.Deserialize(); Assert.AreEqual(desResult.Name, b.Name); Assert.AreEqual(desResult.LastName, b.LastName); Assert.AreEqual(desResult.Number, b.Number); Assert.AreEqual(desResult.Date, b.Date); }
public void CObjXMLDeserializationTest() { string fileName = "CDeserializationTest.xml"; XMLSerialization <C> serializer = new XMLSerialization <C>(fileName, c); serializer.Serialize(); XMLSerialization <C> tmp = new XMLSerialization <C>("CDeserializationTest.xml", c); C desResult = tmp.Deserialize(); Assert.AreEqual(desResult.Name, c.Name); Assert.AreEqual(desResult.LastName, c.LastName); Assert.AreEqual(desResult.Number, c.Number); Assert.AreEqual(desResult.Date, c.Date); }
/// <summary> /// Wartości inicjalizujące /// </summary> private void InitializeValues() { if (File.Exists(_settingsPath)) { settings = XMLSerialization.Deserialization(_settingsPath); } else { settings.DefaultSettings(); } ordersCount = settings.OrdersCount.Count; datePickerFrom.SelectedDate = DateTime.Today.AddMonths(settings.DateFrom); datePickerTo.SelectedDate = DateTime.Today.AddMonths(settings.DateTo); comboBoxOrdersOnPage.Text = settings.OrdersCount.Text; }
/// <summary> /// Start XMLSerialzation to save a Monster object /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSaveMonster_Click(object sender, RoutedEventArgs e) { XMLSerialization xmlSerialization = new XMLSerialization(); if (CheckInputs()) { AssignInputs(); Monster monsterToSave = new Monster(Name, HealthPoints, ArmorClass, PassivePerception, DexterityModifier, Type, Resistances, Immunities, Speed, Attacks, MonsterSpecials, Multiattack, 0); xmlSerialization.SaveMonster(monsterToSave); } else { MessageBox.Show("Check your inputs!", "Error"); } }
public void LoadContent() { var tiles = new List <TileGraphic>(); XMLSerialization.LoadXML(out tiles, string.Format("Content\\Maps\\{0}\\{0}_tiles.map", _mapName)); if (tiles != null) { _tiles = tiles; _tiles.Sort((n, i) => n.ZPos > i.ZPos ? 1 : 0); foreach (var tile in _tiles) { tile.LoadContent(); tile.ManagerCamera = _managerCamera; } } var tilesCollision = new List <TileCollision>(); XMLSerialization.LoadXML(out tilesCollision, string.Format("Content\\Maps\\{0}\\{0}_collision.map", _mapName)); if (tilesCollision != null) { _tileCollisions = tilesCollision; _tileCollisions.ForEach(t => t.ManagerCamera = _managerCamera); } //Just for test var dictionary = new Dictionary <int, List <IGameEvent> >(); dictionary.Add(0, new List <IGameEvent> { new GameEventMessage("I start tile events with id 1"), new GameEventSwitch(1, true) }); _tileEvents.Add(new TileEvent(1, 1, dictionary)); var dictionary2 = new Dictionary <int, List <IGameEvent> >(); dictionary2.Add(1, new List <IGameEvent>() { new GameEventMessage("Hello! I'm tile event with id 1") }); _tileEvents.Add(new TileEvent(1, 5, dictionary2)); _tileEvents[0].ManagerCamera = _managerCamera; _tileEvents[1].ManagerCamera = _managerCamera; }
/// <summary> /// 设置门店信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void set_market_Click(object sender, RoutedEventArgs e) { if (!_checkText.checkNumIsEmpty(this.marketID0.Text)) { return; } if (!_checkText.checkTextIsEmpty(this.MarketName0.Text)) { return; } if (!_checkText.checkTextIsEmpty(this.address0.Text)) { return; } if (this.centerID0.IsEnabled) { if (!_checkText.checkNumIsEmpty(this.centerID0.SelectedItem.ToString())) { return; } _marketsInfo.CenterID = Convert.ToInt32(this.centerID0.SelectedItem.ToString()); } else { _marketsInfo.CenterID = -1; } _marketsInfo.MarketID = Convert.ToInt32(this.marketID0.Text); _marketsInfo.MarketName = this.MarketName0.Text; _marketsInfo.Address = this.address0.Text; _marketsInfo.X = markPnt.X; _marketsInfo.Y = markPnt.Y; this.marketID1.Text = this.marketID0.Text; this.marketID2.Text = this.marketID0.Text; this.centerID3.Text = this.marketID0.Text; this.centerName3.Text = this.MarketName2.Text = this.marketName1.Text = this.MarketName0.Text; string addmarket = XMLSerialization.Serialize(_marketsInfo); addInfo("marketsInfo", addmarket); //ServiceClient.addData_marketsInfoAsync(_marketsInfo); //ServiceClient += new EventHandler<addDataCompletedEventArgs>(ServiceClient_addDataCompleted); }
////////////////////////////////////////// public void LoadGameLevelData() { //Get file name from UI, parse, and set to file setFileName(GameLevelDataNameGen.getName(input_fileName.text)); //Load from XML file GameLevelData = XMLSerialization.Deserialize <C_GameLevelData>(_fullFileNamePath); //Set level name to UI input_levelName.text = GameLevelData.m_levelName; //Pass to game level data to the processor script_gameLevelData = null; script_gameLevelData = GO_GameLevelProcessor.GetComponent <GameLevelProcessor>(); if (script_gameLevelData != null) { script_gameLevelData.gameLevelData = GameLevelData; } }
public DataTable GetDataValuesSOAP(string start, string end, string siteCode, string variableCode, string url) { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("time", typeof(DateTime))); dt.Columns.Add(new DataColumn("value", typeof(double))); System.Collections.Generic.IList<DataValues.DataValues> ListDataValue = new System.Collections.Generic.List<DataValues.DataValues>(); XMLSerialization objXMLSerialization = new XMLSerialization(); string xml = CallWebService(url, siteCode, variableCode, start, end); ListDataValue = objXMLSerialization.ParseGetValues(xml); var ListVariableInfo = objXMLSerialization.GetMetaData(xml); if (ListVariableInfo.Count > 0) VariableName = ListVariableInfo[0].ToString(); else VariableName = "unknown variable"; if (ListVariableInfo.Count > 1) YAxisvalue = ListVariableInfo[1].ToString(); else XAxisvalue = "unknown units"; if (ListVariableInfo.Count > 2) XAxisvalue = ListVariableInfo[2].ToString(); else XAxisvalue = "unknown units"; for (int i = 0; i < ListDataValue.Count; i++) { DataRow row = dt.NewRow(); row["time"] = ListDataValue[i].LocalDateTime; row["value"] = ListDataValue[i].Value; dt.Rows.Add(row); } return dt; }
/// <summary> /// 圆查询回调 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ServiceClient_SsarchByCircleCompleted(object sender, SearchByCircleCompletedEventArgs e) { if (first) { first = false; if (e.Error == null) { if (e.Result != "") { string tmp = e.Result; string[] str = tmp.Split(';'); if (str[0] == "无信息!") { MessageBox.Show("所选区域没有门店"); return; } else { MarketList = XMLSerialization.Desrialize(MarketList, str[0]); this.markLayer.RemoveAll(); addMarkList = new List <IMSMark>(); addMarks marks = new addMarks(); marks.markLayer1 = this.markLayer; marks.markets = MarketList; marks.mapContainer = this.mapContainer; addMarkList = marks.AddMarks(); if (str[1] != "无信息") { _prodects = XMLSerialization.Desrialize(_prodects, str[1]); } if (str[2] != "无信息") { _fincials = XMLSerialization.Desrialize(_fincials, str[2]); } this.Show(); } } } } }
/// <summary> /// Okno 'Ustawienia użytkownika' oraz serializacja ustawień i zapis do pliku /// </summary> private void MenuItem_Settings(object sender, RoutedEventArgs e) { ListNotEmptyCheck(); UserSettings userSettings = new UserSettings(); bool?result = userSettings.ShowDialog(); if (result.HasValue && result.Value) { XMLSerialization.Serialization(userSettings.settings, _settingsPath); ordersCount = userSettings.settings.OrdersCount.Count; datePickerFrom.SelectedDate = DateTime.Today.AddMonths(userSettings.settings.DateFrom); datePickerTo.SelectedDate = DateTime.Today.AddMonths(userSettings.settings.DateTo); comboBoxOrdersOnPage.Text = userSettings.settings.OrdersCount.Text; ComboBoxItemsCount(); RefreshOrderList(); } }