Polymorphic output in the Management API
How to support polymorphic outputs from custom Management APIs
Polymorphism by interface
public interface IMyItem
{
Guid Id { get; }
string Value { get; set; }
}public class MyItem(string value) : IMyItem
{
public Guid Id { get; } = Guid.NewGuid();
public string Value { get; set; } = value;
}public class MyOtherItem(string value, int otherValue) : IMyItem
{
public Guid Id { get; } = Guid.NewGuid();
public string Value { get; set; } = value;
public int OtherValue { get; } = otherValue;
}Polymorphism by annotation
Last updated
Was this helpful?