예제 #1
0
 /// <summary>
 /// Adds the InstallerConfiguration to the zip package.
 /// </summary>
 /// <param name="config">The InstallerConfiguration instance to add.</param>
 public virtual void AddInstallerConfiguration(InstallerConfiguration config)
 {
     using (StringWriter stringWriter = new StringWriter())
     {
         JsonFileHandler<InstallerConfiguration> handler = new JsonFileHandler<InstallerConfiguration>();
         handler.Write(stringWriter, config);
         _currentZipFile.AddEntry(PackageBuilder.InstallerArchivePath + "script" + InstallerConfiguration.DefaultExtension, stringWriter.ToString());
     }
 }
 public void WriteRepositoryListTest()
 {
     JsonFileHandler<ScriptRepositoryList> handler = new JsonFileHandler<ScriptRepositoryList>();
     IPath path = new BasePath(this.getOutputDirectory() + "repositoryList.json");
     try
     {
         handler.Write(path, this.repoList);
     }
     catch (Exception e)
     {
         Assert.Fail(e.Message);
     }
 }
예제 #3
0
 /// <summary>
 /// Adds the ScriptManifest to the zip package.
 /// Only includes the supplied ScriptVersion in the package manifest versions list.
 /// </summary>
 /// <param name="manifest">The ScriptManifest instance to add.</param>
 /// <param name="version">The ScriptVersion to filter out from the manifest. All other versions will not be included.</param>
 public virtual void AddManifest(ScriptManifest manifest, ScriptVersion version)
 {
     ScriptManifest manifestCopy = manifest.Copy();
     ScriptVersion versionCopy = version.Copy();
     versionCopy.ScriptPath = ScriptManifestTokens.Replace(versionCopy.ScriptPath, manifest, version);
     manifestCopy.Versions = new List<ScriptVersion>() { versionCopy };
     using (StringWriter stringWriter = new StringWriter())
     {
         JsonFileHandler<ScriptManifest> handler = new JsonFileHandler<ScriptManifest>();
         handler.Write(stringWriter, manifestCopy);
         //TODO: change this to work with multiple manifests?
         _currentZipFile.AddEntry(PackageBuilder.InstallerArchivePath + "script" + ScriptManifest.DefaultExtension, stringWriter.ToString());
     }
 }
예제 #4
0
        /// <summary>
        /// Writes a ScriptManifest to a file.
        /// </summary>
        /// <param name="manifest">The ScriptManifest to write.</param>
        /// <param name="filePath">The IPath instance of the file to write to.</param>
        /// <returns>True upon success.</returns>
        /// <remarks>Consider removing from this class.</remarks>
        public Boolean WriteManifest(ScriptManifest manifest, IPath filePath)
        {
            //Copy manifest and replace manifest tokens before writing.
            ScriptManifest manifestCopy = manifest.Copy();
            foreach (ScriptVersion v in manifestCopy.Versions)
            {
                v.ScriptPath = ScriptManifestTokens.Replace(v.ScriptPath, manifestCopy, v);
            }

            //Write manifest.
            filePath.AbsolutePath = ScriptManifestTokens.Replace(filePath.AbsolutePath, manifest, manifest.LatestVersion);
            try
            {
                JsonFileHandler<ScriptManifest> handler = new JsonFileHandler<ScriptManifest>();
                handler.Write(filePath, manifestCopy);
            }
            catch
            {
                return false;
            }

            return true;
        }
예제 #5
0
        public void WriteTest()
        {
            JsonFileHandler<ScriptManifest> handler = new JsonFileHandler<ScriptManifest>();

            //Remove the file if it already exists, so we test that it actually writes a file.
            if (System.IO.File.Exists(outputFile.AbsolutePath))
                System.IO.File.Delete(outputFile.AbsolutePath);

            handler.Write(new BasePath(outputFile.AbsolutePath), this.manifest);

            Assert.IsTrue(System.IO.File.Exists(outputFile.AbsolutePath));
        }
예제 #6
0
        private void button3_Click(object sender, EventArgs e)
        {
            InstallerConfiguration config = new InstallerConfiguration();
            config.AddAction(new CopyDirAction("scripts", AppPaths.Directory.Scripts));
            config.AddAction(new CopyDirAction("startupscripts", AppPaths.Directory.StartupScripts));
            config.AddAction(new AssignHotkeyAction(Keys.H | Keys.Alt, "", ""));

            JsonFileHandler<InstallerConfiguration> handler = new JsonFileHandler<InstallerConfiguration>();
            handler.Write(new BasePath("C:/temp/scriptcenter/config.installer"), config);
        }
예제 #7
0
 void comboBox1_KeyUp(object sender, KeyEventArgs e)
 {
     if ((e.KeyData & Keys.Enter) == Keys.Enter)
     {
         ScriptRepositoryReference rep = new ScriptRepositoryReference();
         //rep.URI = this.comboBox1.Text;
         this.repositoryList.Repositories.Add(rep);
         JsonFileHandler<ScriptRepositoryList> h = new JsonFileHandler<ScriptRepositoryList>();
         h.Write(this.repositoryListFile, this.repositoryList);
         this.LoadRepository(new BasePath(rep.URI));
     }
 }
예제 #8
0
        public void WriteTest()
        {
            IPath outputFile = new BasePath(TestHelperMethods.GetOutputDirectory() + "repo" + ScriptRepository.DefaultExtension);
            if (File.Exists(outputFile.AbsolutePath))
                File.Delete(outputFile.AbsolutePath);

            JsonFileHandler<ScriptRepository> handler = new JsonFileHandler<ScriptRepository>();
            handler.Write(outputFile, repo);

            Assert.IsTrue(File.Exists(outputFile.AbsolutePath));
        }
 public void WriteTest()
 {
     JsonFileHandler<InstallerConfiguration> handler = new JsonFileHandler<InstallerConfiguration>();
     IPath path = new BasePath(TestHelperMethods.GetOutputDirectory() + "/myscript" + InstallerConfiguration.DefaultExtension);
     try
     {
         handler.Write(path, this.config);
     }
     catch (Exception e)
     {
         Assert.Fail(e.Message);
     }
 }
예제 #10
0
 private void writeRepository(IPath path, ScriptRepository repository)
 {
     JsonFileHandler<ScriptRepository> handler = new JsonFileHandler<ScriptRepository>();
     try
     {
     handler.Write(path, repository);
     }
     catch (Exception exc)
     {
     MessageBox.Show(exc.Message);
     }
 }
예제 #11
0
 private void writePackage(IPath path, ScriptPackage package)
 {
     JsonFileHandler<ScriptPackage> handler = new JsonFileHandler<ScriptPackage>();
     try
     {
     handler.Write(path, package);
     }
     catch (Exception exc)
     {
     MessageBox.Show(exc.Message);
     }
 }
예제 #12
0
 private void writeManifest(IPath path, ScriptManifest manifest)
 {
     JsonFileHandler<ScriptManifest> handler = new JsonFileHandler<ScriptManifest>();
     try
     {
     handler.Write(path, manifest);
     }
     catch (Exception exc)
     {
     MessageBox.Show(exc.Message);
     }
 }