Files
Umbraco-CMS/src/Umbraco.Core/Configuration/OptionalInnerTextConfigurationElement.cs

24 lines
818 B
C#
Raw Normal View History

2017-07-20 11:21:28 +02:00
namespace Umbraco.Core.Configuration
2013-11-07 17:16:22 +01:00
{
/// <summary>
/// This is used to supply optional/default values when using InnerTextConfigurationElement
/// </summary>
/// <typeparam name="T"></typeparam>
internal class OptionalInnerTextConfigurationElement<T> : InnerTextConfigurationElement<T>
{
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; }
}
}
2017-07-20 11:21:28 +02:00
}