コード例 #1
0
 public static void SaveChanges(TaxesList _list)
 {
     if (System.IO.Directory.Exists(dataPathTax.Split('/')[0]))
     {
         XmlTextWriter xWriter = new XmlTextWriter(dataPathTax, System.Text.UTF8Encoding.UTF8);
         xWriter.Formatting = Formatting.Indented;
         xSerTax.Serialize(xWriter, _list);
         xWriter.Dispose();
     }
     else
     {
         System.IO.Directory.CreateDirectory(dataPathTax.Split('/')[0]);
     }
 }
コード例 #2
0
        public static List <Tax> GetAllTaxes()
        {
            var returnModel = new TaxesList();

            if (System.IO.File.Exists(dataPathTax))
            {
                using (var reader = new StreamReader(dataPathTax))
                {
                    XmlSerializer deserializer = new XmlSerializer(typeof(TaxesList), new XmlRootAttribute("Taxes_List"));
                    returnModel = (TaxesList)deserializer.Deserialize(reader);
                }
                currentTaxes = returnModel.Items;
            }
            else
            {
                SaveChanges();
            }
            return(currentTaxes);
        }