void LoadProjectConfigurations(JsonData document)
{
var projectConfigurations = new List<ProjectFileConfiguration>();
var projectsNode = document[ProjectsSectionKeys.ProjectsKey];
foreach (JsonData projectNode in projectsNode)
{
var projectTypeName = projectNode[ProjectsSectionKeys.NameKey].ToString();
var config = new ProjectFileConfiguration
{
Name = projectTypeName,
TargetFrameworkVersion = projectNode[ProjectsSectionKeys.TargetFrameworkKey].ToString(),
CompilationConstants = projectNode[ProjectsSectionKeys.DefineConstantsKey].ToString(),
BinSubFolder = projectNode[ProjectsSectionKeys.BinSubFolderKey].ToString(),
Template = projectNode[ProjectsSectionKeys.TemplateKey].ToString(),
NuGetTargetPlatform = projectNode[ProjectsSectionKeys.NuGetTargetFrameworkKey] == null ? string.Empty : projectNode[ProjectsSectionKeys.NuGetTargetFrameworkKey].ToString()
};
config.Configurations = (from object bc in projectNode[ProjectsSectionKeys.ConfigurationsKey]
select bc.ToString()).ToList();
config.PlatformCodeFolders = (from object pcf in projectNode[ProjectsSectionKeys.PlatformCodeFoldersKey]
select pcf.ToString()).ToList();
var extraTestProjects = projectNode.SafeGet(ProjectsSectionKeys.ExtraTestProjects);
if (extraTestProjects == null)
{
config.ExtraTestProjects = new List<string>();
}
else
{
config.ExtraTestProjects = (from object etp in extraTestProjects
select etp.ToString()).ToList();
}
// This code assumes that the parent profile (project configuration) is defined in the manifest
// before it's being referred by a sub profile.
if (projectNode.PropertyNames.Contains(ProjectsSectionKeys.ParentProfile))
{
var parentProfileName = projectNode[ProjectsSectionKeys.ParentProfile].ToString();
if (!string.IsNullOrEmpty(parentProfileName))
{
var parentProfile = projectConfigurations.SingleOrDefault(
p => p.Name.Equals(parentProfileName, StringComparison.InvariantCulture));
if (parentProfile == null)
{
throw new KeyNotFoundException(string.Format("Parent profile {0} referred by current profile {1} does not exist.",
parentProfile, config.Name));
}
config.ParentProfile = parentProfile;
}
}
projectConfigurations.Add(config);
}
ProjectFileConfigurations = projectConfigurations;
}