2018-06-29 19:52:40 +02:00
|
|
|
|
namespace Umbraco.Core.Configuration
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// This is used to supply optional/default values when using InnerTextConfigurationElement
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
2019-11-18 14:11:50 +01:00
|
|
|
|
internal class OptionalInnerTextConfigurationElement<T> : InnerTextConfigurationElement<T>
|
2018-06-29 19:52:40 +02:00
|
|
|
|
{
|
|
|
|
|
|
private readonly InnerTextConfigurationElement<T> _wrapped;
|
|
|
|
|
|
private readonly T _defaultValue;
|
|
|
|
|
|
|
|
|
|
|
|
public OptionalInnerTextConfigurationElement(InnerTextConfigurationElement<T> wrapped, T defaultValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
_wrapped = wrapped;
|
|
|
|
|
|
_defaultValue = defaultValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override T Value
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return string.IsNullOrEmpty(_wrapped.RawValue) ? _defaultValue : _wrapped.Value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|