public void ApplicationDataCreateInitial()
 {
   applicationData = new ApplicationData();
   applicationData.Files.RegistryDatabase = new ApplicationFile("myTestDir\\testRegDatabase.db3");
   applicationData.Files.RootDirectory = new ApplicationFile("myTestDir\\");
   applicationData.Files.Executable = new ApplicationFile("myTestDir\\DoesntExist.exe");
 }
 public void LoadApplicationData(ApplicationData data)
 {
   _data = data;
   UpdateGlobalGUI();
   foreach (Control tabPage in _tabMain.TabPages)
     foreach (IApplicationConfigurationPage page in tabPage.Controls)
       page.BindDataSource(data);
 }
 public void BindDataSource(ApplicationData dataSource)
 {
   if (dataSource == null)
     throw new ArgumentNullException("dataSource");
   _data = dataSource;
   if (_data.Settings.FileSystemEngineRuleCollection == null)
     _data.Settings.FileSystemEngineRuleCollection = FileSystemRuleCollection.GetDefaultRuleCollection();
   if (_data.Settings.RegistryEngineRuleCollection == null)
     _data.Settings.RegistryEngineRuleCollection = RegistryRuleCollection.GetDefaultRuleCollection();
   _fileSystemEngineSettingsPageContent.BindRuleCollection(_data.Settings.FileSystemEngineRuleCollection, FileSystemRuleCollectionUpdateEventHandler);
   _registryEngineSettingsPageContent.BindRuleCollection(_data.Settings.RegistryEngineRuleCollection, RegistryRuleCollectionUpdateEventHandler);
   Enabled = true;
 }
 public void BindDataSource(ApplicationData dataSource)
 {
   if (dataSource == null)
     throw new ArgumentNullException("dataSource");
   _data = dataSource;
   if (_data.Files.Executable == null)
     _data.Files.Executable = new ApplicationFile();
   if (_data.Files.RootDirectory == null)
     _data.Files.RootDirectory = new ApplicationFile();
   if (_data.Files.RegistryDatabase == null)
     _data.Files.RegistryDatabase = new ApplicationFile();
   _dataSourceLocked = true;
   _txtExecutable.Text = _data.Files.Executable.FileName;
   _txtFileSystemRootDirectory.Text = _data.Files.RootDirectory.FileName;
   _txtRegistryDatabase.Text = _data.Files.RegistryDatabase.FileName;
   _dataSourceLocked = false;
   Enabled = true;
 }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of <see cref="Packager"/>.
 /// </summary>
 /// <param name="applicationData">The data to base the packaging process on.</param>
 /// <param name="outputFolder">The location where the application must be packaged to.</param>
 public Packager(ApplicationData applicationData, string outputFolder)
 {
   var workingDirectory = new ApplicationFile(outputFolder);
   if (workingDirectory.Type != FileType.Directory)
     throw new ArgumentException("The value specified for the outputFolder is invalid.", "outputFolder");
   _startInfo = new VirtualProcessStartInfo(applicationData, workingDirectory);
   _waitHandle = new AutoResetEvent(false);
 }
