Table of Contents

Class FluentJsonSettings

Namespace
Nucs.JsonSettings
Assembly
Nucs.JsonSettings.dll
public static class FluentJsonSettings
Inheritance
FluentJsonSettings
Inherited Members

Methods

LoadNow<T>(T)

Performs Load on the JsonSettings, used after calling Configure(Type, string) to perform a load at the end.
Uses FileName.

public static T LoadNow<T>(this T _instance) where T : JsonSettings

Parameters

_instance T

The instance of type JsonSettings

Returns

T

Self

Type Parameters

T

LoadNow<T>(T, string)

Performs Load on the JsonSettings, used after calling Configure(Type, string) to perform a load at the end.

public static T LoadNow<T>(this T _instance, string filename) where T : JsonSettings

Parameters

_instance T

The instance of type JsonSettings

filename string

Specific file to load (ignores FileName)

Returns

T

Self

Type Parameters

T

WithBase64<T>(T)

public static T WithBase64<T>(this T _instance) where T : JsonSettings

Parameters

_instance T

Returns

T

Type Parameters

T

WithDefaultValues<T>(T, Action<T>)

Fluently do something with self.

public static T WithDefaultValues<T>(this T _instance, Action<T> @do) where T : JsonSettings

Parameters

_instance T
do Action<T>

Returns

T

Self

Type Parameters

T

WithEncryptionRawKey<T>(T, byte[])

Attaches EncryptionModule using key verbatim as the AES key, with no key derivation. The key must be 16, 24 or 32 bytes (AES-128/192/256). For callers that already hold key material; the caller owns the key's quality, since PBKDF2 stretching is skipped.

public static T WithEncryptionRawKey<T>(this T _instance, byte[] key) where T : JsonSettings

Parameters

_instance T
key byte[]

The raw AES key, 16/24/32 bytes.

Returns

T

Self

Type Parameters

T

WithEncryptionRawKey<T>(T, byte[], EncryptionAlgorithm, KeySize)

Attaches an EncryptionModule using a raw key with algorithm and keySize. The key length must match the algorithm (16/24/32 bytes for AES; 32 for ChaCha20-Poly1305). See WithEncryptionRawKey<T>(T, byte[]) and EncryptionAlgorithm.

public static T WithEncryptionRawKey<T>(this T _instance, byte[] key, EncryptionAlgorithm algorithm, KeySize keySize = KeySize.Aes256) where T : JsonSettings

Parameters

_instance T
key byte[]
algorithm EncryptionAlgorithm
keySize KeySize

Returns

T

Type Parameters

T

WithEncryptionRawKey<T>(T, Func<byte[]>)

Attaches EncryptionModule using a raw AES key resolved on demand. See WithEncryptionRawKey<T>(T, byte[]).

public static T WithEncryptionRawKey<T>(this T _instance, Func<byte[]> key) where T : JsonSettings

Parameters

_instance T
key Func<byte[]>

A fetcher for the raw AES key, 16/24/32 bytes.

Returns

T

Self

Type Parameters

T

WithEncryptionRawKey<T>(T, Func<T, byte[]>)

Attaches EncryptionModule using a raw AES key resolved from the instance on demand. See WithEncryptionRawKey<T>(T, byte[]).

public static T WithEncryptionRawKey<T>(this T _instance, Func<T, byte[]> key) where T : JsonSettings

Parameters

_instance T
key Func<T, byte[]>

A fetcher for the raw AES key, given the instance.

Returns

T

Self

Type Parameters

T

WithEncryption<T>(T, byte[])

Attaches EncryptionModule using a binary password. The bytes are stretched into a key with the same PBKDF2 construction as a text password, so this is salted and iterated - but it is a DIFFERENT credential from the text password whose UTF-8 encoding equals these bytes. To use bytes verbatim as the key instead, see WithEncryptionRawKey<T>(T, byte[]).

public static T WithEncryption<T>(this T _instance, byte[] password) where T : JsonSettings

