TrialRestriction

Namespace: Babel.Licensing Assembly: Babel.Licensing.dll

Represents a typically used to define trial licenses. The trial restriction can limit the number of days the license can be used, the number of application instances that can run simultaneously, the total number of executions and the running time.

public class TrialRestriction : Restriction, IObservableObject

Inheritance

objectRestrictionTrialRestriction

Implements

IObservableObject

Inherited Members

Restriction.Validate(ILicenseContext, Type, object), Restriction.Attach(IObjectListener), Restriction.Detach(IObjectListener), Restriction.Notify(params object[]), Restriction.Name, Restriction.License, Restriction.Listeners, Restriction.Id, Restriction.ExpireDate, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Examples

// Creates a 30 days trial XML license using fluent API
var signer = XmlDigitalSignature.CreateFromKeyFile("Keys.snk");

string licenseXML = new XmlLicense().ForAssembly("ACME.Web, Version=1.0.0.0")
                                    .WithTrialDays(30)
                                    .SignWith(signer)
                                    .ToReadableString();

//<Licenses xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
//  <License>
//    <Assembly name="ACME.Web" version="1.0.0.0" />
//    <Restrictions>
//      <Restriction xsi:type="Trial" Id="rD842" expireDays="30" />
//    </Restrictions>
//  </License>
//  <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
//    <SignedInfo>
//      <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
//      <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
//      <Reference URI="">
//        <Transforms>
//          <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
//        </Transforms>
//        <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
//        <DigestValue>KOKohrsJWwhuuixC1o/gIv5wUtU=</DigestValue>
//      </Reference>
//    </SignedInfo>
//    <SignatureValue>fcUu...</SignatureValue>
//  </Signature>
//</Licenses>

Constructors

TrialRestriction()

Initializes a new instance of the class.

public TrialRestriction()

Properties

ExpireDays

Gets the number of days after which the license expires.

public int? ExpireDays { get; set; }

Property Value

int?

IsExpired

Whether the trial is expired.

public bool IsExpired { get; }

Property Value

bool

Name

Gets the restriction name.

public override string Name { get; }

Property Value

string

RunCount

Gets the number of runs after which the license expires.

public int? RunCount { get; set; }

Property Value

int?

RunCountLeft

Gets the run count remaining before the license expires.

public int? RunCountLeft { get; }

Property Value

int?

RunInstances

Gets or sets the number of the software instances that are allowed to run simultaneously.

public int? RunInstances { get; set; }

Property Value

int?

RunTime

Gets the time that the software is allowed to run before the license expires.

public TimeSpan? RunTime { get; set; }

Property Value

TimeSpan?

Terms

Gets the license trial terms.

public string Terms { get; set; }

Property Value

string

TimeLeft

Gets the time remaining before the license expires.

public TimeSpan? TimeLeft { get; }

Property Value

TimeSpan?

Methods

Validate(ILicenseContext, Type, object)

Validates the current trial license restriction.

public override ValidationResult Validate(ILicenseContext context, Type type, object instance)

Parameters

NameDescription

The license context.

The for which the restriction is validated.

The object instance for which the restriction is validated.

Returns

NameDescription

The validation result code .

Last updated