UsageRestriction

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

An usage is typically used to define environment license restrictions.

public class UsageRestriction : Restriction, IObservableObject

Inheritance

objectRestrictionUsageRestriction

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 an XML license valid only for a specified process 
// name that is not executing in a virtual machine

var signer = XmlDigitalSignature.CreateFromKeyFile("Keys.snk");

string licenseXML = new XmlLicense().RestrictedToProcess("MotionCapture")
                                    .NotForVirtualEnvironment()
                                    .SignWith(signer)
                                    .ToReadableString();

//<Licenses xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
//  <License>
//    <Restrictions>
//      <Restriction xsi:type="Usage" Id="r4A08" canRunInVirtualEnvironment="false">
//        <ProcessList>MotionCapture</ProcessList>
//      </Restriction>
//    </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>ozYWhEYlFubqhRqkIrHA1kwD9sk=</DigestValue>
//      </Reference>
//    </SignedInfo>
//    <SignatureValue>afpb...</SignatureValue>
//  </Signature>
//</Licenses>

Constructors

UsageRestriction()

Initializes a new instance of the class.

public UsageRestriction()

Properties

CanRunInVirtualEnvironment

Whether the use of the license is permitted inside a virtual machine or emulator.

public bool? CanRunInVirtualEnvironment { get; set; }

Property Value

bool?

Name

Gets the restriction name.

public override string Name { get; }

Property Value

string

ProcessList

Gets or sets the name of the process.

public string ProcessList { get; set; }

Property Value

string

Usage

Gets or sets the license usage.

public string Usage { get; set; }

Property Value

string

Methods

Validate(ILicenseContext, Type, object)

Validates the current license usage restriction object.

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

Parameters

NameDescription

The license context.

type Type

The for which the restriction is validated.

instance object

The instance.

Returns

NameDescription

The validation result code .

Last updated