public XDocument LoadSettings() { XMLData xmld = new XMLData(); XDocument settings = xmld.LoadSettings(); return(settings); }
private void Update() { if (Input.GetKeyDown(KeyCode.S)) { Debug.Log("Saving data!"); var ourList = new XMLExample[3]; ourList [0] = new XMLExample(); ourList [1] = new XMLExample(); ourList [2] = new XMLExample(); ourList [0].Initialize(1, "Lightning", 499, 5.0f); ourList [1].Initialize(4, "Earth", 550, 7.0f); ourList [2].Initialize(20, "Water", 600, 8.0f); XMLData.SaveObjects("Potato", "Mashed", ourList); Debug.Log("Data saving complete! Saved to: " + "Potato/Mashed.xml"); } if (Input.GetKeyDown(KeyCode.D)) { Debug.Log("Starting load!"); var ourExampleResults = XMLData.LoadObjects("Potato", "Mashed.xml"); foreach (var e in ourExampleResults) { Debug.Log("CastCount: " + e.CastCount + "\nDamage: " + e.Damage + "\nDamageAmount: " + e.DamageAmount + "\nCastingTime: " + e.CastingTime); } } }
static void Main(string[] args) { //Declare and load your xml file XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load("XMLFile.xml"); //Instatiate the object where you want to store the list values XMLData xmlData = new XMLData(); xmlData.listKeys = new List <string>(); xmlData.listValues = new List <string>(); //Pick the settings parent node XmlNode xmlSettingsNode = xmlDoc.FirstChild; //Loop through the list and add name and values to list foreach (XmlNode xmlNode in xmlSettingsNode.ChildNodes) { //Ignore commented lines if (xmlNode.NodeType != XmlNodeType.Comment) { xmlData.listKeys.Add(xmlNode.Name); xmlData.listValues.Add(xmlNode.InnerText); } } }
/// <summary> /// works at adding a new entry into the monitee list and storages. /// </summary> public void AddMonitoredItem() { //duplicate should not be added in listview. string[] items = new string[] { FolderSelectorBox.Text, ((DestinationBox.Text != "") ? DestinationBox.Text:_DefaultFolder) }; ListViewItem listItems = new ListViewItem(items[0]); ListViewItem.ListViewSubItem subItem1; listItems.Checked = true; subItem1 = new ListViewItem.ListViewSubItem(listItems, items[1]); //listItems.SubItems.Add(subItem1); xmlData = new XMLData(items[0], items[1], XMLDataList.Type(items[0])); monitee = new FolderMonitor.Monitees.Monitee(items[0], items[1], XMLDataList.Type(items[0])); if (XMLDataList.InsertFile(xmlData) && MoniteeList.InsertMonitee(monitee)) { if (!Monitees.MoniteeList.AddedExtra) { Lists.Items.Add(listItems); Monitees.MoniteeList.AddedExtra = false; } MessageBox.Show("Folder successfully added", "Success"); HasChanged = true; } this.FolderSelectorBox.Text = ""; this.DestinationBox.Text = ""; }
public static bool Serialize(List <MyQuery> list, string filePath, out string errorMessage) { errorMessage = ""; //delete file if exits if (File.Exists(filePath)) { File.Delete(filePath); } using (FileStream fileStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write)) { try { var data = new XMLData() { ListQueryData = list }; XmlSerializer xmlSerializer = new XmlSerializer(typeof(XMLData)); xmlSerializer.Serialize(fileStream, data); } catch (Exception e) { errorMessage = e.Message; } finally { fileStream.Close(); } } return(string.IsNullOrEmpty(errorMessage)); }
internal void cargarGen(GeneticAlgorithm a) { Gen gen = a.BestGenByGeneration(); Dictionary <string, List <string> > dictionary = a.GetDictionary(gen); foreach (Agent r in gen.AgentList.AsEnumerable()) { string nl = Environment.NewLine; string RS = ""; foreach (string str in dictionary[r.ID].AsEnumerable()) { RequestedService rs; Service s; rs = (from t in a.RequestedServiceList where t.ID == str select t).FirstOrDefault(); s = (from ss in XMLData.GetInstance().XMLServices where ss.Code == rs.ServiceCode select ss).FirstOrDefault(); RS += "Order ID: " + rs.ID + ", Customer: " + rs.CustomerName + ", Service: " + rs.ServiceCode + ", Time: " + s.Time + ", Commission: " + s.Commission + nl; } dgSalida.Rows.Add(r.ID, r.Name, r.EarnedCommission, r.WorkTime, RS); dgSalida.Rows[dgSalida.Rows.Count - 1].Height = dictionary[r.ID].Count * 30; Console.WriteLine(r); } }
/// <summary> /// Testing still. Saves the subcategories to an XML file. /// </summary> public void SaveSubsAs() { Tuple <string, bool> selectedFile = _fileBrowser.SaveFileAccess( CategoryDirectory, "Save Sub Categories", false); if (selectedFile.Item2) { IXMLDataSub subData = new XMLData() { IncomeSubCategories = Income.AllIncomeCategories, ExpenseSubCategories = Expense.AllExpenseCategories }; XMLWrtier wrtier = new XMLWrtier(selectedFile.Item1, subData); wrtier.WriteSubFile(); // Update the Shell CategoryFileName = selectedFile.Item1; IsSubFileSaved = true; SetSubFileSaveState(); } }
/// <summary> /// Saves the project and sets the save state. /// </summary> public void SaveFile() { IXMLData data = new XMLData() { ProjectName = BudgetFileName, IncomeData = DataViewModel.IncomeDataList.ToList(), ExpenseData = DataViewModel.ExpenseDataList.ToList() }; // Shouldnt get to this point if its false. if (IsMainFileSaved) { XMLWrtier wrtier = new XMLWrtier(MainFileName, data); wrtier.WriteBudgetFile( MessageManager.DisplayMessage, MessageManager.DisplayMessage); } else { SaveFileAs(); } IsMainFileSaved = true; SetMainFileSaveState(); }
public Monitee(XMLData data) { this.Name = data.MoniteePath; this.destination = new String[5]; this.destination[Index] = data.DestinationPath; Index++; }
void Save(XMLData xmlData) { XmlSerializer serializer = new XmlSerializer(typeof(XMLData)); StreamWriter writer = new StreamWriter(path); serializer.Serialize(writer.BaseStream, xmlData); writer.Close(); }
public void SaveSettingsXML() { XMLData xmld = new XMLData(); List <Channel> AllChannels = new List <Channel>(); FeedList.ForEach(i => AllChannels.Add(new Channel(i.getID(), i.Filepath, i.Name, i.URL, i.UpdateInterval, i.LastUpdated, i.Category, i.ListenedToPods))); xmld.SaveAllData(AllChannels); }
public XMLExample[] DataLoad(string folderPath, string fileName) { XMLExample[] newObjects = XMLData.LoadObjects(folderPath, fileName + ".xml"); if (newObjects == null) { return(null); } return(newObjects); }
public virtual void AddData(int line, XMLData data) { if (data != null) { string content = data.ToString().Trim(); if (!"".Equals(content)) { _read.ParseContent(content); } } }
private string GetShortCutXML(DataTable dt) { List <XMLData> row = new List <XMLData>(); foreach (DataRow dr in dt.Rows) { XMLData col = new XMLData(); col.Content = dr["Content"].ToString(); row.Add(col); } return(genericDataDechunker(row)); }
public static void Serialize(List <RelatedTable> list, string filePath) { using FileStream fileStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write); var data = new XMLData() { RelatedTable = list }; XmlSerializer xmlSerializer = new XmlSerializer(typeof(XMLData)); xmlSerializer.Serialize(fileStream, data); fileStream.Close(); }
XMLData Load() { if (!File.Exists(path)) { NewData(); } XmlSerializer serializer = new XmlSerializer(typeof(XMLData)); StreamReader reader = new StreamReader(path); XMLData deserialized = (XMLData)serializer.Deserialize(reader.BaseStream); reader.Close(); return(deserialized); }
public override void Dead() { if (isDead) { return; } isDead = true; int score = XMLData.GameDatas[0].score + GameManage.Instance.round + GameManage.Instance.score; Debug.LogError(XMLData.GameDatas[0].score + " " + GameManage.Instance.round + " " + GameManage.Instance.score); XMLData.SetGameData(score, XMLData.GameDatas[0].talent); UIManage.CreateView(new EndController()); }
public void LoadData() { xmlData = Load(); gameManager.playerStatus.playerHealth = xmlData.playerHealth; gameManager.playerStatus.currentLevel = xmlData.currentLevel; gameManager.playerStatus.currentCheckPoint = xmlData.currentCheckPoint; gameManager.playerStatus.gold = xmlData.gold; gameManager.preferences.musicVolume = xmlData.musicVolume; gameManager.preferences.effectsVolume = xmlData.effectsVolume; gameManager.preferences.vibration = xmlData.vibration; gameManager.preferences.qualityLevel = xmlData.qualityLevel; }
// Use this for initialization public void Start() { patients = XMLData.appData.mPatients.ToArray(); medicals = XMLData.GetMedicinesFromScenario(XMLData.scenario); foreach (var medicine in XMLData.appData.mMedicines) //add gray objects in vanas { if (medicine.mName.ToLower().Contains(GRAYMED.ToLower())) { medicals.Add(medicine.CleanUpName()); } } }
public void ImplementXMLSerialization() { XMLData data = new XMLData(); try { data.Serialization(listOfCar); deserializedListByXML = data.Deserialization(); } catch (Exception ex) { logger.Log(LogLevel.Error, ex.Message); } }
private void cargarOrdenes() { try { requestedServicesDataGridView.Rows.Clear(); requestedServicesDataGridView.Refresh(); XMLData xmlData = XMLData.GetInstance(); requestedServices = xmlData.LoadRequestedServices(); agente.hablar("Las órdenes se cargaron con éxito"); } catch (Exception ex) { agente.hablar("lamentablemente no pude cargar las órdenes"); } }
private void cargarAgentes() { try { agentsDataGridView.Rows.Clear(); agentsDataGridView.Refresh(); XMLData xmlData = XMLData.GetInstance(); agents = xmlData.LoadAgents(); agente.hablar("Los agentes se cargaron con éxito"); } catch (Exception ex) { agente.hablar("lamentablemente no pude cargar los agentes"); } }
/// <summary> /// For TESTING. Used for stress testing. /// ! bad path. /// </summary> public void SaveFileBad(bool path = true) { XMLWrtier writer = new XMLWrtier(); string badPath = @"C:\Users\Daxxn\Daxxn\TestFile.bpn"; string goodPath = @"C:\Users\Daxxn\Desktop\ErrorTest.bpn"; IXMLData goodData = new XMLData() { ProjectName = BudgetFileName, IncomeData = DataViewModel.IncomeDataList.ToList(), ExpenseData = DataViewModel.ExpenseDataList.ToList() }; IXMLData badData = new XMLData() { ProjectName = BudgetFileName, IncomeData = null, ExpenseData = DataViewModel.ExpenseDataList.ToList() }; if (path) { writer = new XMLWrtier(badPath, goodData); } else { writer = new XMLWrtier(goodPath, badData); } try { writer.WriteBudgetFile(); MainFileName = badPath; IsFileOpen = true; IsMainFileSaved = true; SetMainFileSaveState(); } catch (Exception e) { MessageManager.DisplayMessage($"{e.HResult} : {e.Message}", "ERROR!!"); } }
public void LoadAllItems() { XMLData xmld = new XMLData(); XDocument settings = LoadSettings(); String path = (Environment.CurrentDirectory + $"\\podcasts"); var files = xmld.loadXML(path); XDocument xmlDocument; foreach (var file in files) { try // SKAPAR NY FEED O LÄGGER TILL OBJEKT I DESS ITEMS-LISTA { xmlDocument = XDocument.Load(file); var podID = Path.GetFileNameWithoutExtension(file); var items = xmld.LoadChannelItems(xmlDocument, out var podSettings, file); string[] filePathSplit = file.Split('\\'); var feedItems = items.Select(element => new FeedItem { Title = element.Descendants("title").Single().Value, Link = element.Descendants("enclosure").Single().Attribute("url").Value, FolderName = filePathSplit[filePathSplit.Length - 2], Category = podSettings.Descendants("Category").Single().Value, Parent = podID, pubDate = element.Descendants("pubDate").SingleOrDefault().Value, Description = element.Descendants("description").SingleOrDefault().Value, }); Feed feed = FeedList.Single(i => i.getID().ToString().Equals(podID)); feed.Items.AddRange(feedItems.ToList()); } catch { } } }
/// <summary> /// Opens the SaveFileDialog, saves the current file, then stores the save state. /// </summary> public void SaveFileAs() { Tuple <string, bool> selectedFile = _fileBrowser.SaveFileAccess( MainFileDirectory, "Save Budget Plan", BudgetFileName, true); if (selectedFile.Item2) { IXMLData data = new XMLData() { ProjectName = BudgetFileName, IncomeData = DataViewModel.IncomeDataList.ToList(), ExpenseData = DataViewModel.ExpenseDataList.ToList() }; XMLWrtier writer = new XMLWrtier(selectedFile.Item1, data); //writer.WriteBudgetFile( // MessageManager.DisplayMessage, // MessageManager.DisplayMessage); try { writer.WriteBudgetFile(); MainFileName = selectedFile.Item1; IsFileOpen = true; IsMainFileSaved = true; SetMainFileSaveState(); } catch (Exception) { MessageManager.DisplayMessage("An error occured while saving.."); } } }
public void SaveSubs() { if (FileCheck.CheckDirectory(CategoryFileName)) { IXMLDataSub data = new XMLData() { IncomeSubCategories = Income.AllIncomeCategories, ExpenseSubCategories = Expense.AllExpenseCategories }; XMLWrtier wrtier = new XMLWrtier(CategoryFileName, data); wrtier.WriteSubFile(MessageManager.DisplayMessage); IsSubFileSaved = true; SetSubFileSaveState(); } else { SaveSubsAs(); } }
public ActionResult XMLDataProcess(XMLData data) { StringBuilder fileContent = new StringBuilder(); if (data != null) { string myXML = data.XMLDataString; XDocument xdoc = new XDocument(); xdoc = XDocument.Parse(myXML); string node = ""; if (data.operation.ToString() == "Create") { node = "input"; } else { node = "fields"; } var result = xdoc.Element(node).Descendants(); List <String> headers = new List <string>(); string fileContentRow = "Source,Target"; fileContent.AppendLine(fileContentRow); foreach (XElement item in result) { if (data.operation.ToString() == "Create") { fileContentRow = item.Attribute("source").Value + "," + item.Attribute("target").Value + "," + item.Attribute("isFix").Value; } else { fileContentRow = item.Attribute("value").Value + "," + item.Attribute("name").Value + "," + item.Attribute("isFix").Value; } fileContent.AppendLine(fileContentRow); } return(File(new System.Text.UTF8Encoding().GetBytes(fileContent.ToString()), "text/csv", "XMLDATA.csv")); } return(View()); }
public void LoadAllFeeds() { XMLData xmld = new XMLData(); //xmld.LoadAllFeeds(); String path = (Environment.CurrentDirectory + $"\\podcasts"); // Path to a folder containing all XML files in the project directory if (Directory.Exists(path) == false) { Directory.CreateDirectory(path); } XDocument settings = xmld.LoadSettings(); try { var feeds = from item in settings.Descendants("Channel") select new Feed { Id = new Guid(item.Descendants("Id").Single().Value), Name = item.Descendants("Name").Single().Value, URL = item.Descendants("URL").Single().Value, UpdateInterval = int.Parse(item.Descendants("UpdateInterval").Single().Value), LastUpdated = DateTime.Parse(item.Descendants("LastUpdated").Single().Value), Category = item.Descendants("Category").Single().Value, ListenedToPods = item.Descendants("ListenedToPods").Descendants("string").Select(element => element.Value).ToList(), }; //Korrekt antal feeds sparas foreach (Feed feed in feeds) { FeedList.Add(feed); } } catch (Exception) { } LoadAllItems(); }
public void OnClickBuy() { if (XMLData.GameDatas[0].talents.Find(a => a.id == id) != null) { StartMain.Instance.CreateTips("该天赋已购买!"); } TalentConf conf = XMLData.TalentConfs.Find(a => a.id == id); if (conf.num > XMLData.GameDatas[0].score) { StartMain.Instance.CreateTips("天赋点不足!"); } else { XMLData.GameDatas[0].score -= conf.num; XMLData.GameDatas[0].talent += conf.id + ";"; XMLData.GameDatas[0].talents.Add(XMLData.TalentConfs.Find(a => a.id == id)); XMLData.SetGameData(XMLData.GameDatas[0].score, XMLData.GameDatas[0].talent); StartMain.Instance.CreateTips("购买成功!"); button.SetActive(false); CreateItem(); StartMain.Instance.UpdateScore(); } }
public void SaveData(string folderPath, string fileName, XMLExample[] objToSave) { XMLData.SaveObjects(folderPath, fileName, objToSave); }