public abstract class Enum<T> where T : struct, IComparable
public string Value { get; set; }
protected Enum(T id, string @value)
public sealed class Status : Enum<byte>
public static readonly Status Pending = new Status(0, "PENDING");
public static readonly Status Finished = new Status(1, "FINISHED");
private Status(byte id, string name) : base(id, name)
public static Status Create (string @value)
public static Wrapper<Status> CreateWrapper(string @value)
return Wrapper.Wrap(Finished);
public static Enum<byte> ConvertToSomething<T>() where T : struct, IComparable
public interface IWrapper<out T>
public static Wrapper<T> Wrap<T>(T @value)
return new Wrapper<T>(@value);
public class Wrapper<T> : IWrapper<T>
internal Wrapper(T @value)
public class StatusConverter<TType> : ITypeConverter<string, Enum<byte>>
public Enum<byte> Convert(string source, Enum<byte> destination, ResolutionContext context)
return Status.Create(source);
public class StatusConverter2<TValue> : ITypeConverter<string, IWrapper<Status>>
public IWrapper<Status> Convert(string source, IWrapper<Status> destination, ResolutionContext context)
return Status.CreateWrapper(source);
public class StatusConverter3<TValue> : ITypeConverter<string, IWrapper<Enum<byte>>>
public IWrapper<Enum<byte>> Convert(string source, IWrapper<Enum<byte>> destination, ResolutionContext context)
return Status.CreateWrapper(source);
public static void Main()
Enum<byte> test = Status.Finished;
Console.WriteLine("Hello World");