Parameters

_instance T
password byte[]

The binary password.

Returns

T

Self

Type Parameters

T

WithEncryption<T>(T, byte[], EncryptionAlgorithm, KeySize)

Attaches an EncryptionModule using a binary password with algorithm and keySize instead of the default AES-256-CBC. See WithEncryption<T>(T, byte[]) and EncryptionAlgorithm.

public static T WithEncryption<T>(this T _instance, byte[] password, EncryptionAlgorithm algorithm, KeySize keySize = KeySize.Aes256) where T : JsonSettings

Parameters

_instance T
password byte[]
algorithm EncryptionAlgorithm
keySize KeySize

Returns

T

Type Parameters

T

WithEncryption<T>(T, Func<byte[]>)

Attaches EncryptionModule using a binary password resolved on demand. See WithEncryption<T>(T, byte[]).

public static T WithEncryption<T>(this T _instance, Func<byte[]> password) where T : JsonSettings

Parameters

_instance T
password Func<byte[]>

A fetcher for the binary password.

Returns

T

Self

Type Parameters

T

WithEncryption<T>(T, Func<SecureString>)

Attaches an EncryptionModule (AES-256-CBC by default).

public static T WithEncryption<T>(this T _instance, Func<SecureString> password) where T : JsonSettings

Parameters

_instance T
password Func<SecureString>

A fetcher/getter/generator/action-pointer to the password source

Returns

T

Self

Type Parameters

T

WithEncryption<T>(T, Func<string>)

Attaches an EncryptionModule (AES-256-CBC by default).

public static T WithEncryption<T>(this T _instance, Func<string> password) where T : JsonSettings

Parameters

_instance T
password Func<string>

A fetcher/getter/generator/action-pointer to the password source

Returns

T

Self

Type Parameters

T

WithEncryption<T>(T, Func<T, byte[]>)

Attaches EncryptionModule using a binary password resolved from the instance on demand. See WithEncryption<T>(T, byte[]).

public static T WithEncryption<T>(this T _instance, Func<T, byte[]> password) where T : JsonSettings

Parameters

_instance T
password Func<T, byte[]>

A fetcher for the binary password, given the instance.

Returns

T

Self

Type Parameters

T

WithEncryption<T>(T, Func<T, SecureString>)

Attaches an EncryptionModule (AES-256-CBC by default).

public static T WithEncryption<T>(this T _instance, Func<T, SecureString> password) where T : JsonSettings

Parameters

_instance T
password Func<T, SecureString>

A fetcher/getter/generator/action-pointer to the password source

Returns

T

Self

Type Parameters

T

WithEncryption<T>(T, Func<T, string>)

Attaches an EncryptionModule (AES-256-CBC by default).

public static T WithEncryption<T>(this T _instance, Func<T, string> password) where T : JsonSettings

Parameters

_instance T
password Func<T, string>

A fetcher/getter/generator/action-pointer to the password source

Returns

T

Self

Type Parameters

T

WithEncryption<T>(T, SecureString)

Attaches an EncryptionModule (AES-256-CBC by default).

public static T WithEncryption<T>(this T _instance, SecureString password) where T : JsonSettings

Parameters

_instance T
password SecureString

A fetcher/getter/generator/action-pointer to the password source

Returns

T

Self

Type Parameters

T

WithEncryption<T>(T, string)

Attaches an EncryptionModule (AES-256-CBC by default).

public static T WithEncryption<T>(this T _instance, string password) where T : JsonSettings

Parameters

_instance T
password string

A fetcher/getter/generator/action-pointer to the password source

Returns

T

Self

Type Parameters

T

WithEncryption<T>(T, string, EncryptionAlgorithm, KeySize)

Attaches an EncryptionModule using algorithm and keySize instead of the default AES-256-CBC. See EncryptionAlgorithm for the available algorithms and their availability per target framework.

