Class Metered

Class Metered

Namespace: Aspose.Note
Assembly: Aspose.Note.dll (24.12.0)

Provides methods to set metered key.

public class Metered

Inheritance

objectMetered

Inherited Members

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Examples

In this example, an attempt will be made to set metered public and private key

Metered metered = new Metered();
metered.SetMeteredKey("PublicKey", "PrivateKey");
Dim metered As Metered = New Metered
metered.SetMeteredKey("PublicKey", "PrivateKey")

Shows how to set metered license.```csharp Metered metered = new Metered(); metered.SetMeteredKey(“MyPublicKey”, “MyPrivateKey”);

                                        Console.WriteLine($"Credit before operation: {Metered.GetConsumptionCredit():F2}");
                                        Console.WriteLine($"Consumption quantity before operation: {Metered.GetConsumptionQuantity():F2}");

                                        // The path to the documents directory.
                                        string dataDir = RunExamples.GetDataDir_Pages();

                                        // Load OneNote document and get first child           
                                        Document document = new Document(Path.Combine(dataDir, "Aspose.one"));

                                        document.Save(Path.Combine(dataDir, "MeteredLicense.pdf"));

                                        Console.WriteLine($"Credit before operation: {Metered.GetConsumptionCredit():F2}");
                                        Console.WriteLine($"Consumption quantity before operation: {Metered.GetConsumptionQuantity():F2}");

## Constructors

### <a id="Aspose_Note_Metered__ctor"></a> Metered\(\)

```csharp
public Metered()

Methods

GetConsumptionCredit()

Gets consumption credit.

public static decimal GetConsumptionCredit()

Returns

decimal

Returns the number of consumed credit points.

GetConsumptionQuantity()

Gets consumption file size.

public static decimal GetConsumptionQuantity()

Returns

decimal

Returns the number of consumed bytes.

ResetMeteredKey()

Removes previously setup license.

public void ResetMeteredKey()

SetMeteredKey(string, string)

Sets metered public and private keys.

public void SetMeteredKey(string publicKey, string privateKey)

Parameters

publicKey string

The public key.

privateKey string

The private key.

Examples

Shows how to set metered license.```csharp Metered metered = new Metered(); metered.SetMeteredKey(“MyPublicKey”, “MyPrivateKey”);

                                        Console.WriteLine($"Credit before operation: {Metered.GetConsumptionCredit():F2}");
                                        Console.WriteLine($"Consumption quantity before operation: {Metered.GetConsumptionQuantity():F2}");

                                        // The path to the documents directory.
                                        string dataDir = RunExamples.GetDataDir_Pages();

                                        // Load OneNote document and get first child           
                                        Document document = new Document(Path.Combine(dataDir, "Aspose.one"));

                                        document.Save(Path.Combine(dataDir, "MeteredLicense.pdf"));

                                        Console.WriteLine($"Credit before operation: {Metered.GetConsumptionCredit():F2}");
                                        Console.WriteLine($"Consumption quantity before operation: {Metered.GetConsumptionQuantity():F2}");

#### Remarks

If you purchase metered license, this API should be called on application startup, normally, this is enough.
However, if metered fails to upload consumption data during 24 hours period, the license will be set to evaluation status. To avoid such case, you should regularly check the license status If it is evaluation status, call this API again.