Table of Contents

Class AppConfigsLoader

Namespace
VpnHood.AppLib.App.Utils
Assembly
VpnHood.AppLib.App.dll

Provides a product's settings from the settings files its project embeds from the private .user folder.

public static class AppConfigsLoader
Inheritance
AppConfigsLoader
Inherited Members

Methods

Load<T>()

Creates a product's settings and fills them from the embedded AppSettings.json, then AppSettings_Environment.json, the build configuration's: each overrides by name and skips a key the type does not have.

[DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties, typeof(AppLinks))]
public static T Load<T>() where T : AppConfigs, new()

Returns

T

The settings.

Type Parameters

T

The product's settings type, in the assembly that embeds the files.

Remarks

Both files are optional: a fork without them builds, and its settings keep their defaults. The type's public properties, and those of AppLinks, are kept for the trimmer, as only reflection sets them.

Exceptions

JsonException

A file is not JSON, or a value does not fit its property.

InvalidOperationException

A JSON value is not of the kind its property needs.

UriFormatException

A Uri property's text is not a URI.

ReadResourceText(Assembly, string)

Reads a text file a project embedded, such as a secret.

public static string? ReadResourceText(Assembly assembly, string resourceName)

Parameters

assembly Assembly

The assembly that embeds it.

resourceName string

The embedded resource's name.

Returns

string

The file's text, or null when this build has no such file.