Ejemplo n.º 1
0
        /// <summary>
        /// Adds a working year to serialized data
        /// </summary>
        /// <param name="item">Item to add</param>
        /// <param name="fileFormat"> <see cref="OwlSerializer.FileFormats"/> of the item</param>
        /// <returns>Id of item</returns>
        public int AddWorkingYear(IWorkingYear item, OwlSerializer.FileFormats fileFormat)
        {
            if (!yearsCollection.ContainsKey(item.YearCount))
            {
                WorkingYear year = new WorkingYear(item);
                switch (fileFormat)
                {
                    case OwlSerializer.FileFormats.Cfg:
                    case OwlSerializer.FileFormats.Xml:
                        OwlSerializer.Save(year, typeof(WorkingYear), yearFolder + year.YearCount,
                    OwlSerializer.FileFormats.Xml);
                        break;
                    case OwlSerializer.FileFormats.Json:
                        OwlSerializer.Save(year, typeof(WorkingYear), yearFolder + year.YearCount,
                    OwlSerializer.FileFormats.Json);
                        break;

                }
                yearsCollection.Add(year.YearCount,year);
                return year.YearCount;
            }
            return -1;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Updates the given item
 /// </summary>
 /// <param name="item">Item to update</param>
 /// <param name="fileFormat"> <see cref="OwlSerializer.FileFormats"/> of the item</param>
 public bool UpdateWorkingYear(IWorkingYear item, OwlSerializer.FileFormats fileFormat)
 {
     WorkingYear year = new WorkingYear(item);
     if (yearsCollection.ContainsKey(year.YearCount))
     {
         yearsCollection[year.YearCount] = year;
         switch (fileFormat)
         {
             case OwlSerializer.FileFormats.Cfg:
             case OwlSerializer.FileFormats.Xml:
                 OwlSerializer.Save(year, typeof(WorkingYear), yearFolder + year.YearCount,
             OwlSerializer.FileFormats.Xml);
                 break;
             case OwlSerializer.FileFormats.Json:
                 OwlSerializer.Save(year, typeof(WorkingYear), yearFolder + year.YearCount,
             OwlSerializer.FileFormats.Json);
                 break;
         }
         return true;
     }
     return false;
 }