public ContentRewriterFeature get(GadgetSpec spec) { ContentRewriterFeature rewriterFeature = (ContentRewriterFeature)spec.getAttribute("content-rewriter"); if (rewriterFeature != null) { return(rewriterFeature); } rewriterFeature = new ContentRewriterFeature(spec, includeUrls, excludeUrls, expires, includeTags); spec.setAttribute("content-rewriter", rewriterFeature); return(rewriterFeature); }
public GadgetSpec getGadgetSpec(URI gadgetUri, bool ignoreCache) { Uri uri = Uri.fromJavaUri(gadgetUri); if (ignoreCache) { return(FetchObjectAndCache(uri, ignoreCache)); } GadgetSpec cached = HttpRuntime.Cache[gadgetUri.ToString()] as GadgetSpec; GadgetSpec spec; if (cached == null) { try { spec = FetchObjectAndCache(uri, ignoreCache); } catch (GadgetException e) { // We create this dummy spec to avoid the cost of re-parsing when a remote site is out. spec = new GadgetSpec(uri, ERROR_SPEC); spec.setAttribute(ERROR_KEY, e); HttpRuntime.Cache.Insert(uri.ToString(), spec, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(ERROR_DELAY)); } } else { spec = cached; } GadgetException exception = (GadgetException)spec.getAttribute(ERROR_KEY); if (exception != null) { throw exception; } return(spec); }