예제 #1
0
파일: ActionsEx.cs 프로젝트: sidiandi/hagen
        public static IEnumerable <Action> GetSpecialFolderActions()
        {
            FileActionFactory f = new FileActionFactory();

            return(Enum.GetValues(typeof(Environment.SpecialFolder)).Cast <Environment.SpecialFolder>()
                   .SafeSelect(i =>
            {
                var a = f.FromFile(Environment.GetFolderPath((Environment.SpecialFolder)i));
                a.Name = i.ToString();
                return a;
            }));
        }
예제 #2
0
파일: ActionsEx.cs 프로젝트: sidiandi/hagen
        public static IEnumerable <Action> GetPathExecutables()
        {
            FileActionFactory f = new FileActionFactory();
            var exeExtensions   = new FileType("exe", "bat", "cmd", "msc", "cpl");

            var path = Regex.Split(System.Environment.GetEnvironmentVariable("PATH"), @"\;")
                       .SafeSelect(x => LPath.Parse(x)).ToList();

            log.InfoFormat("Searching {0}", path);

            return(path.SelectMany(p =>
            {
                return p.GetFiles().Where(x => exeExtensions.Is(x))
                .SafeSelect(x => f.FromFile(x));
            }));
        }
예제 #3
0
파일: ActionsEx.cs 프로젝트: sidiandi/hagen
        public static IEnumerable <Action> GetStartMenuActions()
        {
            var factory = new FileActionFactory();

            return
                (new[]
            {
                Find.AllFiles(new LPath(AllUsersStartMenu)),
                Find.AllFiles(Sidi.IO.Paths.GetFolderPath(Environment.SpecialFolder.StartMenu)),
                Find.AllFiles(Sidi.IO.Paths.GetFolderPath(Environment.SpecialFolder.MyDocuments).CatDir("My RoboForm Data"))
                .Where(_ => !_.FullName.Parts.Contains("obsolete"))
            }
                 .SelectMany(_ => _)
                 .Where(x => x.Exists)
                 .Select(_ => factory.FromFile(_)));
        }
예제 #4
0
파일: Plugin.cs 프로젝트: sidiandi/hagen
 public void Add(PathList paths, string tagsPrefix)
 {
     using (var actions = OpenActions())
     {
         FileActionFactory f = new FileActionFactory();
         foreach (var i in paths
                  .Where(p => p.Exists && !p.Info.IsHidden))
         {
             try
             {
                 log.Info(i);
                 var action = f.FromFile(i);
                 action.Name = tagsPrefix + action.Name;
                 actions.AddOrUpdate(action);
             }
             catch (Exception ex)
             {
                 log.Warn(ex);
             }
         }
     }
 }