예제 #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);
     }
 }
예제 #2
0
파일: PathIndex.cs 프로젝트: rjshaver/core
        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;
            }
        }
예제 #3
0
 public NativeExecutableCommand(NativeExecutable executable)
 {
     Executable     = executable;
     ExecutableName = executable.FileName;
 }