Hi. I develop next application parameters storing paradigm:
There is enum for each parameter roles
enum ParameterRole
{
FileName,
FileDir
}
Parameters are contained in special container as object
class ParamContainer : Dictionary(ParameterRole, object) {
public new object this[ParameterRole role]
{
get
{
if (base.ContainsKey(role))
{
return base[role];
}
else
{
return null;
}
}
set
{
if (base.ContainsKey(role))
{
base[role] = value;
}
else
{
base.Add(role, value);
}
}
}
}
It's private member of AppSettings class
class AppSettings {
ParamContainer container = new ParamContainer();
public string FileName
{
get
{
return container[ParemeterRole.FileName] as string;
}
set
{
container[ParemeterRole.FileName] = value;
}
}
}
and for each settings there is a corresponding property, but it works not with a local variable, but adds/gets a value from the container.
What benefits? You can work with parameters separately as named property, so as list (container.Keys, container.Values) - it's useful for SQL queries and XML based business logic. What deficiencies? Parameter values are stored as object and it uses more memory as it could, I guess, if was stored as it's corresponding types.
What do you think about it? It's very interesting and important for me. Is it rubbish or could be useful?