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.
Copy public class TrialRestriction : Restriction , IObservableObject
Inheritance
object ← Restriction ← TrialRestriction
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
C# VB
Copy // 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>
Copy ' Creates a 30 days trial XML license using fluent API
Dim signer = XmlDigitalSignature.CreateFromKeyFile("Keys.snk")
Dim licenseXML As String = 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.
Copy public TrialRestriction ()
Properties
ExpireDays
Gets the number of days after which the license expires.
Copy public int? ExpireDays { get; set; }
Property Value
int ?
IsExpired
Whether the trial is expired.
Copy public bool IsExpired { get; }
Property Value
bool
Name
Gets the restriction name.
Copy public override string Name { get; }
Property Value
string
RunCount
Gets the number of runs after which the license expires.
Copy public int? RunCount { get; set; }
Property Value
int ?
RunCountLeft
Gets the run count remaining before the license expires.
Copy public int? RunCountLeft { get; }
Property Value
int ?
RunInstances
Gets or sets the number of the software instances that are allowed to run simultaneously.
Copy public int? RunInstances { get; set; }
Property Value
int ?
RunTime
Gets the time that the software is allowed to run before the license expires.
Copy public TimeSpan ? RunTime { get; set; }
Property Value
TimeSpan ?
Terms
Gets the license trial terms.
Copy public string Terms { get; set; }
Property Value
string
TimeLeft
Gets the time remaining before the license expires.
Copy public TimeSpan ? TimeLeft { get; }
Property Value
TimeSpan ?
Methods
Validate(ILicenseContext, Type, object)
Validates the current trial license restriction.
Copy public override ValidationResult Validate ( ILicenseContext context , Type type , object instance)
Parameters
Name Description The for which the restriction is validated.
The object instance for which the restriction is validated.
Returns
Name Description The validation result code .
Last updated 3 months ago