Table of Contents

Interface IDataSourceConfiguration

Namespace
ToSic.Eav.DataSource
Assembly
ToSic.Eav.DataSources.dll

This helps a data source get configured. It manages all the properties which the data source will want to look up, as well as the LookUp engine which will perform the token resolution

[InternalApi_DoNotUse_MayChangeWithoutNotice]
public interface IDataSourceConfiguration

Properties

IsParsed

Tell us if the values have already been parsed or not. Ideal to check / avoid multiple calls to parse, which would just slow the system down.

bool IsParsed { get; }

Property Value

bool

Values

The values (and keys) used in the data source which owns this Configuration

IReadOnlyDictionary<string, string> Values { get; }

Property Value

IReadOnlyDictionary<string, string>

Methods

Get(string)

string Get(string name)

Parameters

name string

Returns

string

GetThis(string)

Get a configuration value for a specific property. Just use GetThis() and the method name (which is the key) is added automatically by the compiler.

string GetThis(string name = null)

Parameters

name string

The configuration key. Do not set this; it's auto-added by the compiler.

Returns

string

Remarks

Added in v15.04

GetThis<T>(T, string)

Get a configuration value for a specific property, or the fallback. Just use GetThis(5) and the method name (which is the key) is added automatically by the compiler.

T GetThis<T>(T fallback, string name = null)

Parameters

fallback T

Fallback value if the configuration is missing or can't be parsed into the expected data format.

name string

The configuration key. Do not set this; it's auto-added by the compiler.

Returns

T

The configuration value or the fallback.

Type Parameters

T

The data type of the result. Usually optional, because the fallback has this type so it's auto detected.

Remarks

Added in v15.04

Get<TValue>(string)

Get a configuration as a typed (converted) value. It's usually better to use the overload which also provides a fallback.

TValue Get<TValue>(string name)

Parameters

name string

Returns

TValue

Type Parameters

TValue

Get<TValue>(string, NoParamOrder, TValue)

Get a typed value but return the fallback if not found or if the conversion fails.

TValue Get<TValue>(string name, NoParamOrder noParamOrder = default, TValue fallback = default)

Parameters

name string

Name of the configuration

noParamOrder NoParamOrder

see Convention: Named Parameters

fallback TValue

Fallback value if the configuration is missing or can't be parsed into the expected data format.

Returns

TValue

Type Parameters

TValue

Parse()

Parse the values and change them so placeholders in the values are now the resolved value. This can only be called once - then the placeholder are gone. In scenarios where multiple parses are required, use the Parse(IDictionary) overload.

void Parse()

Parse(IDictionary<string, string>)

This will parse a dictionary of values and return the result. It's used to resolve the values list without actually changing the values on the configuration object, in scenarios where multiple parses will be required.

IDictionary<string, string> Parse(IDictionary<string, string> values)

Parameters

values IDictionary<string, string>

Returns

IDictionary<string, string>