/// <summary> /// Gets a list of role names from the .cscfg file /// </summary> public List <string> GetRoleNameList() { return(OriginalVersion.Descendants(Namespaces.NsServiceManagement + "Role") .Attributes("name") .Select(attribute => attribute.Value) .ToList()); }
/// <summary> /// Checks to see whether a particular setting exists in the roleset /// </summary> /// <param name="settingName">The name of the setting being checked</param> /// <returns>A bool as to whether the setting is present or not</returns> private XElement GetSetting(string settingName) { var setting = OriginalVersion.Descendants(name: Namespaces.NsServiceManagement + "Role").FirstOrDefault() .Descendants(Namespaces.NsServiceManagement + "Setting").FirstOrDefault( b => (string)b.Attribute("name") == settingName); return(setting); }
/// <summary> /// Gets the instance count for the role /// </summary> /// <param name="roleName">The name of the role</param> /// <returns>An XElement instance of the instance count element</returns> private XElement GetInstanceCountElementForRole(string roleName) { XElement role = OriginalVersion.Descendants(Namespaces.NsServiceManagement + "Role") .FirstOrDefault(a => (string)a.Attribute("name") == roleName); // updates the instance count number here return(role.Elements(Namespaces.NsServiceManagement + "Instances") .FirstOrDefault()); }
/// <summary> /// Gets a setting value for a role given a rolename and settings name /// </summary> public string GetSettingForRole(string settingName, string roleName) { return(OriginalVersion.Descendants(name: Namespaces.NsServiceManagement + "Role").FirstOrDefault(a => ((string)a.Attribute("name")).ToLower() == roleName.ToLower()) .Descendants(Namespaces.NsServiceManagement + "Setting").FirstOrDefault(b => (string)b.Attribute("name") == settingName) .Attribute("value").Value); }