private object ReadAnySetting(IDictionary dic, string file, int line, string setting, object defaultsetting, string pathseperator)
{
IDictionary cs = null;
// Split the path in an array
string[] keys = setting.Split(pathseperator.ToCharArray());
// Get the root item
object item = dic;
// Go for each item
for(int i = 0; i < keys.Length; i++)
{
// Check if the current item is of ConfigStruct type
if(item is IDictionary)
{
// Check if the key is valid
if(ValidateKey(null, keys[i].Trim(), file, line) == true)
{
// Cast to ConfigStruct
cs = (IDictionary)item;
// Check if the requested item exists
if(cs.Contains(keys[i]) == true)
{
// Set the item to the next item
item = cs[keys[i]];
}
else
{
// Key not found
// return default setting
return defaultsetting;
}
}
else
{
// Invalid key in path
// return default setting
return defaultsetting;
}
}
else
{
// Unable to go any further
// return default setting
return defaultsetting;
}
}
// Return the item
return item;
}