Пример #1
0
        /// <summary>
        /// Gets the XML for an ESD controlled list or mapping, cacheing it if possible
        /// </summary>
        /// <param name="configKey">Key for XML file name &lt;Escc.Web.Metadata/ControlledListXml&gt; section of web.config</param>
        /// <param name="withDom">true to include DOM and XPath support; false for XPath only</param>
        /// <returns>Populated XML document, or null if not found</returns>
        public static EsdXmlDocument GetEsdDocument(string configKey, bool withDom)
        {
            // TODO: Ideally this would check the format of the file to decide, but as a quick fix
            // just check whether the key includes the word "mapping"

            NameValueCollection config = ConfigurationManager.GetSection("Escc.Web.Metadata/ControlledListXml") as NameValueCollection;

            if (config == null)
            {
                config = ConfigurationManager.GetSection("EsccWebTeam.Egms/ControlledListXml") as NameValueCollection;
            }
            if (config == null)
            {
                config = ConfigurationManager.GetSection("egmsXml") as NameValueCollection;
            }
            if (config != null)
            {
                if (configKey.ToLower(CultureInfo.CurrentCulture).IndexOf("mapping") > -1)
                {
                    return(EsdMapping.GetMapping(configKey, withDom));
                }
                else
                {
                    return(EsdControlledList.GetControlledList(configKey, withDom));
                }
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        /// Gets the XML for an ESD controlled list or mapping, cacheing it if possible
        /// </summary>
        /// <param name="xmlFileUri">The URI of the XML file.</param>
        /// <param name="withDom">true to include DOM and XPath support; false for XPath only</param>
        /// <returns>Populated XML document, or null if not found</returns>
        /// <exception cref="FileNotFoundException">Thrown if the file doesn't exist</exception>
        /// <exception cref="XmlException">Thrown if the file isn't XML</exception>
        /// <exception cref="ArgumentException">Thrown if the file isn't recognised as ESD Taxonomy XML</exception>
        public static EsdXmlDocument GetEsdDocument(Uri xmlFileUri, bool withDom)
        {
            Type documentType = EsdXmlDocument.GetEsdDocumentType(xmlFileUri);

            if (documentType == typeof(EsdControlledList))
            {
                return(EsdControlledList.GetControlledList(xmlFileUri, withDom));
            }
            else if (documentType == typeof(EsdMapping))
            {
                return(EsdMapping.GetMapping(xmlFileUri, withDom));
            }

            // Need this to compile. Shouldn't ever return null, because if neither of those two match an exception should have been thrown
            return(null);
        }
Пример #3
0
 /// <summary>
 /// Gets the XML for an ESD list-to-list mapping, cacheing it if possible
 /// </summary>
 /// <param name="configKey">Key for XML file name &lt;Escc.Web.Metadata/ControlledListXml&gt; section of web.config</param>
 /// <returns>Populated XML document, or null if not found</returns>
 public static EsdMapping GetMapping(string configKey)
 {
     return(EsdMapping.GetMapping(configKey, false));
 }
Пример #4
0
 /// <summary>
 /// Gets the XML for an ESD list-to-list mapping, cacheing it if possible
 /// </summary>
 /// <param name="xmlFileUri">The URI of the XML file.</param>
 /// <returns>Populated XML document, or null if not found</returns>
 public static EsdMapping GetMapping(Uri xmlFileUri)
 {
     return(EsdMapping.GetMapping(xmlFileUri, false));
 }