55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
using Salmon.Core;
|
|
using System.Security.Cryptography.X509Certificates;
|
|
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 Transmitter? Transmitter { get; set; } = null;
|
|
|
|
public virtual Task<IEnumerable<Element>> ForgeElements()
|
|
{
|
|
return Task.FromResult(Enumerable.Empty<Element>());
|
|
}
|
|
|
|
public virtual void OnStart()
|
|
{
|
|
}
|
|
|
|
public virtual void OnStop()
|
|
{
|
|
}
|
|
}
|
|
|
|
public abstract class BaseFielded
|
|
: 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 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;
|
|
}
|
|
} |