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: 2.4.0.0
  Babel.Licensing (in Babel.Licensing.dll) Version: 2.4.0.0
Syntax
public class HardwareRestriction : Restriction

The HardwareRestriction type exposes the following members.

Constructors
  NameDescription
Public methodHardwareRestriction
Initializes a new instance of the HardwareRestriction class.
Top
Properties
  NameDescription
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 the restriction identifier.
(Inherited from Restriction.)
Public propertyName
Gets the restriction name.
(Overrides RestrictionName.)
Top
Methods
  NameDescription
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 a hash function for a particular type.
(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 methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodValidate
Validates the current hardware restriction.
(Overrides RestrictionValidate(ILicenseContext, Type, Object).)
Top
Examples
// 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";

license.Restrictions.Add(hardware);

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

string licenseXML = license.SignWith(signer)
                           .ToReadableString();

// 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")
                                    .SignWith(signer)
                                    .ToReadableString();

//<Licenses xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
//  <License>
//    <Restrictions>
//      <Restriction xsi:type="Hardware">
//        <HardwareKey>EFP76-XAJXI-655MU-JAQVX-LGYL6</HardwareKey>
//      </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>vBCBlHCwDoJuU8+hZ5k9b2jRKfk=</DigestValue>
//      </Reference>
//    </SignedInfo>
//    <SignatureValue>CnSM...</SignatureValue>
//  </Signature>
//</Licenses>
See Also