XDocument ICloudConfig.ChangeConfig(XDocument document)
{
// TODO: this whole bit needs to be updated!!! It's beginning to look like a mess and can be replaced with 3-4 lines of code
document.Declaration = new XDeclaration("1.0", "utf-8", "");
foreach (string rn in _manager.RolesInstances.Keys)
{
int instanceCount = _manager.RolesInstances[rn];
XElement role = document.Descendants(Namespaces.NsServiceManagement + "Role")
.Where(a => (string) a.Attribute("name") == rn)
.FirstOrDefault();
// updates the instance count number here
role.Elements(Namespaces.NsServiceManagement + "Instances")
.FirstOrDefault()
.Attribute("count").SetValue(instanceCount.ToString());
}
return document;
}