Exemple #1
0
        /// <summary>
        /// Imports the categories from a <see cref="TaskCollection"/> in a file
        /// </summary>
        /// <returns>The affected categories</returns>
        /// <param name="coll">The collection where to import to</param>
        /// <param name="fileName">File name containing the JSON of the importing <see cref="TaskCollection"/></param>
        /// <param name="opts">Import options</param>
        public static Category[] ImportCategory(this TaskCollection coll,
                                                string fileName,
                                                CategoryImportOptions opts)
        {
            var otherColl = TaskCollection.Load(fileName);

            return(ImportCategory(coll, otherColl, opts));
        }
Exemple #2
0
        /// <summary>
        /// Imports the categories from a file
        /// </summary>
        /// <returns>Collection of imported <see cref="Category"/></returns>
        /// <param name="coll">The collection where to import the categories</param>
        /// <param name="importingCollection">The collection to import</param>
        /// <param name="opts">Options</param>
        public static Category[] ImportCategory(this TaskCollection coll,
                                                TaskCollection importingCollection,
                                                CategoryImportOptions opts)
        {
            var importCats = new HashSet <Category> (importingCollection.EnumerateCategories());
            var ret        = new List <Category> ();

            foreach (var cat in importCats)
            {
                ret.Add(mergeCat(coll, cat, opts));
            }

            return(ret.ToArray());
        }
Exemple #3
0
 static Category mergeCat(TaskCollection coll, Category importCat, CategoryImportOptions opts)
 {
     if (opts.MergeSameName)
     {
         try
         {
             return(coll.EnumerateCategories().First(
                        z => string.Equals(z.Name, importCat.Name, StringComparison.CurrentCultureIgnoreCase)));
         }
         catch (Exception)
         {
             return(importCat.clone(coll));
         }
     }
     return(importCat.clone(coll));
 }