I have been thinking the design over for a couple days now and I’m asymptotically 100% sure this is a design problem. However, here’s my predicament: I essentially want to have a compiler checked and polymorphic static classes. Specifically, I have this:
static class TileSettings
{
static class TileOne
{
public const TileType TYPE = TileType.TileOne;
}
static class TileTwo
{
public const TileType TYPE = TileType.TileTwo;
}
}
This seems fine but I would like to have the subclasses to follow a contract (like an interface) that TileOne and TileTwo could follow so that somewhere in code I could do something like the following:
public void function(TileSettings SETTINGS_TO_USE)
{
someLocalVariable = SETTINGS_TO_USE.TYPE;
}
function(TileOne);
function(TileTwo);
One major problem that sticks out to me though is that one can’t pass a static class into a function. What I could do is have a static class with methods that take a TileType and use a switch to return that types value. That seems like it would be highly inefficient, however, if it ends up being called a lot. So, any thoughts? Is there something simple I’m unaware of that would solve this? Thanks in advance for any help.
Yes, the answer is: don’t use a static class.
How about this:
You can use it like this then: