### FileTokenDeviceIdComponent Usage Example
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Components.md
An example demonstrating how to instantiate and use the FileTokenDeviceIdComponent with a DeviceIdBuilder. Ensure the same file path is used for persistence.
```csharp
var component = new FileTokenDeviceIdComponent("./device-token.txt");
builder.AddComponent("Token", component);
```
--------------------------------
### Using DefaultV5 Formatter with DeviceIdBuilder
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Formatters.md
Example demonstrating how to use the DefaultV5 formatter for backward compatibility when building a device ID.
```csharp
// Use version 5 formatter for backward compatibility
var deviceId = new DeviceIdBuilder()
.AddMachineName()
.AddOsVersion()
.UseFormatter(DeviceIdFormatters.DefaultV5)
.ToString();
```
--------------------------------
### Install DeviceId Packages
Source: https://github.com/matthewking/deviceid/blob/main/readme.md
Installs the core DeviceId package and the Windows-specific components using the NuGet Package Manager.
```powershell
PM> Install-Package DeviceId
PM> Install-Package DeviceId.Windows
```
--------------------------------
### Example: Generate Database ID with Server Name
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/SqlServer.md
Shows how to generate a database identifier that includes the SQL Server instance name.
```csharp
string databaseId = new DeviceIdBuilder()
.AddSqlServer(connection, sql => sql.AddServerName())
.ToString();
// Result: Component includes server name like "MYSERVER"
```
--------------------------------
### Example Usage of PlainTextDeviceIdComponentEncoder
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Encoders.md
Demonstrates how to use PlainTextDeviceIdComponentEncoder with a DeviceIdBuilder and StringDeviceIdFormatter to generate a device ID.
```csharp
var encoder = new PlainTextDeviceIdComponentEncoder();
var formatter = new StringDeviceIdFormatter(encoder);
var deviceId = new DeviceIdBuilder()
.AddMachineName()
.AddUserName()
.UseFormatter(formatter)
.ToString();
```
--------------------------------
### Example: Generate Database ID with Database Name
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/SqlServer.md
Demonstrates generating a database identifier that includes the current database name.
```csharp
string databaseId = new DeviceIdBuilder()
.AddSqlServer(connection, sql => sql.AddDatabaseName())
.ToString();
// Component includes database name like "MyDatabase"
```
--------------------------------
### Custom Component Implementation
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Components.md
Demonstrates how to create a custom IDeviceIdComponent by implementing the interface. This example shows a simple component returning a fixed string value.
```csharp
public class CustomComponent : IDeviceIdComponent
{
public string GetValue()
{
// Return the component value
return "CustomValue";
}
}
// Use the custom component
var builder = new DeviceIdBuilder();
builder.AddComponent("CustomName", new CustomComponent());
```
--------------------------------
### Example: AddMacAddressFromWmi to Windows DeviceIdBuilder
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Windows.md
Demonstrates excluding wireless and non-physical MAC addresses when building a Windows device identifier.
```csharp
var deviceId = new DeviceIdBuilder()
.OnWindows(windows => windows
.AddMacAddressFromWmi(excludeWireless: true, excludeNonPhysical: true))
.ToString();
```
--------------------------------
### XmlDeviceIdFormatter Usage Example
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Formatters.md
Demonstrates how to create and use XmlDeviceIdFormatter to format device ID components into an XML structure.
```csharp
var formatter = new XmlDeviceIdFormatter(
new PlainTextDeviceIdComponentEncoder()
);
var deviceId = new DeviceIdBuilder()
.AddMachineName()
.AddOsVersion()
.UseFormatter(formatter)
.ToString();
// Output:
```
--------------------------------
### Example: AddRegistryValue to Windows DeviceIdBuilder
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Windows.md
Demonstrates how to add a custom registry value using the AddRegistryValue method on Windows.
```csharp
var deviceId = new DeviceIdBuilder()
.OnWindows(windows => windows
.AddRegistryValue("CustomValue", RegistryView.Registry64, RegistryHive.LocalMachine,
"SOFTWARE\MyApp", "DeviceId"))
.ToString();
```
--------------------------------
### Example: Generate Database ID with SQL Server Components
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/SqlServer.md
Demonstrates how to generate a database identifier by adding server name, database name, and database ID using an open SQL Server connection.
```csharp
using SqlConnection connection = new SqlConnection("Server=.;Database=MyDb;Integrated Security=true;");
connection.Open();
string databaseId = new DeviceIdBuilder()
.AddSqlServer(connection, sql => sql
.AddServerName()
.AddDatabaseName()
.AddDatabaseId())
.ToString();
```
--------------------------------
### Migrate OS Installation ID Method
Source: https://github.com/matthewking/deviceid/blob/main/readme.md
Shows the transition from the v5 AddOSInstallationID() method to v6 OS-specific methods like AddMachineGuid() for Windows, AddMachineId() for Linux, and AddPlatformSerialNumber() for Mac.
```csharp
// V5:
builder.AddOSInstallationID();
// V6:
builder.OnWindows(x => x.AddMachineGuid())
.OnLinux(x => x.AddMachineId())
.OnMac(x => x.AddPlatformSerialNumber());
```
--------------------------------
### Linux Platform Detection Example
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Linux.md
Demonstrates how to use the `OnLinux` extension to add Linux-specific device ID components. This code only executes Linux components when run on a Linux operating system.
```csharp
var deviceId = new DeviceIdBuilder()
.OnLinux(linux => linux
.AddMotherboardSerialNumber()
.AddMachineId())
.ToString();
// On non-Linux platforms, Linux-specific components are skipped
```
--------------------------------
### Application Instance Tracking with File Token
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/README.md
Generates a unique identifier for an application installation using machine name, OS version, user name, and a file token.
```csharp
// Identify unique application installation
string appInstanceId = new DeviceIdBuilder()
.AddMachineName()
.AddOsVersion()
.AddUserName(normalize: true)
.AddFileToken("./app-instance.token")
.ToString();
```
--------------------------------
### Initialize DeviceIdBuilder
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/DeviceIdBuilder.md
Creates a new instance of the DeviceIdBuilder with default settings. This is the starting point for building a device identifier.
```csharp
public DeviceIdBuilder()
```
```csharp
var builder = new DeviceIdBuilder();
```
--------------------------------
### Creating and Using a Custom HashDeviceIdFormatter
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Formatters.md
Example of creating a HashDeviceIdFormatter with SHA256 and Base32 Crockford encoding, then using it with DeviceIdBuilder.
```csharp
using System.Security.Cryptography;
var formatter = new HashDeviceIdFormatter(
() => SHA256.Create(),
new Base32ByteArrayEncoder(Base32ByteArrayEncoder.CrockfordAlphabet)
);
var deviceId = new DeviceIdBuilder()
.AddMachineName()
.AddOsVersion()
.UseFormatter(formatter)
.ToString();
```
--------------------------------
### Base32ByteArrayEncoder Example Usage
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Encoders.md
Demonstrates how to use the Base32ByteArrayEncoder with both Crockford and RFC 4648 alphabets for device ID formatting.
```csharp
// Using Crockford alphabet (used in DefaultV6 formatter)
var encoder = new Base32ByteArrayEncoder(Base32ByteArrayEncoder.CrockfordAlphabet);
var formatter = new HashDeviceIdFormatter(() => SHA256.Create(), encoder);
var deviceId = new DeviceIdBuilder()
.AddMachineName()
.UseFormatter(formatter)
.ToString();
// Using RFC 4648 alphabet
var rfcEncoder = new Base32ByteArrayEncoder(Base32ByteArrayEncoder.Rfc4648Alphabet);
```
--------------------------------
### StringDeviceIdFormatter Usage Example
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Formatters.md
Demonstrates how to create and use StringDeviceIdFormatter with a custom delimiter to format device ID components.
```csharp
var formatter = new StringDeviceIdFormatter(
new PlainTextDeviceIdComponentEncoder(),
"|"
);
var deviceId = new DeviceIdBuilder()
.AddMachineName()
.AddOsVersion()
.AddUserName()
.UseFormatter(formatter)
.ToString();
// Output: MachineName|OSVersion|UserName
```
--------------------------------
### Example: AddFileToken Usage
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/DeviceIdBuilderExtensions.md
Demonstrates how to use the AddFileToken method to create a device ID with a persistent token stored in a file. The same file path will consistently generate the same token across application runs.
```csharp
var deviceId = new DeviceIdBuilder()
.AddFileToken("./device-token.txt")
.ToString();
// Same path always generates the same token across application runs
```
--------------------------------
### Example Usage of Base64ByteArrayEncoder
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Encoders.md
Shows the instantiation of a Base64ByteArrayEncoder. This encoder is used for converting byte arrays into Base64 strings.
```csharp
var encoder = new Base64ByteArrayEncoder();
```
--------------------------------
### Example Usage of HexByteArrayEncoder
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Encoders.md
Demonstrates using HexByteArrayEncoder with a HashDeviceIdFormatter to generate a device ID. The output will be a hexadecimal string.
```csharp
var encoder = new HexByteArrayEncoder();
var formatter = new HashDeviceIdFormatter(() => SHA256.Create(), encoder);
var deviceId = new DeviceIdBuilder()
.AddMachineName()
.UseFormatter(formatter)
.ToString();
// Output: hex string like "a1b2c3d4e5f6..."
```
--------------------------------
### Generate Cross-Platform Device ID with Windows Enhancements
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Windows.md
This example demonstrates generating a device ID that works across platforms, including Windows-specific enhancements like the Windows device ID and processor ID. It also includes machine name, OS version, MAC address, and motherboard serial number for Linux.
```csharp
string deviceId = new DeviceIdBuilder()
.AddMachineName()
.AddOsVersion()
.AddMacAddress()
.OnWindows(windows => windows
.AddWindowsDeviceId()
.AddProcessorId())
.OnLinux(linux => linux
.AddMotherboardSerialNumber())
.ToString();
```
--------------------------------
### Example: Add Custom Query Result to SqlServerDeviceIdBuilder
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/SqlServer.md
Demonstrates adding a custom component by executing a T-SQL query and formatting its result. Useful for including specific database properties.
```csharp
builder.AddQueryResult("CustomProperty",
"SELECT DATABASEPROPERTYEX(DB_NAME(),'IsReadOnly')",
result => result?.ToString() ?? "Unknown");
```
--------------------------------
### Initialize DeviceIdManager
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/DeviceIdManager.md
Creates a new instance of the DeviceIdManager with default settings. This is the starting point for configuring device ID management.
```csharp
public DeviceIdManager()
```
```csharp
var manager = new DeviceIdManager();
```
--------------------------------
### Custom String DeviceId Formatter with Plain Text Encoding
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/README.md
This example shows how to create a custom string-based DeviceId formatter. It uses plain text encoding for components and a pipe symbol as a separator, suitable for human-readable or simple delimited output.
```csharp
var formatter = new StringDeviceIdFormatter(
new PlainTextDeviceIdComponentEncoder(),
"|"
);
```
--------------------------------
### Get SQL Server Instance and Database ID
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/SqlServer.md
Use this snippet to generate a device ID incorporating the SQL Server instance name and database name. Ensure the user executing the query has the necessary permissions to query system information and that property names are validated if dynamic.
```csharp
try
{
using SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
string databaseId = new DeviceIdBuilder()
.AddSqlServer(connection, sql => sql
.AddServerName()
.AddDatabaseName())
.ToString();
}
catch (SqlException ex)
{
// Handle SQL Server connection/query errors
}
catch (InvalidOperationException ex)
{
// Handle connection state errors
}
```
--------------------------------
### GetDeviceId (with version)
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/DeviceIdManager.md
Gets a device ID for a specific version. The ID is encoded with the specified version number.
```APIDOC
## GetDeviceId (with version)
### Description
Gets a device ID for a specific version. The ID is encoded with the specified version number.
### Method
```csharp
public string GetDeviceId(int version)
```
### Parameters
#### Path Parameters
- **version** (int) - Required - The version number of the builder to use.
### Returns
The device ID generated from the specified version builder, encoded with version number. Returns null if the version is not registered.
### Example
```csharp
string v1DeviceId = manager.GetDeviceId(1); // Returns: $1$
string v2DeviceId = manager.GetDeviceId(2); // Returns: $2$
```
```
--------------------------------
### Platform-Specific Component Configuration
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/README.md
Demonstrates how to use platform-specific extensions to add components relevant to Windows, Linux, or macOS.
```csharp
.OnWindows(...) // Registry, WMI, processor ID
.OnLinux(...) // DMI, Device Tree, machine ID
.OnMac(...) // IOKit, drive volume UUID
```
--------------------------------
### Migrate System UUID Method
Source: https://github.com/matthewking/deviceid/blob/main/readme.md
Demonstrates the v5 AddSystemUUID() method's migration to v6, where it becomes OS-specific: AddSystemUuid() for Windows and AddProductUuid() for Linux, with no direct equivalent on Mac.
```csharp
// V5:
builder.AddSystemUUID();
// V6:
builder.OnWindows(x => x.AddSystemUuid())
.OnLinux(x => x.AddProductUuid());
// not available on Mac
```
--------------------------------
### AddMachineGuid Method
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Windows.md
Adds the machine GUID, a unique identifier stored in the Windows Cryptography store, to the device identifier.
```APIDOC
## AddMachineGuid
### Description
Adds the machine GUID, a unique identifier stored in the Windows Cryptography store, to the device identifier. This GUID typically persists across Windows reinstallation.
### Method Signature
```csharp
public static WindowsDeviceIdBuilder AddMachineGuid(this WindowsDeviceIdBuilder builder)
```
### Parameters
#### Path Parameters
* None
#### Query Parameters
* None
#### Request Body
* None
### Component Name
`MachineGuid`
### Source
Registry value `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\MachineGuid`
### Returns
* `WindowsDeviceIdBuilder` - The `WindowsDeviceIdBuilder` instance for method chaining.
### Note
This GUID is unique per machine and persists across Windows reinstallations in most cases.
```
--------------------------------
### License Validation with Multiple Versions
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/DeviceIdManager.md
Demonstrates setting up a DeviceIdManager to support multiple versions of device ID generation and validating older license formats.
```csharp
// Initial deployment (v1)
var originalDeviceIdGenerator = new DeviceIdBuilder()
.AddMachineName()
.AddUserName()
.AddMacAddress();
// New deployment (v2) with simplified device ID
var updatedDeviceIdGenerator = new DeviceIdBuilder()
.AddMacAddress()
.AddFileToken("./license-token.txt");
// Create manager that supports both versions
var manager = new DeviceIdManager()
.AddBuilder(1, originalDeviceIdGenerator)
.AddBuilder(2, updatedDeviceIdGenerator);
// Generate new device ID in current format
string newLicenseDeviceId = manager.GetDeviceId();
// Validate old licenses
string oldLicenseDeviceId = "..."; // from old license file
bool isLicenseValid = manager.Validate(oldLicenseDeviceId);
```
--------------------------------
### OnWindows Extension Method
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Windows.md
Extends the DeviceIdBuilder to configure Windows-specific components. This configuration action is only executed on Windows platforms.
```APIDOC
## OnWindows
### Description
Extends the `DeviceIdBuilder` to configure Windows-specific components. The provided action is only executed on Windows platforms, ensuring platform-specific logic is applied correctly.
### Method Signature
```csharp
public static DeviceIdBuilder OnWindows(this DeviceIdBuilder builder, Action windowsBuilderConfiguration)
```
### Parameters
#### Path Parameters
* None
#### Query Parameters
* None
#### Request Body
* None
### Parameters
* `builder` (`DeviceIdBuilder`) - The builder to extend.
* `windowsBuilderConfiguration` (`Action`) - Action that configures Windows-specific components. Only executes on Windows.
### Returns
* `DeviceIdBuilder` - The `DeviceIdBuilder` instance for method chaining.
### Behavior
The action is only invoked on Windows platforms. On other platforms, it is skipped silently.
```
--------------------------------
### GetDeviceId (no arguments)
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/DeviceIdManager.md
Gets the current device ID using the highest version builder. The ID is encoded with the version number.
```APIDOC
## GetDeviceId (no arguments)
### Description
Gets the current device ID using the highest version builder. The ID is encoded with the version number.
### Method
```csharp
public string GetDeviceId()
```
### Returns
The device ID generated from the highest version builder, encoded with version number. Returns null if no builders are registered.
### Example
```csharp
string deviceId = manager.GetDeviceId();
// Returns: $3$
```
```
--------------------------------
### FileTokenDeviceIdComponent Constructor
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Components.md
Initializes a new instance of the FileTokenDeviceIdComponent class. This constructor takes a file path where the token will be stored or read from.
```APIDOC
## FileTokenDeviceIdComponent(string path)
### Description
Initializes a new instance of the FileTokenDeviceIdComponent class. This constructor takes a file path where the token will be stored or read from.
### Parameters
#### Path Parameters
- **path** (string) - Required - The file path where the token will be stored.
### Example
```csharp
var component = new FileTokenDeviceIdComponent("./device-token.txt");
builder.AddComponent("Token", component);
```
```
--------------------------------
### Get Device ID (ToString Override)
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/DeviceIdManager.md
Returns the current device ID, equivalent to calling GetDeviceId() without arguments.
```csharp
public override string ToString()
```
```csharp
string deviceId = manager.ToString();
```
--------------------------------
### Fluent Interface for DeviceIdBuilder
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/DeviceIdBuilder.md
Demonstrates the fluent interface pattern using extension methods to chain multiple component additions before generating the final device ID. This provides a concise way to build complex identifiers.
```csharp
string deviceId = new DeviceIdBuilder()
.AddMachineName()
.AddOsVersion()
.AddMacAddress()
.ToString();
```
--------------------------------
### Get Device ID (Specific Version)
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/DeviceIdManager.md
Retrieves a device ID for a specified version. Returns null if the version is not registered.
```csharp
public string GetDeviceId(int version)
```
```csharp
string v1DeviceId = manager.GetDeviceId(1); // Returns: $1$
string v2DeviceId = manager.GetDeviceId(2); // Returns: $2$
```
--------------------------------
### Configuring DeviceIdManager for Gradual Migration
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/DeviceIdManager.md
Demonstrates how to configure DeviceIdManager with multiple builders for gradual migration. This allows older device ID formats to remain valid while introducing new ones.
```csharp
var manager = new DeviceIdManager()
// Original format
.AddBuilder(1, builder => builder
.AddMachineName()
.AddOsVersion()
.AddUserName())
// Improved format (removes OS version due to frequent changes)
.AddBuilder(2, builder => builder
.AddMachineName()
.AddUserName()
.AddMacAddress())
// Current format (adds persistent token)
.AddBuilder(3, builder => builder
.AddMacAddress()
.AddFileToken("./device-id.txt"));
// Old licenses continue to work, new ones use v3
string currentId = manager.GetDeviceId(); // v3 format
bool validateOldV1 = manager.Validate(oldV1Id); // true
bool validateOldV2 = manager.Validate(oldV2Id); // true
```
--------------------------------
### Get Device ID (Highest Version)
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/DeviceIdManager.md
Retrieves the device ID generated by the highest version builder. Returns null if no builders are registered.
```csharp
public string GetDeviceId()
```
```csharp
string deviceId = manager.GetDeviceId();
// Returns: $3$
```
--------------------------------
### Migrate Processor ID Method
Source: https://github.com/matthewking/deviceid/blob/main/readme.md
Shows the v5 AddSystemUUID() method's migration to v6, where it is replaced by OS-specific methods: AddProcessorId() for Windows and AddCpuInfo() for Linux, not available on Mac.
```csharp
// V5:
builder.AddSystemUUID();
// V6:
builder.OnWindows(x => x.AddProcessorId())
.OnLinux(x => x.AddCpuInfo());
// not available on Mac
```
--------------------------------
### FileTokenDeviceIdComponent Constructor
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Components.md
The constructor for FileTokenDeviceIdComponent. It requires a string representing the file path for token storage.
```csharp
public FileTokenDeviceIdComponent(string path)
```
--------------------------------
### LinuxDeviceIdBuilder
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/types.md
A fluent builder for Linux-specific device ID components.
```APIDOC
## LinuxDeviceIdBuilder
### Description
Fluent builder for Linux-specific components.
### Methods
- `LinuxDeviceIdBuilder AddComponent(string name, IDeviceIdComponent component)`: Adds a component to the builder.
```
--------------------------------
### Get Current Device ID Version
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/DeviceIdManager.md
Retrieves the highest registered version number among all configured builders. This ensures that new device IDs are generated using the latest format.
```csharp
public int GetCurrentVersion()
```
```csharp
var manager = new DeviceIdManager()
.AddBuilder(1, builder => builder.AddMachineName())
.AddBuilder(2, builder => builder.AddMachineName().AddOsVersion())
.AddBuilder(3, builder => builder.AddMachineName().AddMacAddress());
int currentVersion = manager.GetCurrentVersion(); // Returns 3
```
--------------------------------
### Migrate Motherboard Serial Number Method
Source: https://github.com/matthewking/deviceid/blob/main/readme.md
Illustrates the change from the v5 AddMotherboardSerialNumber() method to v6 OS-specific calls, available on Windows and Linux but not Mac.
```csharp
// V5:
builder.AddMotherboardSerialNumber();
// V6:
builder.OnWindows(x => x.AddMotherboardSerialNumber())
.OnLinux(x => x.AddMotherboardSerialNumber());
// not available on Mac
```
--------------------------------
### FileTokenDeviceIdComponent.GetValue
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Components.md
Retrieves the device token value. If the token file exists, its content is read and returned. If not, a new GUID is generated, written to the file, and then returned. Errors during file operations result in a null return.
```APIDOC
## GetValue()
### Description
Retrieves the device token value. If the token file exists, its content is read and returned. If not, a new GUID is generated, written to the file, and then returned. Errors during file operations result in a null return.
### Returns
string - The token value (existing file contents or newly generated GUID), or null on error.
### Behavior
- If file exists: reads and returns file contents as ASCII text
- If file does not exist: generates a new GUID, writes it to the file, returns the GUID
- Fails silently on file I/O errors (returns null)
- Token value is uppercase GUID format
```
--------------------------------
### Configuring macOS Components with OnMac Extension
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Mac.md
Illustrates the usage of the `OnMac` extension method on `DeviceIdBuilder` to configure macOS-specific device identification components. The provided action is only executed on macOS.
```csharp
public static DeviceIdBuilder OnMac(this DeviceIdBuilder builder, Action macBuilderConfiguration)
```
--------------------------------
### Generate Lightweight Registry-Based Windows Device ID
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Windows.md
This snippet generates a minimal device ID using only the Windows device ID and machine GUID, which are typically stored in the registry. It's ideal for scenarios requiring a lightweight identifier without full WMI access.
```csharp
string deviceId = new DeviceIdBuilder()
.OnWindows(windows => windows
.AddWindowsDeviceId()
.AddMachineGuid())
.ToString();
```
--------------------------------
### Using Custom Command Executors with Mac Components
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Mac.md
Shows how to specify a custom command executor, such as `CommandExecutor.Bash`, when adding macOS-specific components like platform serial number and system drive volume UUID. This allows for control over how shell commands are executed.
```csharp
var deviceId = new DeviceIdBuilder()
.OnMac(mac => mac
.AddPlatformSerialNumber(CommandExecutor.Bash)
.AddSystemDriveVolumeUUID(CommandExecutor.Bash))
.ToString();
```
--------------------------------
### Basic Device ID Generation for Validation
Source: https://github.com/matthewking/deviceid/blob/main/readme.md
Generate a device ID using machine name, user name, and MAC address for initial license checks.
```csharp
var currentDeviceId = new DeviceIdBuilder()
.AddMachineName()
.AddUserName()
.AddMacAddress()
.ToString();
var savedDeviceIdFromLicenseFile = ReadDeviceIdFromLicenseFile();
var isLicenseValid = currentDeviceId == savedDeviceIdFromLicenseFile;
```
--------------------------------
### Backward-Compatible Version Management with Multiple Builders
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/README.md
Manages device ID generation and validation across different versions using multiple builders. It allows for generating new IDs in the latest format while ensuring older IDs remain valid.
```csharp
var manager = new DeviceIdManager()
// Original format (v1)
.AddBuilder(1, builder => builder
.AddMachineName()
.AddUserName()
.AddMacAddress())
// Updated format (v2) - removes UserName, adds FileToken
.AddBuilder(2, builder => builder
.AddMachineName()
.AddMacAddress()
.AddFileToken("./token.txt"));
// Generate new IDs in v2 format
string currentId = manager.GetDeviceId();
// Old v1 IDs still validate correctly
bool isValid = manager.Validate(oldV1Id);
```
--------------------------------
### AddSqlServer Extension Method
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/SqlServer.md
Extends DeviceIdBuilder to add SQL Server specific identifier components. Requires an open SqlConnection and configuration for SQL Server components.
```csharp
public static DeviceIdBuilder AddSqlServer(
this DeviceIdBuilder builder,
SqlConnection connection,
Action sqlServerBuilderConfiguration)
```
--------------------------------
### LinuxDeviceIdBuilder
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/types.md
A fluent builder for constructing Linux-specific device ID components. Used with the OnLinux() extension method.
```csharp
namespace DeviceId
{
public class LinuxDeviceIdBuilder
{
public LinuxDeviceIdBuilder AddComponent(string name, IDeviceIdComponent component)
}
}
```
--------------------------------
### HashDeviceIdFormatter Constructor with Hasher and Encoder
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Formatters.md
Initializes HashDeviceIdFormatter with a specific byte array hasher and encoder.
```csharp
public HashDeviceIdFormatter(IByteArrayHasher byteArrayHasher, IByteArrayEncoder byteArrayEncoder)
```
--------------------------------
### AddWindowsProductId Method
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Windows.md
Adds the Windows Product ID, retrieved from the device specifications in the registry, to the device identifier.
```APIDOC
## AddWindowsProductId
### Description
Adds the Windows Product ID, which is part of the device specifications, to the device identifier. This value is retrieved from the Windows registry.
### Method Signature
```csharp
public static WindowsDeviceIdBuilder AddWindowsProductId(this WindowsDeviceIdBuilder builder)
```
### Parameters
#### Path Parameters
* None
#### Query Parameters
* None
#### Request Body
* None
### Component Name
`WindowsProductId`
### Source
Registry value `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId`
### Returns
* `WindowsDeviceIdBuilder` - The `WindowsDeviceIdBuilder` instance for method chaining.
```
--------------------------------
### macOS Platform Detection and Component Addition
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Mac.md
Demonstrates how to conditionally add macOS-specific device identification components using the `OnMac` extension. This code only executes macOS-specific logic on macOS systems.
```csharp
var deviceId = new DeviceIdBuilder()
.OnMac(mac => mac
.AddPlatformSerialNumber()
.AddSystemDriveVolumeUUID())
.ToString();
// On non-macOS platforms, macOS-specific components are skipped
```
--------------------------------
### WindowsDeviceIdBuilder
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/types.md
A fluent builder for Windows-specific device ID components.
```APIDOC
## WindowsDeviceIdBuilder
### Description
Fluent builder for Windows-specific components.
### Methods
- `WindowsDeviceIdBuilder AddComponent(string name, IDeviceIdComponent component)`: Adds a component to the builder.
```
--------------------------------
### HashDeviceIdFormatter Constructor with Hash Algorithm Factory and Encoder
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Formatters.md
Initializes HashDeviceIdFormatter using a factory function for the hash algorithm and a byte array encoder.
```csharp
public HashDeviceIdFormatter(Func hashAlgorithm, IByteArrayEncoder byteArrayEncoder)
```
--------------------------------
### AddSqlServer
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/SqlServer.md
Extends the DeviceIdBuilder to include SQL Server specific components for generating a database identifier. It requires an open SqlConnection and allows for configuration of which SQL Server properties to include.
```APIDOC
## AddSqlServer
### Description
Extends the DeviceIdBuilder to include SQL Server specific components for generating a database identifier. It requires an open SqlConnection and allows for configuration of which SQL Server properties to include.
### Method Signature
```csharp
public static DeviceIdBuilder AddSqlServer(
this DeviceIdBuilder builder,
SqlConnection connection,
Action sqlServerBuilderConfiguration)
```
### Parameters
#### Path Parameters
* None
#### Query Parameters
* None
#### Request Body
* None
### Parameters
* `builder` (`DeviceIdBuilder`) - The builder to extend.
* `connection` (`SqlConnection`) - An open SQL Server connection. Must not be null.
* `sqlServerBuilderConfiguration` (`Action`) - Action that configures SQL Server components.
### Returns
The `DeviceIdBuilder` instance for method chaining.
### Requirements
* Connection must be open
* User must have appropriate permissions to query system information
### Example
```csharp
using SqlConnection connection = new SqlConnection("Server=.;Database=MyDb;Integrated Security=true;");
connection.Open();
string databaseId = new DeviceIdBuilder()
.AddSqlServer(connection, sql => sql
.AddServerName()
.AddDatabaseName()
.AddDatabaseId())
.ToString();
```
```
--------------------------------
### OnLinux Extension
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Linux.md
Configures Linux-specific components for device identification. This extension is only invoked on Linux platforms.
```APIDOC
## OnLinux Extension
### Description
Configures Linux-specific components for device identification. This extension is only invoked on Linux platforms.
### Method Signature
`public static DeviceIdBuilder OnLinux(this DeviceIdBuilder builder, Action linuxBuilderConfiguration)`
### Parameters
#### Path Parameters
- `builder` (DeviceIdBuilder) - The builder to extend.
- `linuxBuilderConfiguration` (Action) - Action that configures Linux-specific components. Only executes on Linux.
### Returns
The `DeviceIdBuilder` instance for method chaining.
### Behavior
The action is only invoked on Linux platforms. On other platforms, it is skipped silently.
```
--------------------------------
### Default Version Encoder Format
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/DeviceIdManager.md
Illustrates the default format for encoding and decoding device IDs with versions using the '$$' pattern.
```text
- Encode: $$
- Decode: Attempts to parse as $$, returning version and device ID on success
**Example:**
- Input: $1$device-id-string
- Decoded: version=1, deviceId="device-id-string"
```
--------------------------------
### Build Cross-Platform Device ID with Linux Enhancements
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Linux.md
Constructs a cross-platform device ID that includes Linux-specific identifiers like machine ID and motherboard serial number, alongside Windows and macOS specific components.
```csharp
string deviceId = new DeviceIdBuilder()
.AddMachineName()
.AddOsVersion()
.AddMacAddress()
.OnWindows(windows => windows
.AddWindowsDeviceId())
.OnLinux(linux => linux
.AddMachineId()
.AddMotherboardSerialNumber())
.OnMac(mac => mac
.AddPlatformSerialNumber())
.ToString();
```
--------------------------------
### Platform Detection on Windows
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Windows.md
Automatically detects the Windows platform and applies Windows-specific components. On non-Windows platforms, only base components are added.
```csharp
var deviceId = new DeviceIdBuilder()
.OnWindows(windows => windows
.AddWindowsDeviceId()
.AddProcessorId())
.ToString();
// On non-Windows platforms, only adds components from the base builder
```
--------------------------------
### HashDeviceIdFormatter Constructor (hashAlgorithm, byteArrayEncoder)
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Formatters.md
Initializes a new instance of the HashDeviceIdFormatter class with a specified hash algorithm factory and byte array encoder.
```APIDOC
## HashDeviceIdFormatter(hashAlgorithm, byteArrayEncoder)
### Description
Initializes a new instance of the HashDeviceIdFormatter class with a specified hash algorithm factory and byte array encoder.
### Method
`HashDeviceIdFormatter(Func hashAlgorithm, IByteArrayEncoder byteArrayEncoder)`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
```csharp
var formatter = new HashDeviceIdFormatter(
() => SHA256.Create(),
new Base32ByteArrayEncoder(Base32ByteArrayEncoder.CrockfordAlphabet)
);
```
### Response
#### Success Response
None
#### Response Example
None
```
--------------------------------
### DeviceIdFormatters Factory Class
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Formatters.md
Provides access to pre-built default formatter instances like DefaultV5 and DefaultV6.
```csharp
public static class DeviceIdFormatters
{
public static IDeviceIdFormatter DefaultV5 { get; }
public static IDeviceIdFormatter DefaultV6 { get; }
}
```
--------------------------------
### AddBuilder (with instance)
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/DeviceIdManager.md
Registers a device ID builder for a specific version number.
```APIDOC
## AddBuilder(int version, DeviceIdBuilder builder)
### Description
Registers a device ID builder for a specific version number. The version number must be unique.
### Method
`DeviceIdManager.AddBuilder`
### Parameters
#### Parameters
- **version** (`int`) - Required - The version number for this builder (must be unique).
- **builder** (`DeviceIdBuilder`) - Required - The builder instance. Must not be null.
### Returns
The current `DeviceIdManager` instance for method chaining.
### Throws
`ArgumentNullException` if builder is null.
### Example
```csharp
var manager = new DeviceIdManager()
.AddBuilder(1, new DeviceIdBuilder()
.AddMachineName()
.AddUserName()
.AddMacAddress())
.AddBuilder(2, new DeviceIdBuilder()
.AddMachineName()
.AddMacAddress());
```
```
--------------------------------
### ToString Method
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/DeviceIdBuilder.md
Returns a string representation of the device identifier by applying the configured formatter to all components. This is the final step in generating the device ID.
```APIDOC
## ToString
Returns a string representation of the device identifier by applying the configured formatter to all components.
### Method Signature
```csharp
public override string ToString()
```
### Returns
A string representation of the device identifier based on the configured formatter and components.
### Throws
`InvalidOperationException` if the `Formatter` property is null.
### Example
```csharp
var builder = new DeviceIdBuilder()
.AddComponent("UserName", new DeviceIdComponent(Environment.UserName))
.AddComponent("MachineName", new DeviceIdComponent(Environment.MachineName));
string deviceId = builder.ToString();
```
```
--------------------------------
### Build Comprehensive Linux Device ID
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Linux.md
Constructs a comprehensive device ID for Linux systems, including machine name, OS version, machine ID, motherboard serial number, system drive serial number, and product UUID.
```csharp
string deviceId = new DeviceIdBuilder()
.AddMachineName()
.AddOsVersion()
.OnLinux(linux => linux
.AddMachineId()
.AddMotherboardSerialNumber()
.AddSystemDriveSerialNumber()
.AddProductUuid())
.ToString();
```
--------------------------------
### AddCpuInfo
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Linux.md
Adds CPU information from `/proc/cpuinfo` to the device identifier, generating a hash-based identifier from processor details.
```APIDOC
## AddCpuInfo
### Description
Adds CPU information parsed from `/proc/cpuinfo` to the device identifier. It generates a hash-based identifier from the processor details found in the file.
### Method Signature
`public static LinuxDeviceIdBuilder AddCpuInfo(this LinuxDeviceIdBuilder builder)`
### Parameters
#### Path Parameters
- `builder` (LinuxDeviceIdBuilder) - The builder.
### Returns
The `LinuxDeviceIdBuilder` instance for method chaining.
### Component Name
`CPUInfo`
### Source
`/proc/cpuinfo`
### Behavior
Parses CPU information and generates a hash-based identifier from processor details.
```
--------------------------------
### Build ARM-Based System Device ID (e.g., Raspberry Pi)
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Linux.md
Generates a device ID for ARM-based systems like Raspberry Pi, including machine name, OS version, hardware model, device serial number, and CPU information.
```csharp
string deviceId = new DeviceIdBuilder()
.AddMachineName()
.AddOsVersion()
.OnLinux(linux => linux
.AddDeviceTreeModel() // Hardware model
.AddDeviceTreeSerialNumber() // Device serial
.AddCpuInfo()) // Processor info
.ToString();
```
--------------------------------
### MacDeviceIdBuilder
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/types.md
A fluent builder for macOS-specific device ID components.
```APIDOC
## MacDeviceIdBuilder
### Description
Fluent builder for macOS-specific components.
### Methods
- `MacDeviceIdBuilder AddComponent(string name, IDeviceIdComponent component)`: Adds a component to the builder.
```
--------------------------------
### AddBuilder (with configuration)
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/DeviceIdManager.md
Registers a device ID builder using a configuration action.
```APIDOC
## AddBuilder(int version, Action builderConfiguration)
### Description
Registers a device ID builder using a configuration action. The version number must be unique.
### Method
`DeviceIdManager.AddBuilder`
### Parameters
#### Parameters
- **version** (`int`) - Required - The version number for this builder (must be unique).
- **builderConfiguration** (`Action`) - Required - An action that configures the builder.
### Returns
The current `DeviceIdManager` instance for method chaining.
### Example
```csharp
var manager = new DeviceIdManager()
.AddBuilder(1, builder => builder
.AddMachineName()
.AddUserName()
.AddMacAddress())
.AddBuilder(2, builder => builder
.AddMacAddress()
.AddFileToken("./device-id.txt"));
```
```
--------------------------------
### FileTokenDeviceIdComponent Class Definition
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Components.md
Defines the FileTokenDeviceIdComponent class, implementing the IDeviceIdComponent interface. It includes the constructor and the GetValue method signature.
```csharp
public class FileTokenDeviceIdComponent : IDeviceIdComponent
{
public FileTokenDeviceIdComponent(string path)
public string GetValue()
}
```
--------------------------------
### AddComponent Method
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/DeviceIdBuilder.md
Adds or replaces a component in the device identifier. This method is chainable, returning the current builder instance.
```APIDOC
## AddComponent
Adds or replaces a component in the device identifier.
### Method Signature
```csharp
public DeviceIdBuilder AddComponent(string name, IDeviceIdComponent component)
```
### Parameters
#### Path Parameters
* **name** (string) - Required - The component name. If a component with this name already exists, it will be replaced. Component names are case-insensitive.
* **component** (IDeviceIdComponent) - Required - The component implementation. Must not be null.
### Returns
The current `DeviceIdBuilder` instance for method chaining.
### Throws
`ArgumentNullException` if component is null.
### Example
```csharp
var builder = new DeviceIdBuilder();
builder.AddComponent("CustomId", new DeviceIdComponent("MyValue"));
```
```
--------------------------------
### Use Custom Hash Device ID Formatter
Source: https://github.com/matthewking/deviceid/blob/main/readme.md
Set a custom formatter using the UseFormatter method with a HashDeviceIdFormatter, SHA256, and Base32 encoding.
```csharp
string deviceId = new DeviceIdBuilder()
.AddMachineName()
.AddOsVersion()
.UseFormatter(new HashDeviceIdFormatter(() => SHA256.Create(), new Base32ByteArrayEncoder()))
.ToString();
```
--------------------------------
### WindowsDeviceIdBuilder
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/types.md
A fluent builder for constructing Windows-specific device ID components. Used with the OnWindows() extension method.
```csharp
namespace DeviceId
{
public class WindowsDeviceIdBuilder
{
public WindowsDeviceIdBuilder AddComponent(string name, IDeviceIdComponent component)
}
}
```
--------------------------------
### Device ID Backward-Compatible Version Management
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/README.md
Enables backward-compatible device ID validation when formats change by managing multiple builder versions. New device IDs use the latest format, but old IDs still validate.
```csharp
var manager = new DeviceIdManager()
.AddBuilder(1, builder1 => builder1.AddMachineName().AddUserName())
.AddBuilder(2, builder2 => builder2.AddMacAddress().AddFileToken("./token.txt"));
// New device IDs use v2 format, but old v1 IDs still validate
bool isValid = manager.Validate(oldDeviceId);
```
--------------------------------
### Comprehensive Hardware Fingerprint Generation
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/README.md
Generates a detailed hardware fingerprint by combining various hardware identifiers across different operating systems.
```csharp
// Comprehensive hardware fingerprint
string hardwareId = new DeviceIdBuilder()
.OnWindows(windows => windows
.AddProcessorId()
.AddMotherboardSerialNumber()
.AddSystemDriveSerialNumber())
.OnLinux(linux => linux
.AddCpuInfo()
.AddMotherboardSerialNumber()
.AddProductUuid())
.OnMac(mac => mac
.AddPlatformSerialNumber())
.ToString();
```
--------------------------------
### Build Container-Aware Linux Device ID
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Linux.md
Creates a device ID that identifies containerized instances on Linux, including machine name, Docker container ID, and machine ID.
```csharp
string deviceId = new DeviceIdBuilder()
.AddMachineName()
.OnLinux(linux => linux
.AddDockerContainerId() // Identify containerized instances
.AddMachineId())
.ToString();
```
--------------------------------
### AddCpuInfo
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Linux.md
Adds CPU information from `/proc/cpuinfo` to the device identifier. It parses processor details to generate a hash-based identifier.
```csharp
public static LinuxDeviceIdBuilder AddCpuInfo(this LinuxDeviceIdBuilder builder)
```
--------------------------------
### Implement PlainTextDeviceIdComponentEncoder
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Encoders.md
Encodes components as plain text. Use this encoder when no modification or hashing is required for component values.
```csharp
public class PlainTextDeviceIdComponentEncoder : IDeviceIdComponentEncoder
{
public PlainTextDeviceIdComponentEncoder()
public string Encode(IDeviceIdComponent component)
}
```
--------------------------------
### Normalized User and Machine Information
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/DeviceIdBuilderExtensions.md
Creates a device identifier using normalized user and machine information, including normalized username, machine name, and MAC address excluding wireless interfaces.
```csharp
string deviceId = new DeviceIdBuilder()
.AddUserName(normalize: true)
.AddMachineName()
.AddMacAddress(excludeWireless: true)
.ToString();
```
--------------------------------
### ToString
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/DeviceIdManager.md
Returns a string representation of the DeviceIdManager.
```APIDOC
## ToString()
### Description
Returns a string representation of the `DeviceIdManager` object, typically indicating its current state or configuration.
### Method
`DeviceIdManager.ToString`
### Returns
A string representation of the `DeviceIdManager`.
### Example
```csharp
var manager = new DeviceIdManager();
string managerString = manager.ToString(); // Returns a string representation
```
```
--------------------------------
### DeviceIdBuilder Constructor
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/DeviceIdBuilder.md
Initializes a new instance of the DeviceIdBuilder class with default settings. This creates a builder with an empty components dictionary and the DefaultV6 formatter.
```APIDOC
## DeviceIdBuilder()
### Description
Initializes a new instance of the `DeviceIdBuilder` class with default settings.
### Returns
A new builder instance with an empty components dictionary and the DefaultV6 formatter.
### Example
```csharp
var builder = new DeviceIdBuilder();
```
```
--------------------------------
### Device ID Manager for Versioned Formats
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/README.md
Sets up a DeviceIdManager to support multiple versions of device ID formats, enabling backward compatibility.
```csharp
var manager = new DeviceIdManager()
.AddBuilder(1, currentFormat)
.AddBuilder(2, futureFormat);
```
--------------------------------
### MacDeviceIdBuilder AddComponent Method
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/api-reference/Mac.md
Shows how to add custom macOS-specific device identification components using the `AddComponent` method of `MacDeviceIdBuilder`. This allows for fluent interface chaining.
```csharp
public MacDeviceIdBuilder AddComponent(string name, IDeviceIdComponent component)
```
--------------------------------
### MacDeviceIdBuilder
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/types.md
A fluent builder for constructing macOS-specific device ID components. Used with the OnMac() extension method.
```csharp
namespace DeviceId
{
public class MacDeviceIdBuilder
{
public MacDeviceIdBuilder AddComponent(string name, IDeviceIdComponent component)
}
}
```
--------------------------------
### SqlServerDeviceIdBuilder
Source: https://github.com/matthewking/deviceid/blob/main/_autodocs/types.md
A fluent builder for SQL Server database identifier components.
```APIDOC
## SqlServerDeviceIdBuilder
### Description
Fluent builder for SQL Server database identifier components.
### Methods
- `SqlServerDeviceIdBuilder AddComponent(string name, IDeviceIdComponent component)`: Adds a component to the builder.
- `SqlServerDeviceIdBuilder AddQueryResult(string name, string query)`: Adds a query result component.
- `SqlServerDeviceIdBuilder AddQueryResult(string name, string query, Func