public void File(string applicationPath, string filePath)
 {
     if (settings.IsStatisticsCounted)
     {
         appender.File(applicationPath, filePath);
     }
 }
        public void Run(IApplication application, IFile file)
        {
            if (file == null)
            {
                countingAppender.Application(application.Path);
                Process.Start(application.Path);
            }
            else
            {
                string arguments = file.Path;
                if (!String.IsNullOrEmpty(application.Arguments))
                {
                    TokenWriter writer = new TokenWriter(application.Arguments);
                    arguments = writer.Format(new KeyValueCollection()
                                              .Add("FilePath", file.Path)
                                              .Add("DirectoryPath", System.IO.Path.GetDirectoryName(file.Path))
                                              );

                    countingAppender.File(application.Path, application.Arguments, file.Path);
                }
                else
                {
                    countingAppender.File(application.Path, file.Path);
                }

                Process.Start(new ProcessStartInfo(application.Path, arguments));
                EventManager.RaiseProcessStarted(application, file);
            }
        }
        public void Run(IApplication application, IFile file, bool isAdministratorRequired = false)
        {
            string arguments = null;

            if (file == null)
            {
                if (!String.IsNullOrEmpty(application.EmptyArguments))
                {
                    arguments = application.EmptyArguments;
                    countingAppender.Application(application.Path, arguments);
                }
                else
                {
                    countingAppender.Application(application.Path);
                }
            }
            else
            {
                if (!String.IsNullOrEmpty(application.FileArguments))
                {
                    TokenWriter writer = new TokenWriter(application.FileArguments);
                    arguments = writer.Format(new KeyValueCollection()
                                              .Add("FilePath", file.Path)
                                              .Add("DirectoryPath", Path.GetDirectoryName(file.Path))
                                              );

                    countingAppender.File(application.Path, application.FileArguments, file.Path);
                }
                else
                {
                    arguments = file.Path;
                    countingAppender.File(application.Path, file.Path);
                }
            }

            ProcessStartInfo info = arguments == null ? new ProcessStartInfo(application.Path) : new ProcessStartInfo(application.Path, arguments);

            if (isAdministratorRequired || application.IsAdministratorRequired)
            {
                info.Verb = "runas";
            }

            try
            {
                Process.Start(info);
                EventManager.RaiseProcessStarted(application, file);
            }
            catch (Win32Exception e)
            {
                // "The operation was canceled by the user".
                if (e.NativeErrorCode != 1223)
                {
                    throw;
                }
            }
        }