37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using Salmon.Core;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Salmon.Service.Watchers;
|
|
|
|
[JsonPolymorphic(
|
|
TypeDiscriminatorPropertyName = "Type"
|
|
, UnknownDerivedTypeHandling = JsonUnknownDerivedTypeHandling.FailSerialization)
|
|
]
|
|
[JsonDerivedType(typeof(Executable), typeDiscriminator: "executable")]
|
|
[JsonDerivedType(typeof(WebStatus), typeDiscriminator: "web")]
|
|
[JsonDerivedType(typeof(Docker), typeDiscriminator: "docker")]
|
|
public abstract class Base
|
|
{
|
|
public string? UniqueId { get; set; }
|
|
public string? ShortName { get; set; }
|
|
public string? LongName { get; set; }
|
|
public string? Description { get; set; }
|
|
public string? ParentId { get; set; } = null;
|
|
|
|
public abstract Task<IEnumerable<Element>> ForgeElements();
|
|
|
|
public void ApplyField(Element e)
|
|
{
|
|
if(ShortName is not null)
|
|
e.ShortName = ShortName;
|
|
|
|
if(LongName is not null)
|
|
e.LongName = LongName;
|
|
|
|
if(Description is not null)
|
|
e.Description = Description;
|
|
|
|
if(ParentId is not null)
|
|
e.ParentId = ParentId;
|
|
}
|
|
} |