Exemplo n.º 1
0
 public override ICommand GetCommand(string commandName)
 {
     try {
         NativeExecutable exe = PathIndex.GetCommand(commandName)
                                ?? (FileHelper.Instance.IsFile(commandName) ? new NativeExecutable(commandName) : null);
         return(exe != null ? new NativeExecutableCommand(executable: exe) : null);
     } catch (Exception ex) {
         Log.Warning(ex);
         return(null);
     }
 }
Exemplo n.º 2
0
        void IndexExecutables()
        {
            if (!IsIndexed)
            {
                lock (lockIndex) {
                    Log.Debug("IndexExecutables:");
                    Log.Indent++;
                    foreach (string directory in PathDirectories)
                    {
                        Log.Debug("PathDirectory: ", directory);
                        Log.Indent++;
                        try {
                            IEnumerable <string> files = SafeDirectoryEnumerator.EnumerateFiles(directory, "*", System.IO.SearchOption.TopDirectoryOnly);
                            foreach (string fullPath in files)
                            {
                                if (ExecutablePathValidator.IsValidExecutable(fullPath: fullPath))
                                {
                                    NativeExecutable executable = new NativeExecutable(fullPath: fullPath);
                                    Log.Debug("executable: ", executable);
                                    foreach (string commandName in executable.CommandNames)
                                    {
                                        if (!PathExecutables.ContainsKey(commandName))
                                        {
                                            PathExecutables [commandName] = executable;
                                        }
                                    }
                                }
                            }
                        } catch (Exception ex) {
                            Log.Error(ex);
                        }
                        Log.Indent--;
                    }
                    Log.Indent--;
                }

                IsIndexed = true;
            }
        }
Exemplo n.º 3
0
 public NativeExecutableCommand(NativeExecutable executable)
 {
     Executable     = executable;
     ExecutableName = executable.FileName;
 }