2021-03-22 12:09:25 -04:00
|
|
|
|
using Data.Abstractions;
|
2020-04-25 20:01:26 -04:00
|
|
|
|
using System.Collections.Concurrent;
|
2017-11-25 20:29:58 -05:00
|
|
|
|
|
2021-03-22 12:09:25 -04:00
|
|
|
|
namespace Data.Models
|
2017-11-25 20:29:58 -05:00
|
|
|
|
{
|
2020-04-25 20:01:26 -04:00
|
|
|
|
public class SharedEntity : IPropertyExtender
|
2017-11-25 20:29:58 -05:00
|
|
|
|
{
|
2020-04-25 20:01:26 -04:00
|
|
|
|
private readonly ConcurrentDictionary<string, object> _additionalProperties;
|
|
|
|
|
|
2019-11-25 13:05:12 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// indicates if the entity is active
|
|
|
|
|
/// </summary>
|
2018-09-12 20:53:11 -04:00
|
|
|
|
public bool Active { get; set; } = true;
|
2019-11-25 13:05:12 -05:00
|
|
|
|
|
2020-04-25 20:01:26 -04:00
|
|
|
|
public SharedEntity()
|
|
|
|
|
{
|
|
|
|
|
_additionalProperties = new ConcurrentDictionary<string, object>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T GetAdditionalProperty<T>(string name)
|
|
|
|
|
{
|
|
|
|
|
return _additionalProperties.ContainsKey(name) ? (T)_additionalProperties[name] : default;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetAdditionalProperty(string name, object value)
|
|
|
|
|
{
|
|
|
|
|
if (_additionalProperties.ContainsKey(name))
|
|
|
|
|
{
|
|
|
|
|
_additionalProperties[name] = value;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_additionalProperties.TryAdd(name, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-11-25 20:29:58 -05:00
|
|
|
|
}
|
|
|
|
|
}
|