public static bool TryFormatCreativeCommonsExtension(CreativeCommonsExtension extensionToFormat, XNamespaceAliasSet namespaceAliases, out IList <XElement> elements)
        {
            elements = default;

            if (extensionToFormat == null)
            {
                return(false);
            }

            elements = new List <XElement>();

            foreach (var licenseToFormat in extensionToFormat.Licenses)
            {
                if (TryFormatCreativeCommonsTextElement(licenseToFormat, namespaceAliases, out var licenseElement))
                {
                    elements.Add(licenseElement);
                }
            }

            if (!elements.Any())
            {
                return(false);
            }

            return(true);
        }
Exemple #2
0
        public static bool TryParseCreativeCommonsExtension(XElement parentElement, out CreativeCommonsExtension extension)
        {
            extension = null;

            if (parentElement == null)
            {
                return(false);
            }

            foreach (var ns in CreativeCommonsExtensionConstants.RecognizedNamespaces)
            {
                foreach (var licenseElement in parentElement.Elements(ns + "license"))
                {
                    if (TryParseCreativeCommonsLicenseElement(licenseElement, out var parsedLicense))
                    {
                        extension = extension ?? new CreativeCommonsExtension();
                        extension.Licenses.Add(parsedLicense);
                    }
                }
            }

            return(extension != null);
        }