Beispiel #1
0
        private static void AddAllRolesExtensions(ExtensionAssociation[] extensionAssociations, XNamespace ns, XElement extensionConfigurationElement)
        {
            var allRolesAssociations = extensionAssociations.OfType<AllRolesExtensionAssociation>().ToArray();

            if (allRolesAssociations.Length == 0)
            {
                return;
            }

            var allRolesElement = new XElement(ns + "AllRoles");

            var children = allRolesAssociations.Select(ara =>
                new XElement(
                    ns + "Extension",
                    new XElement(ns + "Id", ara.Id),
                    new XElement(ns + "State", ara.State ?? "Enable")));

            allRolesElement.Add(children);

            extensionConfigurationElement.Add(allRolesElement);
        }
Beispiel #2
0
        private static void AddNamedRoleExtensions(ExtensionAssociation[] extensionAssociations, XNamespace ns, XElement extensionConfigurationElement)
        {
            var namedRoleAssociations = extensionAssociations.OfType<NamedRoleExtensionAssociation>().ToArray();

            if (namedRoleAssociations.Length == 0)
            {
                return;
            }

            var namedRolesElement = new XElement(ns + "NamedRoles");
            extensionConfigurationElement.Add(namedRolesElement);

            foreach (var role in namedRoleAssociations.GroupBy(nra => nra.RoleName))
            {
                var roleElement = new XElement(
                    ns + "Role",
                    new XElement(ns + "RoleName", role.Key));
                var roleExtensionsElement = new XElement(ns + "Extensions");
                roleElement.Add(roleExtensionsElement);

                namedRolesElement.Add(roleElement);

                var children = role.Select(nra =>
                    new XElement(
                        ns + "Extension",
                        new XElement(ns + "Id", nra.Id),
                        new XElement(ns + "State", nra.State ?? "Enable")));

                roleExtensionsElement.Add(children);
            }
        }
Beispiel #3
0
        private static void AddExtensionConfigurationXml(
            XContainer parentElement,
            ExtensionAssociation[] extensionAssociations)
        {
            if (extensionAssociations.Length == 0)
            {
                return;
            }

            var ns = XmlNamespaces.WindowsAzure;

            var extensionConfigurationElement = new XElement(ns + "ExtensionConfiguration");
            parentElement.Add(extensionConfigurationElement);

            AddAllRolesExtensions(extensionAssociations, ns, extensionConfigurationElement);
            AddNamedRoleExtensions(extensionAssociations, ns, extensionConfigurationElement);
        }