Is this possible!!?!?!?!?
I'm trying to make a set of classes that model a number of different types of things. Properties of these things change over time, and I want my code to be easy to maintain, so I want to do something like the following:
public class Cat
{
public string CatName { get; set; }
public Cat()
{
this.CatName = MAGICSTUFF.GetInstanceName(this);
}
}
Somewhere else, when I want to get at those cats, I want to be able to say:
[TestMethod]
public void test_awesome_cats()
{
Cat Tiger = new Cat();
Assert.IsTrue(Tiger.CatName.Equals("Tiger"));
}
So, I'm trying to map my naming convention into object properties. The part I can't figure out is the MAGICSTUFF.GetInstanceName. Is that a thing?
I suspect this is impossible, so if that's the case hopefully somebody can give me some other ideas on clever ways to use convention for this type of scenario. I've been thinking of using attributes for the Cat class for a while, but I like this was a lot better if its possible.