2021-02-18 11:06:02 +01:00
|
|
|
|
// Copyright (c) Umbraco.
|
|
|
|
|
|
// See LICENSE for more details.
|
2014-01-23 10:41:57 +11:00
|
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
|
using Umbraco.Cms.Core.Models.Entities;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Extensions
|
2014-01-23 10:41:57 +11:00
|
|
|
|
{
|
2021-02-18 11:06:02 +01:00
|
|
|
|
public static class HaveAdditionalDataExtensions
|
2014-01-23 10:41:57 +11:00
|
|
|
|
{
|
2018-01-15 15:54:06 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets additional data.
|
|
|
|
|
|
/// </summary>
|
2022-01-21 11:43:58 +01:00
|
|
|
|
public static object? GetAdditionalDataValueIgnoreCase(this IHaveAdditionalData entity, string key, object? defaultValue)
|
2018-01-15 13:44:49 +01:00
|
|
|
|
{
|
2018-01-15 15:54:06 +01:00
|
|
|
|
if (!entity.HasAdditionalData) return defaultValue;
|
2022-01-21 11:43:58 +01:00
|
|
|
|
if (entity.AdditionalData?.ContainsKeyIgnoreCase(key) == false) return defaultValue;
|
|
|
|
|
|
return entity.AdditionalData?.GetValueIgnoreCase(key, defaultValue);
|
2018-01-15 13:44:49 +01:00
|
|
|
|
}
|
2014-08-13 09:38:40 +02:00
|
|
|
|
}
|
2017-07-20 11:21:28 +02:00
|
|
|
|
}
|