Skip to content

Commit

Permalink
Merge branch 'release-4.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasohlund committed Apr 14, 2014
2 parents 914a8a2 + 6aad544 commit 010d1f1
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions src/NServiceBus.Core/Licensing/LicenseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace NServiceBus.Licensing
using System.Threading;
using System.Windows.Forms;
using Logging;
using Microsoft.Win32;
using Particular.Licensing;

[ObsoleteEx(Message = "Not a public API.", TreatAsErrorFromVersion = "4.5", RemoveInVersion = "5.0")]
Expand Down Expand Up @@ -78,20 +79,16 @@ internal static void InitializeLicense()
//only do this if not been configured by the fluent API
if (licenseText == null)
{
//look in the new platform locations
if (!(new RegistryLicenseStore().TryReadLicense(out licenseText)))
{
//legacy locations
licenseText = LicenseLocationConventions.TryFindLicenseText();
licenseText = GetExistingLicense();
}

if (string.IsNullOrWhiteSpace(licenseText))
{
license = GetTrialLicense();
return;
}
}
if (string.IsNullOrWhiteSpace(licenseText))
{
license = GetTrialLicense();
return;
}


LicenseVerifier.Verify(licenseText);

var foundLicense = LicenseDeserializer.Deserialize(licenseText);
Expand All @@ -114,6 +111,26 @@ internal static void InitializeLicense()
license = foundLicense;
}

static string GetExistingLicense()
{
string existingLicense;

//look in HKCU
if (new RegistryLicenseStore().TryReadLicense(out existingLicense))
{
return existingLicense;
}

//look in HKLM
if (new RegistryLicenseStore(Registry.LocalMachine).TryReadLicense(out existingLicense))
{
return existingLicense;
}


return LicenseLocationConventions.TryFindLicenseText();
}

static ILog Logger = LogManager.GetLogger(typeof(LicenseManager));
static string licenseText;
static Particular.Licensing.License license;
Expand Down

0 comments on commit 010d1f1

Please sign in to comment.