public string Generate(HelpSource hs, string id, Dictionary <string, string> context) { string specialPage; if (context != null && context.TryGetValue("specialpage", out specialPage) && specialPage == "master-root") { return(GenerateMasterRootPage(hs != null ? hs.RootTree : null)); } if (hs == null || string.IsNullOrEmpty(id)) { return(MakeHtmlError(string.Format("Your request has found no candidate provider [hs=\"{0}\", id=\"{1}\"]", hs == null ? "(null)" : hs.Name, id ?? "(null)"))); } var cache = defaultCache ?? hs.Cache; if (cache != null && cache.IsCached(MakeCacheKey(hs, id, null))) { return(cache.GetCachedString(MakeCacheKey(hs, id, null))); } IEnumerable <string> parts; if (hs.IsMultiPart(id, out parts)) { return(GenerateMultiPart(hs, parts, id, context)); } if (hs.IsRawContent(id)) { return(hs.GetText(id) ?? string.Empty); } DocumentType type = hs.GetDocumentTypeForId(id); if (cache != null && context != null && cache.IsCached(MakeCacheKey(hs, id, context))) { return(cache.GetCachedString(MakeCacheKey(hs, id, context))); } IHtmlExporter exporter; if (!converters.TryGetValue(type, out exporter)) { return(MakeHtmlError(string.Format("Input type '{0}' not supported", type.ToString()))); } var result = hs.IsGeneratedContent(id) ? exporter.Export(hs.GetCachedText(id), context) : exporter.Export(hs.GetCachedHelpStream(id), context); if (cache != null) { cache.CacheText(MakeCacheKey(hs, id, context), result); } return(result); }
public bool Generate(HelpSource hs, string id) { LastCheckMessage = string.Format("#1 : {0} {1}", hs, id); if (hs == null || string.IsNullOrEmpty(id)) { return(false); } // Stripe the arguments parts since we don't need it var argIdx = id.LastIndexOf('?'); if (argIdx != -1) { id = id.Substring(0, argIdx); } LastCheckMessage = string.Format("#2 : {0} {1}", hs, id); if (hs.IsRawContent(id)) { return(hs.GetText(id) != null); } IEnumerable <string> parts; if (hs.IsMultiPart(id, out parts)) { LastCheckMessage = string.Format("#4 : {0} {1} ({2})", hs, id, string.Join(", ", parts)); foreach (var partId in parts) { if (!Generate(hs, partId)) { return(false); } } } LastCheckMessage = string.Format("#3 : {0} {1}", hs, id); if (hs.IsGeneratedContent(id)) { return(hs.GetCachedText(id) != null); } else { var s = hs.GetCachedHelpStream(id); if (s != null) { s.Close(); return(true); } else { return(false); } } }
public string Generate(HelpSource hs, string id) { if (hs == null || string.IsNullOrEmpty(id)) { return(MakeHtmlError("Your request has found no candidate provider")); } var cache = defaultCache ?? hs.Cache; if (cache != null && cache.IsCached(MakeCacheKey(hs, id, null))) { return(cache.GetCachedString(MakeCacheKey(hs, id, null))); } IEnumerable <string> parts; if (hs.IsMultiPart(id, out parts)) { return(GenerateMultiPart(hs, parts, id)); } if (hs.IsRawContent(id)) { return(hs.GetText(id) ?? string.Empty); } Dictionary <string, string> extraParams = null; DocumentType type = hs.GetDocumentTypeForId(id, out extraParams); if (cache != null && extraParams != null && cache.IsCached(MakeCacheKey(hs, id, extraParams))) { return(cache.GetCachedString(MakeCacheKey(hs, id, extraParams))); } IHtmlExporter exporter; if (!converters.TryGetValue(type, out exporter)) { return(MakeHtmlError(string.Format("Input type '{0}' not supported", type.ToString()))); } var result = hs.IsGeneratedContent(id) ? exporter.Export(hs.GetCachedText(id), extraParams) : exporter.Export(hs.GetCachedHelpStream(id), extraParams); if (cache != null) { cache.CacheText(MakeCacheKey(hs, id, extraParams), result); } return(result); }
public string Generate(HelpSource hs, string id, Dictionary <string, string> context) { if (hs == null || string.IsNullOrEmpty(id)) { return(null); } IEnumerable <string> parts; if (hs.IsMultiPart(id, out parts)) { return(GenerateMultiPart(hs, parts, id, context)); } if (hs.IsRawContent(id)) { return(hs.GetText(id) ?? string.Empty); } var result = hs.IsGeneratedContent(id) ? hs.GetCachedText(id) : new StreamReader(hs.GetCachedHelpStream(id)).ReadToEnd(); return(result); }