Table of Contents

Interface IGlobalConfiguration

Namespace
ToSic.Sys.Configuration
Assembly
ToSic.Sys.Core.dll

Global configuration system.

[InternalApi_DoNotUse_MayChangeWithoutNotice]
public interface IGlobalConfiguration
Extension Methods

Remarks

Should be setup as singleton. May someday be replaced by ConfigurationManager or other standard .net system.

Note that accessing any properties should happen through extension methods, which themselves ensure that default values and cleanup are done.

Methods

GetThis(string?)

Get a configuration with the same name as the calling method/property.

string? GetThis(string? key = null)

Parameters

key string

The name of the configuration key, automatically set to the calling method/property name.

Returns

string

The value of the configuration key, or null if it doesn't exist.

GetThisErrorOnNull(string?)

Get a configuration with the same name as the calling method/property, or throw an error if it doesn't exist.

string GetThisErrorOnNull(string? key = null)

Parameters

key string

The name of the configuration key, automatically set to the calling method/property name.

Returns

string

The value of the configuration key.

GetThisOrSet(Func<string>, string?)

Get a configuration with the same name as the calling method/property, or set it if it doesn't exist.

string? GetThisOrSet(Func<string> generator, string? key = null)

Parameters

generator Func<string>

A function to generate the value if it doesn't exist.

key string

The name of the configuration key, automatically set to the calling method/property name.

Returns

string

The value of the configuration key.

SetThis(string?, string?)

Set a configuration with the same name as the calling method/property.

string? SetThis(string? value, string? key = null)

Parameters

value string

The value to set.

key string

The name of the configuration key, automatically set to the calling method/property name.

Returns

string

The value of the configuration key.