Example #1
0
        /// <summary>
        /// Obtains a license from Isolated Storage if exist.
        /// </summary>
        /// <param name="licFile">The string name of the license file.</param>
        /// <param name="key">The encryption key to verify the license.</param>
        /// <param name="licenses">The licenses collection to add new license if exist.</param>
        private void AddLicenseFromIsolatedStorage(string licFile, RSACryptoServiceProvider key, List <License> licenses)
        {
            LicenseFile license = null;

            using (var reader = IsolatedStorageAccess.CreateIsolatedStorageLicenseStream(FileMode.Open))
                license = LicenseFile.LoadFile(reader, key);
            if (license != null)
            {
                licenses.Add(license);
            }
        }
Example #2
0
 /// <summary>
 /// This saves the license in the proper location.
 /// </summary>
 /// <param name="licenseFile">The license file to save.</param>
 /// <param name="key">The encryption key to verify the license.</param>
 /// <param name="useIsolatedStorage">Save to IsolatedStorage if true if saving in the application data path causes an exception.</param>
 /// <param name="appDataFilePath">The application data file path.</param>
 private void Save
     (LicenseFile licenseFile, RSACryptoServiceProvider key, bool useIsolatedStorage, string appDataFilePath)
 {
     Debug.WriteLine("OpenLicenseProvider: Save Function");
     try
     {
         using (Stream fileStream = FileNames.CreateLicenseFileStream(FileMode.Create, FileAccess.Write, FileShare.Write))
             licenseFile.SaveFile(fileStream, key);
     }
     catch (Exception ex)
     {
         if (!useIsolatedStorage)
         {
             throw new LicenseFileException(Resources.ErrStr_SaveLicense_UnableToSaveLicense + ex.Message);
         }
     }
     if (useIsolatedStorage)
     {
         using (Stream writer = IsolatedStorageAccess.CreateIsolatedStorageLicenseStream(FileMode.Create))
             licenseFile.SaveFile(writer, key);
     }
 }