Hi KenJohnson,
First of all thanks for really try to undertand the problem. It is sad to see that most of the people don't even read the question to the end or do not spend a second to try to view the larger picture.
For those short minded a few words:
1 - By using the derived class as a generic of the base class you can actually simulate the chaining of the instance constructors. Look for the term SIMULATE! I realy do not need the constructor of the base class (Base) to be called. Just the one from Base class which is not the same class as Base. And I just need it to be called once because (as I pointed cleared in the question) I will ONLY USE the static propereties and methods of the class.
2 - Singleton or Sealed classes do not solve the problem. I want to reuse the class and be able to inherit from it.
3 - I'm already using reflection. PLEASE read the code!!!
4 - Yes!! Type inheritance is possible! Not only instanciated objects. I proved that in the sample I put in the end of the question. It's works perfectly.
5 - If I could write the name of the class in the static constructors I would not have all that problem, would I? Come on! You are smarter than that.
Now...
Imagine that the base class is declared in a Assembly and the derived class is writen in other.
And jus to blow out your minds, I will hust give a taste of this potential (ATTENTION: I'M NOT GIVEN ALL THE CODE THAT MAKES THAT IMPLEMENTATION POSSIBLE...)
[Flags]
enum Animals
{
Squid = 0,
Lizard = 1,
Giraffe = 2,
Dog = 4,
}
class Animal : CategorizedEnum<Animal, Animals>
{
public class Invertebrate
{
public Animals Squid;
}
public class Vertebrate
{
public class Reptile
{
public Animals Lizard;
}
public class Mamal
{
public Animals Giraffe;
public Animals Dog;
}
}
}
var myAnimal = Animal.Vertebrate.Mamal.Giraffe;
Assert.AreEqual(Animals.Giraffe, myAnimal);
Assert.AreEqual(Animals.Giraffe | Animals.Dog, Animal.Vertebrate.Mamal);
Assert.AreEqual("Animal_Vertebrate_Mamal_Giraffe_Name", Animal.Vertebrate.Mamal.Giraffe.ResourceKey("Name"));
Assert.IsNotNull(Animal.Vertebrate.Mamal.Giraffe.Resource("Icon"));
That code is just an extract of the full implementation, but it WORKS!
It uses a lot of reflection, abstracts and operators overriding but the final result very good.
I just want make it more elegant.
Regards
Andre