public static T WithEncryption<T>(this T _instance, string password, EncryptionAlgorithm algorithm, KeySize keySize = KeySize.Aes256) where T : JsonSettings

Parameters

_instance T
password string

The password source.

algorithm EncryptionAlgorithm

The symmetric algorithm to use.

keySize KeySize

The AES key size (ignored by ChaCha20-Poly1305). Defaults to 256-bit.

Returns

T

Self

Type Parameters

T

WithFileName<T>(T, FileInfo)

public static T WithFileName<T>(this T _instance, FileInfo filename) where T : JsonSettings

Parameters

_instance T
filename FileInfo

Returns

T

Type Parameters

T

WithFileName<T>(T, string)

public static T WithFileName<T>(this T _instance, string filename) where T : JsonSettings

Parameters

_instance T
filename string

Returns

T

Type Parameters

T

WithModule<T>(T, Module)

Load custom made module.

public static T WithModule<T>(this T _instance, Module module) where T : JsonSettings

Parameters

_instance T

Self

module Module

The module instance

Returns

T

Self

Type Parameters

T

WithModule<T, TMod>(T, params object[])

Loads a freshly constructed module with the following arguments.

public static T WithModule<T, TMod>(this T _instance, params object[] args) where T : JsonSettings where TMod : Module

Parameters

_instance T

Self

args object[]

The arguments to fit into a constructor.

Returns

T

Self

Type Parameters

T
TMod

WithRecovery<T>(T, RecoveryAction)

RecoveryModule used to enforce a fail-safe recovery and take RecoveryAction when the json parsing fails.

public static T WithRecovery<T>(this T _instance, RecoveryAction action) where T : JsonSettings

Parameters

_instance T
action RecoveryAction

Returns

T

Type Parameters

T

WithVersioning<T>(T, VersioningResultAction, VersioningPolicyHandler?)

VersioningModule used to enforce a policy and take VersioningResultAction when the policy detects an invalid version. A policy is a VersioningPolicyHandler comparer between two Version.
This overload uses EnforcedVersionAttribute to resolve the default attribute.

public static T WithVersioning<T>(this T _instance, VersioningResultAction invalidAction, VersioningPolicyHandler? policy = null) where T : JsonSettings, IVersionable

Parameters

_instance T

the instance being configured

invalidAction VersioningResultAction

The action to take when the policy returns false

policy VersioningPolicyHandler

The version comparison policy, return true when version is OK.

Returns

T

Type Parameters

T

The settings type inheriting IVersionable

WithVersioning<T>(T, string, VersioningResultAction, VersioningPolicyHandler?)

VersioningModule used to enforce a policy and take VersioningResultAction when the policy detects an invalid version. A policy is a VersioningPolicyHandler comparer between two Version.

public static T WithVersioning<T>(this T _instance, string expectedVersion, VersioningResultAction invalidAction, VersioningPolicyHandler? policy = null) where T : JsonSettings, IVersionable

Parameters

_instance T

the instance being configured

expectedVersion string

The expected version based on given policy

invalidAction VersioningResultAction

The action to take when the policy returns false

policy VersioningPolicyHandler

The version comparison policy, return true when version is OK.

Returns

T

Type Parameters

T

The settings type inheriting IVersionable

WithVersioning<T>(T, Version, VersioningResultAction, VersioningPolicyHandler?)

VersioningModule used to enforce a policy and take VersioningResultAction when the policy detects an invalid version. A policy is a VersioningPolicyHandler comparer between two Version.

public static T WithVersioning<T>(this T _instance, Version expectedVersion, VersioningResultAction invalidAction, VersioningPolicyHandler? policy = null) where T : JsonSettings, IVersionable

Parameters

_instance T

the instance being configured

expectedVersion Version

The expected version based on given policy

invalidAction VersioningResultAction

The action to take when the policy returns false

policy VersioningPolicyHandler

The version comparison policy, return true when version is OK.

Returns

T

Type Parameters

T

The settings type inheriting IVersionable