From d0757ed5441426bed0d3ccd22c25052f34d9395d Mon Sep 17 00:00:00 2001 From: Chris Coulson Date: Fri, 22 Jan 2016 14:43:33 -0500 Subject: [PATCH] Added Product field to license - so that the licensee can see the name of the product they have the license for. --- .../LicenseValidationTests.cs | 2 +- src/Portable.Licensing/ILicenseBuilder.cs | 9 ++++++++- src/Portable.Licensing/License.cs | 11 ++++++++++- src/Portable.Licensing/LicenseBuilder.cs | 12 ++++++++++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/Portable.Licensing.Tests/LicenseValidationTests.cs b/src/Portable.Licensing.Tests/LicenseValidationTests.cs index 4acaddd..1218e55 100644 --- a/src/Portable.Licensing.Tests/LicenseValidationTests.cs +++ b/src/Portable.Licensing.Tests/LicenseValidationTests.cs @@ -100,7 +100,7 @@ public void Can_Validate_Invalid_Signature() [Test] public void Can_Validate_Expired_ExpirationDate() { - var publicKey = ""; + //var publicKey = ""; var licenseData = @" 77d4c193-6088-4c64-9663-ed7398ae8c1a Trial diff --git a/src/Portable.Licensing/ILicenseBuilder.cs b/src/Portable.Licensing/ILicenseBuilder.cs index c5227f5..fab12cb 100644 --- a/src/Portable.Licensing/ILicenseBuilder.cs +++ b/src/Portable.Licensing/ILicenseBuilder.cs @@ -32,7 +32,14 @@ namespace Portable.Licensing /// Fluent api to create and sign a new . /// public interface ILicenseBuilder : IFluentInterface - { + { + /// + /// Sets the product name of the . + /// + /// The product name of the . + /// The . + ILicenseBuilder WithProduct(string product); + /// /// Sets the unique identifier of the . /// diff --git a/src/Portable.Licensing/License.cs b/src/Portable.Licensing/License.cs index 9da4dda..c32ac6b 100644 --- a/src/Portable.Licensing/License.cs +++ b/src/Portable.Licensing/License.cs @@ -69,6 +69,15 @@ public Guid Id { get { return new Guid(GetTag("Id") ?? Guid.Empty.ToString()); } set { if (!IsSigned) SetTag("Id", value.ToString()); } + } + + /// + /// Gets or sets the product name this applies to. + /// + public String Product + { + get { return GetTag("Product") ?? ""; } + set { if (!IsSigned) SetTag("Product", value); } } /// @@ -167,7 +176,7 @@ public LicenseAttributes AdditionalAttributes /// /// Gets or sets the expiration date of this . /// Use this property to set the expiration date for a trial license - /// or the expiration of support & subscription updates for a standard license. + /// or the expiration of support and subscription updates for a standard license. /// public DateTime Expiration { diff --git a/src/Portable.Licensing/LicenseBuilder.cs b/src/Portable.Licensing/LicenseBuilder.cs index 2919a40..5a59957 100644 --- a/src/Portable.Licensing/LicenseBuilder.cs +++ b/src/Portable.Licensing/LicenseBuilder.cs @@ -42,6 +42,18 @@ internal class LicenseBuilder : ILicenseBuilder public LicenseBuilder() { license = new License(); + } + + + /// + /// Sets the product name of the . + /// + /// The product name of the . + /// The . + public ILicenseBuilder WithProduct(string product) + { + license.Product = product; + return this; } ///