Click or drag to resize

SKMOptionalField Method

Namespace:  SKGL
Assembly:  SKM (in SKM.dll) Version: 4.0.2.6 (4.0.2.6)
Syntax
public static int OptionalField(
	ProductVariables productVariables,
	string sid,
	SKMTodo todo = SKMTodo.Get,
	int decrement = 0
)

Parameters

productVariables
Type: SKGLProductVariables
The object that contains Uid, Pid and Hsum
sid
Type: SystemString
Serial Key that is to be validated
todo (Optional)
Type: SKGLSKMTodo
Action to perform. Either Get or Set.
decrement (Optional)
Type: SystemInt32
If todo is set to "Set", this method will try to decrease the current value of the optional field by this value.
Note, it has to be a positive integer.

Return Value

Type: Int32
An intger that is currently stored in the optional field.
Examples
The code below first checks the value of the optional field and then decreases it by 1. The Assert.True will be true in this case.
C#
public void TestOptionalField()
{
    // let's assume that the following key has an optional field of the value 5.
    // edit: this will pass several thousand times. then, it has to be increased again.

    var productVariables = new SKGL.ProductVariables() { UID = "2", PID = "2196", HSUM = "749172" };

    int currentvalue = SKGL.SKM.OptionalField(productVariables, "KTDOU-JZQUY-NOJCU-ECTAA");

    int newValue = SKGL.SKM.OptionalField(productVariables, "KTDOU-JZQUY-NOJCU-ECTAA", SKGL.SKM.Todo.Set, 1);

    Assert.IsTrue(newValue == currentvalue - 1);

}
See Also