C#

The C# library allows you to interact with the Flux API for user authentication and variable fetching.

Installation

You can install the C# library by either copying the source code into your project or by referencing the compiled binary.

Usage

Initialize

To initialize the library, set the Application property to your Flux application ID.

using Flux;

Auth.Application = "your-application-id";

Authenticate

To authenticate a user, call the Authenticate method with the user’s license key and an optional hardware ID.

try {
    Auth.Authenticate(license, hwid);
} catch (Exception e) {
    Console.WriteLine("Authentication failed: " + e.Message);
    return;
}

Get Field

To get a field from the authenticated response, call the GetField<T> method with the field name.

int expiresAt = Auth.GetField<int>("expiresAt");
Console.WriteLine("License expires at " + expiresAt);

Get Variable

To get a variable from the Flux API, call the GetVariable<T> method with the variable name.

string variableValue = Auth.GetVariable<string>("variable-name");
Console.WriteLine("Variable value: " + variableValue);

Download Variable

To download a variable as a file, call the DownloadVariable method with the variable name.

byte[] fileData = Auth.DownloadVariable("variable-name");
File.WriteAllBytes("output-file-name", fileData);

Example

using Flux;

Auth.Application = "your-application-id";

// Get an unauthenticated variable
Console.WriteLine(Auth.GetVariable<string>("welcome-str"));

try {
    Auth.Authenticate("your-license", "your-hwid");
} catch (Exception e) {
    Console.WriteLine("Authentication failed: " + e.Message);
    return;
}

Console.WriteLine($"License expires at {Auth.GetField<int>("expiresAt")}");
Console.WriteLine($"Authenticated variable: {Auth.GetVariable<string>("authenticated")}");

var file = Auth.DownloadVariable("file");
File.WriteAllBytes("file.bin", file);