Click or drag to resize
HardwareRestriction Class
Defines an hardware Restriction object. The hardware restriction tie the license to a particular hardware represented by a key string. This class cannot be inherited.
Inheritance Hierarchy

Namespace:  Babel.Licensing
Assemblies:   Babel.Licensing (in Babel.Licensing.dll) Version:
  Babel.Licensing (in Babel.Licensing.dll) Version:
public class HardwareRestriction : Restriction

The HardwareRestriction type exposes the following members.

Public methodHardwareRestriction
Initializes a new instance of the HardwareRestriction class.
Public propertyData
Gets additional hardware information.
Public propertyExpireDate
Gets or sets the expire date after which the license is no longer valid.
(Inherited from Restriction.)
Public propertyHardwareKey
Gets the hardware key.
Public propertyId
Gets or sets the restriction identifier.
(Inherited from Restriction.)
Public propertyListeners
Gets the listeners.
(Inherited from Restriction.)
Public propertyName
Gets the restriction name.
(Overrides RestrictionName.)
Public methodAttach
Attaches the given listener.
(Inherited from Restriction.)
Public methodDetach
Detaches the given listener.
(Inherited from Restriction.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodNotify
Notifies registered listeners.
(Inherited from Restriction.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodValidate
Validates the current hardware restriction.
(Overrides RestrictionValidate(ILicenseContext, Type, Object).)
// Creates an XML license for a specific hardware 
var license = new XmlLicense();

// Add the hardware key
// The hardware key can be generated using the 
// Babel.Licensing.HardwareId class
HardwareRestriction hardware = new HardwareRestriction();
hardware.HardwareKey = "EFP76-XAJXI-655MU-JAQVX-LGYL6";


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

string licenseXML = license.SignWith(signer)

// The same license can be generated using fluent API
var signer = XmlDigitalSignature.CreateFromKeyFile("Keys.snk");

string licenseXML = new XmlLicense().WithHardwareKey("EFP76-XAJXI-655MU-JAQVX-LGYL6")

//<Licenses xmlns:xsi="">
//  <License>
//    <Restrictions>
//      <Restriction xsi:type="Hardware">
//        <HardwareKey>EFP76-XAJXI-655MU-JAQVX-LGYL6</HardwareKey>
//      </Restriction>
//    </Restrictions>
//  </License>
//  <Signature xmlns="">
//    <SignedInfo>
//      <CanonicalizationMethod Algorithm="" />
//      <SignatureMethod Algorithm="" />
//      <Reference URI="">
//        <Transforms>
//          <Transform Algorithm="" />
//        </Transforms>
//        <DigestMethod Algorithm="" />
//        <DigestValue>vBCBlHCwDoJuU8+hZ5k9b2jRKfk=</DigestValue>
//      </Reference>
//    </SignedInfo>
//    <SignatureValue>CnSM...</SignatureValue>
//  </Signature>
See Also