YamlDotNet
YamlDotNet copied to clipboard
Overriding the name of a type dynamically
I'm playing around with building a class that will model how the OpenTelemetry Collector's config works.
Specifically, they have a format that takes a list of components, but does them as Objects
receivers:
otlp/1:
<stuff>
otlp/2:
<stuff>
What I want to be able to do is represent that as a list in code (since the OTLP and OTLP/2 objects are the same thing.
So what I want to do is "just" override the name part, and the rendering of the List as a objects.
The classes will look something like this:
public class Config
{
public List<Receivers> Receivers { get; } = [];
}
public abstract class Receiver
{
public abstract string ReceiverType;
public string ReceiverName;
}
Is this possible, I've been struggling to make it work.