Class ExtensionMethods
Some extension methods that allow you to use SKGL Extension as a Fluent API.
Inherited Members
Namespace: SKGL
Assembly: Cryptolens.Licensing.CrossPlatform.dll
Syntax
public static class ExtensionMethods
Methods
| Edit this page View SourceHasFeature(KeyInformation, int)
Checks so that a certain Feature is enabled (i.e. it's set to TRUE).
Declaration
public static KeyInformation HasFeature(this KeyInformation keyInformation, int featureNumber)
Parameters
Type | Name | Description |
---|---|---|
KeyInformation | keyInformation | |
int | featureNumber | The feature number, eg. feature1, feature 2, etc. FeatureNumber can be 1,2,...,8. |
Returns
Type | Description |
---|---|
KeyInformation | A key information object if the condition is satisfied. Null otherwise. |
HasNotExpired(KeyInformation, bool)
Checks that they key has not expired (i.e. the expire date has not been reached).
Declaration
public static KeyInformation HasNotExpired(this KeyInformation keyInformation, bool checkWithInternetTime = false)
Parameters
Type | Name | Description |
---|---|---|
KeyInformation | keyInformation | |
bool | checkWithInternetTime | If set to true, we will also check that the local time (on the client computer) has not been changed (using SKM.TimeCheck). |
Returns
Type | Description |
---|---|
KeyInformation | A key information object if the condition is satisfied. Null otherwise. |
HasNotFeature(KeyInformation, int)
Checks so that a certain Feature is disabled (i.e. it's set to FALSE).
Declaration
public static KeyInformation HasNotFeature(this KeyInformation keyInformation, int featureNumber)
Parameters
Type | Name | Description |
---|---|---|
KeyInformation | keyInformation | |
int | featureNumber | The feature number, eg. feature1, feature 2, etc. FeatureNumber can be 1,2,...,8. |
Returns
Type | Description |
---|---|
KeyInformation | A key information object if the condition is satisfied. Null otherwise. |
HasValidSignature(KeyInformation, string)
Checks that this object has a valid signature, which means that the content has not been altered after that it was generated by Cryptolens.
Declaration
public static KeyInformation HasValidSignature(this KeyInformation keyInformation, string rsaPublicKey)
Parameters
Type | Name | Description |
---|---|---|
KeyInformation | keyInformation | |
string | rsaPublicKey | The public key (RSA). It can be found here: https://app.cryptolens.io/User/Security |
Returns
Type | Description |
---|---|
KeyInformation | A key information object if the condition is satisfied. Null otherwise. |
HasValidSignature(KeyInformation, string, int?)
Checks that this object has a valid signature, which means that the content has not been altered after that it was generated by Cryptolens.
Declaration
public static KeyInformation HasValidSignature(this KeyInformation keyInformation, string rsaPublicKey, int? signatureExpirationInterval)
Parameters
Type | Name | Description |
---|---|---|
KeyInformation | keyInformation | |
string | rsaPublicKey | The public key (RSA). It can be found here: https://app.cryptolens.io/User/Security |
int? | signatureExpirationInterval |
Returns
Type | Description |
---|---|
KeyInformation | A key information object if the condition is satisfied. Null otherwise. |
IsOnRightMachine(KeyInformation)
Checks so that the machine code corresponds to the machine code of this computer. The default hash function is SHA1.
Declaration
public static KeyInformation IsOnRightMachine(this KeyInformation keyInformation)
Parameters
Type | Name | Description |
---|---|---|
KeyInformation | keyInformation |
Returns
Type | Description |
---|---|
KeyInformation |
IsOnRightMachine(KeyInformation, Func<string, string>)
Checks so that the machine code corresponds to the machine code of this computer.
Declaration
public static KeyInformation IsOnRightMachine(this KeyInformation keyInformation, Func<string, string> hashFunction)
Parameters
Type | Name | Description |
---|---|---|
KeyInformation | keyInformation | |
Func<string, string> | hashFunction | A hash function used to hash the current computer's parameters. |
Returns
Type | Description |
---|---|
KeyInformation |
IsValid(KeyInformation)
Checks that the Key Information object is valid (in the correct format). You can always add constraints such as @HasNotExpired(KeyInformation, bool).
Declaration
public static bool IsValid(this KeyInformation keyInformation)
Parameters
Type | Name | Description |
---|---|---|
KeyInformation | keyInformation |
Returns
Type | Description |
---|---|
bool | Returns true if the object is valid and false otherwise. |
IsValid(KeyInformation, string)
Checks that the Key Information object is valid (in the correct format). You can always add constraints such as @HasNotExpired(KeyInformation, bool).
Declaration
public static bool IsValid(this KeyInformation keyInformation, string rsaPublicKey)
Parameters
Type | Name | Description |
---|---|---|
KeyInformation | keyInformation | |
string | rsaPublicKey | The public key (RSA). It can be found here: https://app.cryptolens.io/User/Security |
Returns
Type | Description |
---|---|
bool | Returns true if the object is valid and false otherwise. |
LoadFromFile(KeyInformation, string)
Load a saved object from file (using @SaveToFile(KeyInformation, string)).
Declaration
public static KeyInformation LoadFromFile(this KeyInformation keyInformation, string file = "")
Parameters
Type | Name | Description |
---|---|---|
KeyInformation | keyInformation | |
string | file | The entire path including file name, i.e. c:\folder\file.txt |
Returns
Type | Description |
---|---|
KeyInformation | A key information object if the condition is satisfied. Null otherwise. |
LoadFromFile(KeyInformation, string, bool, bool)
Load a saved object from file (using @SaveToFile(KeyInformation, string)).
Declaration
public static KeyInformation LoadFromFile(this KeyInformation keyInformation, string file = "", bool json = false, bool activationFile = false)
Parameters
Type | Name | Description |
---|---|---|
KeyInformation | keyInformation | |
string | file | The entire path including file name, i.e. c:\folder\file.txt |
bool | json | If the file is stored in JSON (eg. an activation file with .skm extension), set this parameter to TRUE. |
bool | activationFile | If you obtained this file from an Activation Form (.skm extension), this should be set to true. |
Returns
Type | Description |
---|---|
KeyInformation | A key information object if the condition is satisfied. Null otherwise. |
SaveToFile(KeyInformation, string)
Save the current object into a file. It can be read using @LoadFromFile(KeyInformation, string).
Declaration
public static KeyInformation SaveToFile(this KeyInformation keyInformation, string file = "")
Parameters
Type | Name | Description |
---|---|---|
KeyInformation | keyInformation | |
string | file | The entire path including file name, i.e. c:\folder\file.txt |
Returns
Type | Description |
---|---|
KeyInformation | A key information object if the condition is satisfied. Null otherwise. |
SaveToFile(KeyInformation, string, bool)
Save the current object into a file. It can be read using @LoadFromFile(KeyInformation, string).
Declaration
public static KeyInformation SaveToFile(this KeyInformation keyInformation, string file = "", bool json = false)
Parameters
Type | Name | Description |
---|---|---|
KeyInformation | keyInformation | |
string | file | The entire path including file name, i.e. c:\folder\file.txt |
bool | json | If the file is stored in JSON (eg. an activation file with .skm extension), set this parameter to TRUE. |
Returns
Type | Description |
---|---|
KeyInformation | A key information object if the condition is satisfied. Null otherwise. |
Remarks
This method does not use the same JSON format structure as activation files. Instead, if you want to read these files using LoadFromFile(KeyInformation, string), then activationFile has to be set to FALSE.