refactor project configurations reading code

This commit is contained in:
Vadim Lopatin 2015-02-27 12:19:20 +03:00
parent e77286941c
commit e9544d2f83
1 changed files with 8 additions and 10 deletions

View File

@ -259,20 +259,18 @@ struct ProjectConfiguration {
static ProjectConfiguration[string] load(Setting s) static ProjectConfiguration[string] load(Setting s)
{ {
ProjectConfiguration[string] res = [DEFAULT_NAME: DEFAULT]; ProjectConfiguration[string] res = [DEFAULT_NAME: DEFAULT];
if(s.map is null || "configurations" !in s.map || s.map["configurations"].array is null) Setting configs = s.objectByPath("configurations");
if(configs is null || configs.type != SettingType.ARRAY)
return res; return res;
foreach(conf; s.map["configurations"].array) foreach(conf; configs) {
{ if(!conf.isObject) continue;
if(conf.map is null || "name" !in conf.map) continue;
Type t = Type.Default; Type t = Type.Default;
if("targetType" in conf.map) { if(auto typeName = conf.getString("targetType"))
t = parseType(conf.map["targetType"].str); t = parseType(typeName);
} if (string confName = conf.getString("name"))
string confName = conf.map["name"].str;
res[confName] = ProjectConfiguration(confName, t); res[confName] = ProjectConfiguration(confName, t);
} }
return res; return res;
} }
} }