For context:
I'm trying to not rely on a collection to store "Command" type because of the overhead of iteration when i want to get one
Here what i am trying to do is to do so when ever i instantiate any child class of "Command", the base constructor will get Id and Fields from the static instance of that command, the problem is that i would have thought that i could pass "this" to Registery but unless i pass it the type MyCommand explicitly it wont work with this.GetType()
public static class Registery<T>
where T : Command
{
public static T instance;
}
public abstract class Command
{
public int Id { get; protected set; }
private FieldInfo[] Fields { get; protected set; }
public Command()
{
Id = Registery<this.GetType()>.instance.Id; <<<-- doesn't work
Fields = Registery<MyCommand>.instance.Fields; <<<-- works
}
}
public class MyCommand: Command
{
}
What am i doing wrong ?