/// <summary> /// Class constructor /// </summary> /// <param name="unresolvedUri">unresolved help content URI</param> /// <param name="cultures">supported UI cultures</param> internal UpdatableHelpInfo(string unresolvedUri, CultureSpecificUpdatableHelp[] cultures) { Debug.Assert(cultures != null); UnresolvedUri = unresolvedUri; HelpContentUriCollection = new Collection<UpdatableHelpUri>(); UpdatableHelpItems = cultures; }
internal UpdatableHelpInfo CreateHelpInfo(string xml, string moduleName, Guid moduleGuid, string currentCulture, string pathOverride, bool verbose) { XmlDocument document = null; try { document = this.CreateValidXmlDocument(xml, HelpInfoXmlNamespace, HelpInfoXmlSchema, new ValidationEventHandler(this.HelpInfoValidationHandler), true); } catch (XmlException exception) { throw new UpdatableHelpSystemException("HelpInfoXmlValidationFailure", exception.Message, ErrorCategory.InvalidData, null, exception); } string resolvedUri = pathOverride; string innerText = document["HelpInfo"]["HelpContentURI"].InnerText; if (string.IsNullOrEmpty(pathOverride)) { resolvedUri = this.ResolveUri(innerText, verbose); } XmlNodeList childNodes = document["HelpInfo"]["SupportedUICultures"].ChildNodes; CultureSpecificUpdatableHelp[] cultures = new CultureSpecificUpdatableHelp[childNodes.Count]; for (int i = 0; i < childNodes.Count; i++) { cultures[i] = new CultureSpecificUpdatableHelp(new CultureInfo(childNodes[i]["UICultureName"].InnerText), new Version(childNodes[i]["UICultureVersion"].InnerText)); } UpdatableHelpInfo info = new UpdatableHelpInfo(innerText, cultures); if (!string.IsNullOrEmpty(currentCulture)) { WildcardOptions options = WildcardOptions.CultureInvariant | WildcardOptions.IgnoreCase; IEnumerable <WildcardPattern> patterns = SessionStateUtilities.CreateWildcardsFromStrings(new string[] { currentCulture }, options); for (int j = 0; j < cultures.Length; j++) { if (SessionStateUtilities.MatchesAnyWildcardPattern(cultures[j].Culture.Name, patterns, true)) { info.HelpContentUriCollection.Add(new UpdatableHelpUri(moduleName, moduleGuid, cultures[j].Culture, resolvedUri)); } } } if (!string.IsNullOrEmpty(currentCulture) && (info.HelpContentUriCollection.Count == 0)) { throw new UpdatableHelpSystemException("HelpCultureNotSupported", StringUtil.Format(HelpDisplayStrings.HelpCultureNotSupported, currentCulture, info.GetSupportedCultures()), ErrorCategory.InvalidOperation, null, null); } return(info); }
internal UpdatableHelpInfo CreateHelpInfo(string xml, string moduleName, Guid moduleGuid, string currentCulture, string pathOverride, bool verbose) { XmlDocument document = null; try { document = this.CreateValidXmlDocument(xml, HelpInfoXmlNamespace, HelpInfoXmlSchema, new ValidationEventHandler(this.HelpInfoValidationHandler), true); } catch (XmlException exception) { throw new UpdatableHelpSystemException("HelpInfoXmlValidationFailure", exception.Message, ErrorCategory.InvalidData, null, exception); } string resolvedUri = pathOverride; string innerText = document["HelpInfo"]["HelpContentURI"].InnerText; if (string.IsNullOrEmpty(pathOverride)) { resolvedUri = this.ResolveUri(innerText, verbose); } XmlNodeList childNodes = document["HelpInfo"]["SupportedUICultures"].ChildNodes; CultureSpecificUpdatableHelp[] cultures = new CultureSpecificUpdatableHelp[childNodes.Count]; for (int i = 0; i < childNodes.Count; i++) { cultures[i] = new CultureSpecificUpdatableHelp(new CultureInfo(childNodes[i]["UICultureName"].InnerText), new Version(childNodes[i]["UICultureVersion"].InnerText)); } UpdatableHelpInfo info = new UpdatableHelpInfo(innerText, cultures); if (!string.IsNullOrEmpty(currentCulture)) { WildcardOptions options = WildcardOptions.CultureInvariant | WildcardOptions.IgnoreCase; IEnumerable<WildcardPattern> patterns = SessionStateUtilities.CreateWildcardsFromStrings(new string[] { currentCulture }, options); for (int j = 0; j < cultures.Length; j++) { if (SessionStateUtilities.MatchesAnyWildcardPattern(cultures[j].Culture.Name, patterns, true)) { info.HelpContentUriCollection.Add(new UpdatableHelpUri(moduleName, moduleGuid, cultures[j].Culture, resolvedUri)); } } } if (!string.IsNullOrEmpty(currentCulture) && (info.HelpContentUriCollection.Count == 0)) { throw new UpdatableHelpSystemException("HelpCultureNotSupported", StringUtil.Format(HelpDisplayStrings.HelpCultureNotSupported, currentCulture, info.GetSupportedCultures()), ErrorCategory.InvalidOperation, null, null); } return info; }
/// <summary> /// Creates a HelpInfo object /// </summary> /// <param name="xml">XML text</param> /// <param name="moduleName">module name</param> /// <param name="moduleGuid">module GUID</param> /// <param name="currentCulture">current UI cultures</param> /// <param name="pathOverride">overrides the path contained within HelpInfo.xml</param> /// <param name="verbose"></param> /// <param name="shouldResolveUri"> /// Resolve the uri retrieved from the <paramref name="xml"/> content. The uri is resolved /// to handle redirections if any. /// </param> /// <param name="ignoreValidationException">ignore the xsd validation exception and return null in such case</param> /// <returns>HelpInfo object</returns> internal UpdatableHelpInfo CreateHelpInfo(string xml, string moduleName, Guid moduleGuid, string currentCulture, string pathOverride, bool verbose, bool shouldResolveUri, bool ignoreValidationException) { XmlDocument document = null; try { document = CreateValidXmlDocument(xml, HelpInfoXmlNamespace, HelpInfoXmlSchema, #if !CORECLR new ValidationEventHandler(HelpInfoValidationHandler), #endif true); } catch (UpdatableHelpSystemException e) { if (ignoreValidationException && HelpInfoXmlValidationFailure.Equals(e.FullyQualifiedErrorId, StringComparison.Ordinal)) { return null; } throw; } catch (XmlException e) { if (ignoreValidationException) { return null; } throw new UpdatableHelpSystemException(HelpInfoXmlValidationFailure, e.Message, ErrorCategory.InvalidData, null, e); } string uri = pathOverride; string unresolvedUri = document["HelpInfo"]["HelpContentURI"].InnerText; if (String.IsNullOrEmpty(pathOverride)) { if (shouldResolveUri) { uri = ResolveUri(unresolvedUri, verbose); } else { uri = unresolvedUri; } } XmlNodeList cultures = document["HelpInfo"]["SupportedUICultures"].ChildNodes; CultureSpecificUpdatableHelp[] updatableHelpItem = new CultureSpecificUpdatableHelp[cultures.Count]; for (int i = 0; i < cultures.Count; i++) { updatableHelpItem[i] = new CultureSpecificUpdatableHelp( new CultureInfo(cultures[i]["UICultureName"].InnerText), new Version(cultures[i]["UICultureVersion"].InnerText)); } UpdatableHelpInfo helpInfo = new UpdatableHelpInfo(unresolvedUri, updatableHelpItem); if (!String.IsNullOrEmpty(currentCulture)) { WildcardOptions wildcardOptions = WildcardOptions.IgnoreCase | WildcardOptions.CultureInvariant; IEnumerable<WildcardPattern> patternList = SessionStateUtilities.CreateWildcardsFromStrings(new string[1] { currentCulture }, wildcardOptions); for (int i = 0; i < updatableHelpItem.Length; i++) { if (SessionStateUtilities.MatchesAnyWildcardPattern(updatableHelpItem[i].Culture.Name, patternList, true)) { helpInfo.HelpContentUriCollection.Add(new UpdatableHelpUri(moduleName, moduleGuid, updatableHelpItem[i].Culture, uri)); } } } if (!String.IsNullOrEmpty(currentCulture) && helpInfo.HelpContentUriCollection.Count == 0) { // throw exception throw new UpdatableHelpSystemException("HelpCultureNotSupported", StringUtil.Format(HelpDisplayStrings.HelpCultureNotSupported, currentCulture, helpInfo.GetSupportedCultures()), ErrorCategory.InvalidOperation, null, null); } return helpInfo; }
internal UpdatableHelpInfo(string unresolvedUri, CultureSpecificUpdatableHelp[] cultures) { this._unresolvedUri = unresolvedUri; this._helpContentUriCollection = new Collection<UpdatableHelpUri>(); this._updatableHelpItems = cultures; }