I want to create a configuration for my application using static classes.
First, forgive my ignorance, I'm not a full-time C # dev. I come from the world of Ruby / Javascript, where dynamic access to constants and variables is trivial.
Is this the right approach here, I'm not 100% right now. Other suggested approaches would be helpful.
I have the following static class setting for my config:
public static class Config
{
public static class MaterialQuality
{
public static class Low
{
public const float Value = 0.1f;
public const int Cost = 10;
}
public static class Medium
{
public const float Value = 0.2f;
public const int Cost = 20;
}
public static class High
{
public const float Value = 0.2f;
public const int Cost = 40;
}
}
}
Then I have a class Materialto which the enumeration value relating to types is transferred Low,Medium,High. The reason for enumunity is that it provides a quick way for developers to provide level developers with a list of options for an object.
, , , , . .
- Cost Value MaterialQuality.
public enum MaterialQuality
{
Low,Medium,High
}
public class Material
{
private int Cost;
private float Value;
Material(MaterialQuality quality) {
Cost = Config.MaterialQuality.<quality>.Cost;
Value = Config.MaterialQuality.<quality>.Value;
Cost = Config.MaterialQuality[quality].Cost;
Cost = Config.MaterialQuality.const_get(quality).Cost
}
}
. , intellisense.