Interface IMirageMigrationBuilder
Defines methods for migration of license files.
Namespace: Sartorius.SAF.Licensing.Mirage
Assembly: Sartorius.SAF.Licensing.Mirage.dll
Syntax
public interface IMirageMigrationBuilder
Examples
The following example shows how to implement a mirage license migration.
using System;
using Sartorius.SAF.Licensing;
using Sartorius.SAF.Licensing.Mirage;
namespace Sartorius.SAF.Documentation.Examples.Licensing
{
/// <summary>
/// Migrates the license to the new version 5.1.1.1.
/// </summary>
public class LicensingMigrationExample : MirageMigration
{
/// <summary>
/// Gets the migration version. This should be a unique value for all migrations.
/// </summary>
public override Version MigrationVersion => new Version("5.1.1.1");
/// <summary>
/// Does the actual migration of the license file.
/// </summary>
/// <param name="builder">An implementation of the mirage migration builder.</param>
public override void Migrate(IMirageMigrationBuilder builder)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
// add a new feature "QHD011"
var feature = new FeatureInfo("QHD011", "nameB", new DateTime(2020, 10, 10, 0, 0, 0, DateTimeKind.Local), FeatureState.Demo, 1);
builder.AddFeature(feature, FeatureType.Counter);
// change existing feature eg. 'expired on' value.
// Accepted values are in ISO - format 'YYYY - MM - DD'.
builder.SetFeatureValue("QHD011", FeatureToken.EXO, "2032-01-01");
// delete an existing feature.
builder.DeleteFeature("QHD010");
// set the license file Tag value.
builder.SetLicenseValue(LicenseFileToken.LTG, "value");
var featureInfo = builder.GetFeatureInfo("QHD009");
if (featureInfo.ExpirationDate == null)
{
builder.SetFeatureValue("QHD009", FeatureToken.EXO, "2032-01-01");
}
}
}
}
Methods
View SourceAddFeature(FeatureInfo, FeatureType)
Adds a given license feature to the license file.
Declaration
void AddFeature(FeatureInfo feature, FeatureType featureType)
Parameters
Type | Name | Description |
---|---|---|
FeatureInfo | feature | The license feature to add. |
FeatureType | featureType | The license feature type. |
DeleteFeature(String)
Deletes a license feature from the license file.
Declaration
void DeleteFeature(string featureId)
Parameters
Type | Name | Description |
---|---|---|
System.String | featureId | The id of the license feature that should be deleted. |
GetFeatureInfo(String)
Gets the feature information for the specified feature id.
Declaration
FeatureInfo GetFeatureInfo(string featureId)
Parameters
Type | Name | Description |
---|---|---|
System.String | featureId | The license feature id. |
Returns
Type | Description |
---|---|
FeatureInfo | An instance of FeatureInfo containing all information about the feature specified by |
GetFeatureValue(String, FeatureToken)
Gets the value for the specified feature id and FeatureToken.
Declaration
string GetFeatureValue(string featureId, FeatureToken token)
Parameters
Type | Name | Description |
---|---|---|
System.String | featureId | The feature id. |
FeatureToken | token | The feature token. |
Returns
Type | Description |
---|---|
System.String | The value for the specified |
GetLicenseValue(LicenseFileToken)
Gets the value for the specified token.
Declaration
string GetLicenseValue(LicenseFileToken token)
Parameters
Type | Name | Description |
---|---|---|
LicenseFileToken | token | The license file token. |
Returns
Type | Description |
---|---|
System.String | The value for the specified token or |
SetFeatureValue(String, FeatureToken, String)
Sets the value for the specified feature id and token.
Declaration
void SetFeatureValue(string featureId, FeatureToken token, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | featureId | The feature id. |
FeatureToken | token | The feature token. |
System.String | value | The value to set. |
SetLicenseValue(LicenseFileToken, String)
Sets the value for the specified token.
Declaration
void SetLicenseValue(LicenseFileToken token, string value)
Parameters
Type | Name | Description |
---|---|---|
LicenseFileToken | token | The license file token. |
System.String | value | The value to set. |