Esempio n. 6
0
 /// <summary>
 /// Returns a default instance of <see cref="ApplicationData"/> for the packaging of <see cref="executable"/>.
 /// </summary>
 /// <exception cref="ArgumentNullException"></exception>
 /// <exception cref="ArgumentException">
 /// An <see cref="ArgumentException"/> is thrown if the value specified for <paramref name="executable"/> is invalid.
 /// </exception>
 /// <param name="executable"></param>
 /// <returns></returns>
 public static ApplicationData GetDefaultApplicationData(string executable)
 {
   if (string.IsNullOrEmpty(executable))
     throw new ArgumentNullException("executable");
   ApplicationData data = new ApplicationData();
   data.Settings.RegistryEngineRuleCollection = RegistryRuleCollection.GetDefaultRuleCollection();
   data.Files.RootDirectory = new ApplicationFile(".");
   data.Files.Executable = new ApplicationFile(executable);
   if (data.Files.Executable.Type != FileType.Executable)
     throw new ArgumentException("The value specified for the executable is invalid.", "executable");
   data.Files.RegistryDatabase = new ApplicationFile(_dbRegistry);
   return data;
 }
 /// <summary>
 /// Saves an instance of <see cref="ApplicationData"/> to the specified <paramref name="filename"/>.
 /// </summary>
 /// <param name="applicationData">The data to save.</param>
 /// <param name="filename">File containing the data to deserialize.</param>
 /// <returns>True if the data is successfully save; otherwise, false.</returns>
 public static bool Save(ApplicationData applicationData, string filename)
 {
   try
   {
     SerializationHelper.Serialize(filename, applicationData, _SerializerType);
     return true;
   }
   catch (Exception e)
   {
     HostCore.Log.Warning("Failed to save instance of ApplicationData to " + filename, e);
     return false;
   }
 }
 /// <summary>
 /// Initializes a new instance of <see cref="VirtualProcessStartInfo"/>
 ///  based on the <see cref="ApplicationData"/> specified.
 /// </summary>
 /// <exception cref="ArgumentNullException">
 /// An <see cref="ArgumentNullException"/> is thrown if <paramref name="data"/> of one of its properties is null.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// An <see cref="ArgumentException"/> is thrown if any of the properties of <paramref name="data"/> is of the wrong type.
 /// </exception>
 /// <param name="data">The data to base the process on.</param>
 /// <param name="workingDirectory">The working directory of the process to start.</param>
 public VirtualProcessStartInfo(ApplicationData data, ApplicationFile workingDirectory)
 {
   if (data == null
       || data.Files.RegistryDatabase == null
       || data.Files.Executable == null
       || data.Files.RootDirectory == null)
     throw new ArgumentNullException("data", "The data argument or one of its properties is null.");
   if (workingDirectory == null)
     throw new ArgumentNullException("workingDirectory", "The workingDirectory argument is null.");
   if (data.Files.Executable.Type != FileType.Executable)
     throw new ArgumentException("The ApplicationData specified contains an illegal value for the main executable.",
                                 "data");
   if (data.Files.RegistryDatabase.Type != FileType.Database)
     throw new ArgumentException(
       "The ApplicationData specified contains an illegal value for the registry database.",
       "data");
   if (workingDirectory.Type != FileType.Directory)
     throw new ArgumentException("The working directory specified is not a directory.",
                                 "workingDirectory");
   _files = new ApplicationFiles
              {
                RegistryDatabase
                  = new ApplicationFile(Path.Combine(workingDirectory.FileName, data.Files.RegistryDatabase.FileName)),
                Executable
                  = new ApplicationFile(Path.Combine(workingDirectory.FileName, data.Files.Executable.FileName)),
                RootDirectory
                  = new ApplicationFile(Path.Combine(workingDirectory.FileName, data.Files.RootDirectory.FileName))
              };
   _arguments = "";
   _workingDirectory = workingDirectory;
   _fileSystemRuleCollection = data.Settings.FileSystemEngineRuleCollection ?? FileSystemRuleCollection.GetDefaultRuleCollection();
   _registryRuleCollection = data.Settings.RegistryEngineRuleCollection ?? RegistryRuleCollection.GetDefaultRuleCollection();
 }
 private static bool PrepareApplicationData(PreConfigurationState preConfigurationState, out ApplicationData applicationData)
 {
   try
   {
     applicationData = Packager.GetDefaultApplicationData(preConfigurationState.InstallerExecutable);
   }
   catch (ArgumentException)
   {
     applicationData = null;
     return false;
   }
   if (preConfigurationState.ShowEngineConfigurationUtility)
   {
     var utility = new ApplicationConfigurationUtility(true);
     utility.LoadApplicationData(applicationData);
     utility.ShowDialog();
   }
   return true;
 }
 private static bool RunPackagingSequence(PreConfigurationState preConfigurationState, ApplicationData applicationData, out PackagedApplication packagedApplication)
 {
   try
   {
     var packager = new Packager(applicationData, preConfigurationState.InstallerOutputDestination);
     packagedApplication = packager.CreatePackage();
     return true;
   }
   catch (Exception ex)
   {
     HostCore.Log.Error("Packaging failed", ex);
     MessageReporter.Show(FormatMessageFor(ex) + "\r\nCheck the log files or the extended information for troubleshooting.",
                          "Packaging failed!", ex, MessageBoxButtons.OK, MessageBoxIcon.Error);
     // ToDo: Clean up first!
     packagedApplication = null;
     return false;
   }
 }