Beispiel #1
0
 static void TagFile(string path)
 {
     try
     {
         bool ro = tag_changes.Count == 0;
         using (IHaTagger ht = TaggerFactory.CreateTagger(path))
         {
             if (ro)
             {
                 // Display file tags
                 Console.WriteLine(path + ": " + Utils.SafeAggregate(ht.Tags).ToUpper());
             }
             else
             {
                 // Apply tag changes
                 foreach (HaSyntax.HaSyntaxElement element in tag_changes)
                 {
                     if (element.Flag)
                     {
                         ht.AddTag(element.Element);
                     }
                     else
                     {
                         ht.RemoveTag(element.Element);
                     }
                 }
                 ht.Save();
             }
         }
     }
     catch (HaException)
     {
         Console.WriteLine(string.Format("FAILED ({0})", path));
     }
 }
        private void applyTagsToList(List <HaSyntax.HaSyntaxElement> tags, IEnumerable <LoadedFile> list)
        {
            // Set tags
            foreach (LoadedFile file in list)
            {
                using (IHaTagger ht = TaggerFactory.CreateTagger(file.Filename, true))
                {
                    foreach (HaSyntax.HaSyntaxElement tag in tags)
                    {
                        if (tag.Flag)
                        {
                            ht.AddTag(tag.Element);
                        }
                        else
                        {
                            ht.RemoveTag(tag.Element);
                        }
                    }
                    ht.Save();
                }
            }

            // Reload views
            foreach (LoadedFile file in list)
            {
                file.Reload();
            }
        }