Exemplo n.º 1
0
        private InstalledFile CreateAndAddFileDescription(InstalledApplication app, Environment.SpecialFolder folder, string fileName, long fileSize)
        {
            var existing =
                app.Files.FirstOrDefault(
                    x => string.Equals(fileName, x.Filename, StringComparison.InvariantCultureIgnoreCase) && x.Folder == folder);
            long id;

            if (existing != null)
            {
                app.Files.Remove(existing);
                id = existing.Id;
            }
            else
            {
                id = Interlocked.Increment(ref _nextFileId);
            }

            var file = new InstalledFile
            {
                Id         = id,
                FileLength = fileSize,
                Filename   = fileName,
                Folder     = folder
            };

            app.Files.Add(file);
            return(file);
        }
Exemplo n.º 2
0
        private Process StartNewProcress(string instanceName)
        {
            lock (_syncRoot)
            {
                ApplicationInstanceDescription instance = _registeredApplicationInstances[instanceName];
                InstalledFile        executable         = instance.Executable;
                InstalledApplication application        = _installedApplications[instance.ApplicationName];

                var process = new Process
                {
                    StartInfo = new ProcessStartInfo
                    {
                        FileName = Resolve(application, executable.Folder, executable.Filename),
                    },
                    EnableRaisingEvents = true
                };

                return(process);
            }
        }