コード例 #1
0
 /// <summary>
 /// Removes an installation.
 /// </summary>
 /// <param name="savedState">
 /// An IDictionary used to save information needed to perform a commit, rollback, or uninstall operation.
 /// </param>
 public override void Uninstall(System.Collections.IDictionary savedState)
 {
     LicenseFile.Uninstall();
     FileNames.DeleteKeys();
     ManifestManagement.DeleteDeployManifest();
     base.Uninstall(savedState);
 }
コード例 #2
0
 /// <summary>
 /// When overridden in a derived class, restores the pre-installation state of the computer.
 /// </summary>
 /// <param name="savedState">An <see cref="T:System.Collections.IDictionary"/> that contains the pre-installation state of the computer.</param>
 /// <exception cref="T:System.ArgumentException">
 /// The <paramref name="savedState"/> parameter is null.
 /// -or-
 /// The saved-state <see cref="T:System.Collections.IDictionary"/> might have been corrupted.
 /// </exception>
 /// <exception cref="T:System.Configuration.Install.InstallException">
 /// An exception occurred during the <see cref="M:System.Configuration.Install.Installer.Rollback(System.Collections.IDictionary)"/> phase
 /// of the installation. This exception is ignored and the rollback continues.
 /// However, the computer might not be fully reverted to its initial state after the rollback completes.
 /// </exception>
 public override void Rollback(IDictionary savedState)
 {
     LicenseFile.Uninstall();
     FileNames.DeleteKeys();
     ManifestManagement.DeleteDeployManifest();
     base.Rollback(savedState);
 }
コード例 #3
0
 internal static void InstallLicense(string user, string company, string email, bool loadLicenseFromDefaultContainer, string alternativeProductName, string licenseUnlockCode, Assembly assembly)
 {
     if (assembly == null)
     {
         throw new ArgumentNullException(nameof(assembly), $"Entring {nameof(InstallLicense)} with null argument.");
     }
     LicenseTraceSource.TraceVerbose(39, $"Entering InstallLicense {user}, {company}, {email}");
     ManifestManagement.WriteDeployManifest(assembly, alternativeProductName);
     LicenseFile.Install(user, company, email, FileNames.LicenseFilePath, loadLicenseFromDefaultContainer, licenseUnlockCode);
 }
コード例 #4
0
        /// <summary>
        /// It completes the install transaction.
        /// </summary>
        /// <param name="savedState">An <see cref="T:System.Collections.IDictionary"/> that contains the state
        /// of the computer after all the installers in the collection have run.
        /// </param>
        /// <exception cref="T:System.ArgumentException">
        /// The <paramref name="savedState"/> parameter is null.
        /// -or-
        /// The saved-state <see cref="T:System.Collections.IDictionary"/> might have been corrupted.
        /// </exception>
        /// <exception cref="T:System.Configuration.Install.InstallException">
        /// An exception occurred during the <see cref="M:System.Configuration.Install.Installer.Commit(System.Collections.IDictionary)"/> phase
        /// of the installation. This exception is ignored and the installation continues.
        /// However, the application might not function correctly after the installation is complete.
        /// </exception>
        public override void Commit(IDictionary savedState)
        {
            base.Commit(savedState);
            InstallContext _Context = this.Context;

            try
            {
                ManifestManagement.WriteDeployManifest(_Context);
                LicenseFile.Install(_Context.Parameters[InstallContextNames.User], _Context.Parameters[InstallContextNames.Company], _Context.Parameters[InstallContextNames.Email], FileNames.LicenseFilePath, true, null);
            }
            catch (Exception ex)
            {
                throw new InstallException("Installation Error", ex);
            }
        }
コード例 #5
0
 public void InstallLicenseFromContainerAllParametersTest()
 {
     try
     {
         LibInstaller.InstallLicense("user", "company", "email", true, "", "", Assembly.GetExecutingAssembly());
         Assert.Fail();
     }
     catch (Exception ex)
     {
         DeployManifest _manifest = FileNames.ProductManifest();
         Assert.IsNotNull(_manifest);
         Assert.AreEqual <string>("CAS.CodeProtect.UnitTests", _manifest.Product);
         Assert.IsFalse(ex.Message.Contains("CAS.CodeProtect.UnitTests"));
         Assert.IsTrue(ex.Message.Contains("CodeProtect.UnitTests"));
         ManifestManagement.DeleteDeployManifest();
     }
 }
コード例 #6
0
 public void InstallLicenseFromContainerDefaultParametersTest()
 {
     try
     {
         LibInstaller.InstallLicense(true);
         Assert.Fail();
     }
     catch (Exception ex)
     {
         DeployManifest _manifest = FileNames.ProductManifest();
         Assert.IsNotNull(_manifest);
         Assert.AreEqual <string>("CAS.CodeProtect.UnitTests", _manifest.Product);
         Assert.IsFalse(ex.Message.Contains("CAS.CodeProtect.UnitTests"));
         Assert.IsTrue(ex.Message.Contains("CodeProtect.UnitTests"));
         ManifestManagement.DeleteDeployManifest();
     }
 }
コード例 #7
0
        public void ManifestFromAssemblyManagementWriteReadTestMethod()
        {
            FileInfo _fi = new FileInfo(FileNames.ManifestFileName);

            Assert.IsFalse(_fi.Exists);
            Assembly _thisAssembly = Assembly.GetExecutingAssembly();

            ManifestManagement.WriteDeployManifest(_thisAssembly, CommonDefinitions.AssemblyProduct);
            _fi.Refresh();
            Assert.IsTrue(_fi.Exists);
            DeployManifest _manifest = ManifestManagement.ReadDeployManifest();

            ManifestManagement.DeleteDeployManifest();
            _fi.Refresh();
            Assert.IsFalse(_fi.Exists);
            //test the content
            Assert.IsNotNull(_manifest);
            Assert.IsTrue(_manifest.Install);
            Assert.AreEqual <string>("CodeProtectTests", _manifest.Product);
            Assert.AreEqual <string>("CAS", _manifest.Publisher); //Only in test environment
            Assert.AreEqual <string>("http://www.commsvr.eu/", _manifest.SupportUrl);
            Assert.AreEqual <string>("http://www.commsvr.eu/", _manifest.DeploymentUrl);
            AssemblyIdentity _id = _manifest.AssemblyIdentity;

            Assert.IsNotNull(_id);
            AssemblyName _thisName = _thisAssembly.GetName();

            Assert.AreEqual <string>(_thisName.Version.ToString(), _id.Version);
            //FileReferences
            Assert.IsNotNull(_manifest.FileReferences);
            Assert.AreEqual <int>(1, _manifest.FileReferences.Count);
            FileReference _FileReference = _manifest.FileReferences[0];

            Assert.AreEqual <string>(FileNames.TargetDir, _FileReference.TargetPath);
            Assert.AreEqual <string>("license", _FileReference.Group);
            Assert.IsFalse(_FileReference.IsOptional);
            Assert.IsTrue(_FileReference.IsDataFile);
        }
コード例 #8
0
 /// <summary>
 /// Reads the deploy manifest.
 /// </summary>
 /// <param name="ManifestFileName">Name of the manifest file.</param>
 /// <returns>The DeployManifest readed from XML File</returns>
 public static DeployManifest ReadDeployManifest(string ManifestFileName)
 {
     return(ManifestManagement.ReadDeployManifest(ManifestFileName));
 }