internal override void ProcessOutputCacheDirective(string directiveName, IDictionary directive) { bool val = false; string andRemoveNonEmptyAttribute = System.Web.UI.Util.GetAndRemoveNonEmptyAttribute(directive, "varybycontentencoding"); if (andRemoveNonEmptyAttribute != null) { base.OutputCacheParameters.VaryByContentEncoding = andRemoveNonEmptyAttribute; } string str2 = System.Web.UI.Util.GetAndRemoveNonEmptyAttribute(directive, "varybyheader"); if (str2 != null) { base.OutputCacheParameters.VaryByHeader = str2; } object obj2 = System.Web.UI.Util.GetAndRemoveEnumAttribute(directive, typeof(OutputCacheLocation), "location"); if (obj2 != null) { this._outputCacheLocation = (OutputCacheLocation)obj2; base.OutputCacheParameters.Location = this._outputCacheLocation; } string depString = System.Web.UI.Util.GetAndRemoveNonEmptyAttribute(directive, "sqldependency"); if (depString != null) { base.OutputCacheParameters.SqlDependency = depString; SqlCacheDependency.ValidateOutputCacheDependencyString(depString, true); } if (System.Web.UI.Util.GetAndRemoveBooleanAttribute(directive, "nostore", ref val)) { base.OutputCacheParameters.NoStore = val; } base.ProcessOutputCacheDirective(directiveName, directive); }
private static void SetCachePolicy(HttpResponse response, OutputCacheLocation outputCacheLocation) { switch (outputCacheLocation) { case OutputCacheLocation.Any: response.Cache.SetCacheability(HttpCacheability.Public); break; case OutputCacheLocation.Client: response.Cache.SetCacheability(HttpCacheability.Private); response.Cache.SetNoServerCaching(); break; case OutputCacheLocation.Downstream: response.Cache.SetCacheability(HttpCacheability.Public); response.Cache.SetNoServerCaching(); break; case OutputCacheLocation.None: response.Cache.SetCacheability(HttpCacheability.NoCache); response.Cache.SetNoServerCaching(); break; case OutputCacheLocation.Server: response.Cache.SetCacheability(HttpCacheability.Server); break; case OutputCacheLocation.ServerAndClient: response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate); break; } }
/* * Process the contents of the <%@ OutputCache ... %> directive */ internal override void ProcessOutputCacheDirective(string directiveName, IDictionary directive) { _varyByHeader = Util.GetAndRemoveNonEmptyAttribute(directive, "varybyheader"); object tmpObj = Util.GetAndRemoveEnumAttribute(directive, typeof(OutputCacheLocation), "location"); if (tmpObj != null) { _outputCacheLocation = (OutputCacheLocation)tmpObj; } base.ProcessOutputCacheDirective(directiveName, directive); }
/* * Process the contents of the <%@ OutputCache ... %> directive */ internal override void ProcessOutputCacheDirective(string directiveName, IDictionary directive) { string varyByContentEncoding; string varyByHeader; string sqlDependency; bool noStoreValue = false; varyByContentEncoding = Util.GetAndRemoveNonEmptyAttribute(directive, "varybycontentencoding"); if (varyByContentEncoding != null) { OutputCacheParameters.VaryByContentEncoding = varyByContentEncoding; } varyByHeader = Util.GetAndRemoveNonEmptyAttribute(directive, "varybyheader"); if (varyByHeader != null) { OutputCacheParameters.VaryByHeader = varyByHeader; } object tmpObj = Util.GetAndRemoveEnumAttribute(directive, typeof(OutputCacheLocation), "location"); if (tmpObj != null) { _outputCacheLocation = (OutputCacheLocation)tmpObj; OutputCacheParameters.Location = _outputCacheLocation; } sqlDependency = Util.GetAndRemoveNonEmptyAttribute(directive, "sqldependency"); if (sqlDependency != null) { OutputCacheParameters.SqlDependency = sqlDependency; // Validate the sqldependency attribute SqlCacheDependency.ValidateOutputCacheDependencyString(sqlDependency, true); } // Get the "no store" bool value if (Util.GetAndRemoveBooleanAttribute(directive, "nostore", ref noStoreValue)) { OutputCacheParameters.NoStore = noStoreValue; } base.ProcessOutputCacheDirective(directiveName, directive); }
protected override void InitOutputCache(int duration, String varyByHeader, String varyByCustom, OutputCacheLocation location, String varyByParam) { base.InitOutputCache(duration, varyByHeader, varyByCustom, location, varyByParam); Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate); Response.Cache.VaryByHeaders[UserAgentHeader] = true; IList headerList = Adapter.CacheVaryByHeaders; if (headerList != null) { foreach (String header in headerList) { Response.Cache.VaryByHeaders[header] = true; } } }
internal virtual void AddDirective (string directive, Hashtable atts) { if (String.Compare (directive, DefaultDirectiveName, true) == 0) { if (mainAttributes != null) ThrowParseException ("Only 1 " + DefaultDirectiveName + " is allowed"); mainAttributes = atts; ProcessMainAttributes (mainAttributes); return; } int cmp = String.Compare ("Assembly", directive, true); if (cmp == 0) { string name = GetString (atts, "Name", null); string src = GetString (atts, "Src", null); if (atts.Count > 0) ThrowParseException ("Attribute " + GetOneKey (atts) + " unknown."); if (name == null && src == null) ThrowParseException ("You gotta specify Src or Name"); if (name != null && src != null) ThrowParseException ("Src and Name cannot be used together"); if (name != null) { AddAssemblyByName (name); } else { GetAssemblyFromSource (src); } return; } cmp = String.Compare ("Import", directive, true); if (cmp == 0) { string namesp = GetString (atts, "Namespace", null); if (atts.Count > 0) ThrowParseException ("Attribute " + GetOneKey (atts) + " unknown."); if (namesp != null && namesp != "") AddImport (namesp); return; } cmp = String.Compare ("Implements", directive, true); if (cmp == 0) { string ifacename = GetString (atts, "Interface", ""); if (atts.Count > 0) ThrowParseException ("Attribute " + GetOneKey (atts) + " unknown."); Type iface = LoadType (ifacename); if (iface == null) ThrowParseException ("Cannot find type " + ifacename); if (!iface.IsInterface) ThrowParseException (iface + " is not an interface"); AddInterface (iface.FullName); return; } cmp = String.Compare ("OutputCache", directive, true); if (cmp == 0) { output_cache = true; if (atts ["Duration"] == null) ThrowParseException ("The directive is missing a 'duration' attribute."); if (atts ["VaryByParam"] == null) ThrowParseException ("This directive is missing a 'VaryByParam' " + "attribute, which should be set to \"none\", \"*\", " + "or a list of name/value pairs."); foreach (DictionaryEntry entry in atts) { string key = (string) entry.Key; switch (key.ToLower ()) { case "duration": oc_duration = Int32.Parse ((string) entry.Value); if (oc_duration < 1) ThrowParseException ("The 'duration' attribute must be set " + "to a positive integer value"); break; case "varybyparam": oc_param = (string) entry.Value; if (String.Compare (oc_param, "none") == 0) oc_param = null; break; case "varybyheader": oc_header = (string) entry.Value; break; case "varybycustom": oc_custom = (string) entry.Value; break; case "location": if (!(this is PageParser)) goto default; try { oc_location = (OutputCacheLocation) Enum.Parse ( typeof (OutputCacheLocation), (string) entry.Value, true); } catch { ThrowParseException ("The 'location' attribute is case sensitive and " + "must be one of the following values: Any, Client, " + "Downstream, Server, None, ServerAndClient."); } break; case "varybycontrol": if (this is PageParser) goto default; oc_controls = (string) entry.Value; break; case "shared": if (this is PageParser) goto default; try { oc_shared = Boolean.Parse ((string) entry.Value); } catch { ThrowParseException ("The 'shared' attribute is case sensitive" + " and must be set to 'true' or 'false'."); } break; default: ThrowParseException ("The '" + key + "' attribute is not " + "supported by the 'Outputcache' directive."); break; } } return; } ThrowParseException ("Unknown directive: " + directive); }
protected virtual new void InitOutputCache (int duration, string varyByContentEncoding, string varyByHeader, string varyByCustom, OutputCacheLocation location, string varyByParam) { }
/* * Process the contents of the <%@ OutputCache ... %> directive */ internal override void ProcessOutputCacheDirective(string directiveName, IDictionary directive) { string varyByContentEncoding; string varyByHeader; string sqlDependency; bool noStoreValue = false; varyByContentEncoding = Util.GetAndRemoveNonEmptyAttribute(directive, "varybycontentencoding"); if (varyByContentEncoding != null) { OutputCacheParameters.VaryByContentEncoding = varyByContentEncoding; } varyByHeader = Util.GetAndRemoveNonEmptyAttribute(directive, "varybyheader"); if (varyByHeader != null) { OutputCacheParameters.VaryByHeader = varyByHeader; } object tmpObj = Util.GetAndRemoveEnumAttribute(directive, typeof(OutputCacheLocation), "location"); if (tmpObj != null) { _outputCacheLocation = (OutputCacheLocation) tmpObj; OutputCacheParameters.Location = _outputCacheLocation; } sqlDependency = Util.GetAndRemoveNonEmptyAttribute(directive, "sqldependency"); if (sqlDependency != null) { OutputCacheParameters.SqlDependency = sqlDependency; // Validate the sqldependency attribute SqlCacheDependency.ValidateOutputCacheDependencyString(sqlDependency, true); } // Get the "no store" bool value if (Util.GetAndRemoveBooleanAttribute(directive, "nostore", ref noStoreValue)) { OutputCacheParameters.NoStore = noStoreValue; } base.ProcessOutputCacheDirective(directiveName, directive); }
protected virtual new void InitOutputCache(int duration, string varyByContentEncoding, string varyByHeader, string varyByCustom, OutputCacheLocation location, string varyByParam) { }
bool ShouldCacheOnServer(OutputCacheLocation location) { return(location == OutputCacheLocation.Any || location == OutputCacheLocation.Server || location == OutputCacheLocation.ServerAndClient); }
bool ShouldCacheOnServer(OutputCacheLocation location) { return (location == OutputCacheLocation.Any || location == OutputCacheLocation.Server || location == OutputCacheLocation.ServerAndClient); }
protected override void InitOutputCache(int duration, String varyByContentEncoding, String varyByHeader, String varyByCustom, OutputCacheLocation location, String varyByParam) { base.InitOutputCache(duration, varyByContentEncoding, varyByHeader, varyByCustom, location, varyByParam); Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate); Response.Cache.VaryByHeaders[UserAgentHeader] = true; IList headerList = Adapter.CacheVaryByHeaders; if (headerList != null) { foreach (String header in headerList) { Response.Cache.VaryByHeaders[header] = true; } } }
/// <summary> /// Initializes a new instance of the OutputCacheAttribute class /// </summary> /// <param name="location">The location(s) where caching can be applied.</param> /// <param name="duration">The duration in seconds for which the response should be cached.</param> public OutputCacheAttribute(OutputCacheLocation location, int duration) { this.Duration = duration; this.Location = location; }
internal override void ProcessOutputCacheDirective(string directiveName, IDictionary directive) { bool val = false; string andRemoveNonEmptyAttribute = System.Web.UI.Util.GetAndRemoveNonEmptyAttribute(directive, "varybycontentencoding"); if (andRemoveNonEmptyAttribute != null) { base.OutputCacheParameters.VaryByContentEncoding = andRemoveNonEmptyAttribute; } string str2 = System.Web.UI.Util.GetAndRemoveNonEmptyAttribute(directive, "varybyheader"); if (str2 != null) { base.OutputCacheParameters.VaryByHeader = str2; } object obj2 = System.Web.UI.Util.GetAndRemoveEnumAttribute(directive, typeof(OutputCacheLocation), "location"); if (obj2 != null) { this._outputCacheLocation = (OutputCacheLocation) obj2; base.OutputCacheParameters.Location = this._outputCacheLocation; } string depString = System.Web.UI.Util.GetAndRemoveNonEmptyAttribute(directive, "sqldependency"); if (depString != null) { base.OutputCacheParameters.SqlDependency = depString; SqlCacheDependency.ValidateOutputCacheDependencyString(depString, true); } if (System.Web.UI.Util.GetAndRemoveBooleanAttribute(directive, "nostore", ref val)) { base.OutputCacheParameters.NoStore = val; } base.ProcessOutputCacheDirective(directiveName, directive); }
protected virtual void InitOutputCache(int duration, string varyByContentEncoding, string varyByHeader, string varyByCustom, OutputCacheLocation location, string varyByParam) { HttpResponse response = Response; HttpCachePolicy cache = response.Cache; bool set_vary = false; HttpContext ctx = Context; DateTime timestamp = ctx != null ? ctx.Timestamp : DateTime.Now; switch (location) { case OutputCacheLocation.Any: cache.SetCacheability (HttpCacheability.Public); cache.SetMaxAge (new TimeSpan (0, 0, duration)); cache.SetLastModified (timestamp); set_vary = true; break; case OutputCacheLocation.Client: cache.SetCacheability (HttpCacheability.Private); cache.SetMaxAge (new TimeSpan (0, 0, duration)); cache.SetLastModified (timestamp); break; case OutputCacheLocation.Downstream: cache.SetCacheability (HttpCacheability.Public); cache.SetMaxAge (new TimeSpan (0, 0, duration)); cache.SetLastModified (timestamp); break; case OutputCacheLocation.Server: cache.SetCacheability (HttpCacheability.Server); set_vary = true; break; case OutputCacheLocation.None: break; } if (set_vary) { if (varyByCustom != null) cache.SetVaryByCustom (varyByCustom); if (varyByParam != null && varyByParam.Length > 0) { string[] prms = varyByParam.Split (';'); foreach (string p in prms) cache.VaryByParams [p.Trim ()] = true; cache.VaryByParams.IgnoreParams = false; } else { cache.VaryByParams.IgnoreParams = true; } if (varyByHeader != null && varyByHeader.Length > 0) { string[] hdrs = varyByHeader.Split (';'); foreach (string h in hdrs) cache.VaryByHeaders [h.Trim ()] = true; } if (PageAdapter != null) { if (PageAdapter.CacheVaryByParams != null) { foreach (string p in PageAdapter.CacheVaryByParams) cache.VaryByParams [p] = true; } if (PageAdapter.CacheVaryByHeaders != null) { foreach (string h in PageAdapter.CacheVaryByHeaders) cache.VaryByHeaders [h] = true; } } } response.IsCached = true; cache.Duration = duration; cache.SetExpires (timestamp.AddSeconds (duration)); }
internal virtual void ProcessOutputCacheAttributes (IDictionary atts) { if (atts ["Duration"] == null) ThrowParseException ("The directive is missing a 'duration' attribute."); if (atts ["VaryByParam"] == null && atts ["VaryByControl"] == null) ThrowParseException ("This directive is missing 'VaryByParam' " + "or 'VaryByControl' attribute, which should be set to \"none\", \"*\", " + "or a list of name/value pairs."); foreach (DictionaryEntry entry in atts) { string key = (string) entry.Key; if (key == null) continue; switch (key.ToLower (Helpers.InvariantCulture)) { case "duration": oc_duration = Int32.Parse ((string) entry.Value); if (oc_duration < 1) ThrowParseException ("The 'duration' attribute must be set " + "to a positive integer value"); break; case "sqldependency": oc_sqldependency = (string) entry.Value; break; case "nostore": try { oc_nostore = Boolean.Parse ((string) entry.Value); oc_parsed_params |= OutputCacheParsedParams.NoStore; } catch { ThrowParseException ("The 'NoStore' attribute is case sensitive" + " and must be set to 'true' or 'false'."); } break; case "cacheprofile": oc_cacheprofile = (string) entry.Value; oc_parsed_params |= OutputCacheParsedParams.CacheProfile; break; case "varybycontentencodings": oc_content_encodings = (string) entry.Value; oc_parsed_params |= OutputCacheParsedParams.VaryByContentEncodings; break; case "varybyparam": oc_param = (string) entry.Value; if (String.Compare (oc_param, "none", true, Helpers.InvariantCulture) == 0) oc_param = null; break; case "varybyheader": oc_header = (string) entry.Value; oc_parsed_params |= OutputCacheParsedParams.VaryByHeader; break; case "varybycustom": oc_custom = (string) entry.Value; oc_parsed_params |= OutputCacheParsedParams.VaryByCustom; break; case "location": if (!(this is PageParser)) goto default; try { oc_location = (OutputCacheLocation) Enum.Parse ( typeof (OutputCacheLocation), (string) entry.Value, true); oc_parsed_params |= OutputCacheParsedParams.Location; } catch { ThrowParseException ("The 'location' attribute is case sensitive and " + "must be one of the following values: Any, Client, " + "Downstream, Server, None, ServerAndClient."); } break; case "varybycontrol": oc_controls = (string) entry.Value; oc_parsed_params |= OutputCacheParsedParams.VaryByControl; break; case "shared": if (this is PageParser) goto default; try { oc_shared = Boolean.Parse ((string) entry.Value); } catch { ThrowParseException ("The 'shared' attribute is case sensitive" + " and must be set to 'true' or 'false'."); } break; default: ThrowParseException ("The '" + key + "' attribute is not " + "supported by the 'Outputcache' directive."); break; } } }
public CachedResult(int duration = int.MaxValue, OutputCacheLocation location = OutputCacheLocation.Server) { Duration = duration; VaryByParam = "none"; Location = location; }
internal virtual void ProcessOutputCacheAttributes(IDictionary atts) { if (atts ["Duration"] == null) { ThrowParseException("The directive is missing a 'duration' attribute."); } if (atts ["VaryByParam"] == null && atts ["VaryByControl"] == null) { ThrowParseException("This directive is missing 'VaryByParam' " + "or 'VaryByControl' attribute, which should be set to \"none\", \"*\", " + "or a list of name/value pairs."); } foreach (DictionaryEntry entry in atts) { string key = (string)entry.Key; if (key == null) { continue; } switch (key.ToLower(Helpers.InvariantCulture)) { case "duration": oc_duration = Int32.Parse((string)entry.Value); if (oc_duration < 1) { ThrowParseException("The 'duration' attribute must be set " + "to a positive integer value"); } break; case "sqldependency": oc_sqldependency = (string)entry.Value; break; case "nostore": try { oc_nostore = Boolean.Parse((string)entry.Value); oc_parsed_params |= OutputCacheParsedParams.NoStore; } catch { ThrowParseException("The 'NoStore' attribute is case sensitive" + " and must be set to 'true' or 'false'."); } break; case "cacheprofile": oc_cacheprofile = (string)entry.Value; oc_parsed_params |= OutputCacheParsedParams.CacheProfile; break; case "varybycontentencodings": oc_content_encodings = (string)entry.Value; oc_parsed_params |= OutputCacheParsedParams.VaryByContentEncodings; break; case "varybyparam": oc_param = (string)entry.Value; if (String.Compare(oc_param, "none", true, Helpers.InvariantCulture) == 0) { oc_param = null; } break; case "varybyheader": oc_header = (string)entry.Value; oc_parsed_params |= OutputCacheParsedParams.VaryByHeader; break; case "varybycustom": oc_custom = (string)entry.Value; oc_parsed_params |= OutputCacheParsedParams.VaryByCustom; break; case "location": if (!(this is PageParser)) { goto default; } try { oc_location = (OutputCacheLocation)Enum.Parse( typeof(OutputCacheLocation), (string)entry.Value, true); oc_parsed_params |= OutputCacheParsedParams.Location; } catch { ThrowParseException("The 'location' attribute is case sensitive and " + "must be one of the following values: Any, Client, " + "Downstream, Server, None, ServerAndClient."); } break; case "varybycontrol": oc_controls = (string)entry.Value; oc_parsed_params |= OutputCacheParsedParams.VaryByControl; break; case "shared": if (this is PageParser) { goto default; } try { oc_shared = Boolean.Parse((string)entry.Value); } catch { ThrowParseException("The 'shared' attribute is case sensitive" + " and must be set to 'true' or 'false'."); } break; default: ThrowParseException("The '" + key + "' attribute is not " + "supported by the 'Outputcache' directive."); break; } } }
/// <include file='doc\MobilePage.uex' path='docs/doc[@for="MobilePage.InitOutputCache"]/*' /> protected override void InitOutputCache(int duration, String varyByHeader, String varyByCustom, OutputCacheLocation location, String varyByParam) { InitOutputCache(duration, null, varyByHeader, varyByCustom, location, varyByParam); }
protected virtual void InitOutputCache (int duration, string varyByHeader, string varyByCustom, OutputCacheLocation location, string varyByParam) { InitOutputCache (duration, null, varyByHeader, varyByCustom, location, varyByParam); }
protected virtual void InitOutputCache(int duration, string varyByContentEncoding, string varyByHeader, string varyByCustom, OutputCacheLocation location, string varyByParam) { if (!this._isCrossPagePostBack) { OutputCacheParameters cacheSettings = new OutputCacheParameters { Duration = duration, VaryByContentEncoding = varyByContentEncoding, VaryByHeader = varyByHeader, VaryByCustom = varyByCustom, Location = location, VaryByParam = varyByParam }; this.InitOutputCache(cacheSettings); } }
protected IDictionary<string, object> ParseOutputCachePI() { XPathNavigator nav = this.Navigator; IDictionary<string, string> attribs = GetAttributes(nav.Value); var parameters = new Dictionary<string, object>(); // location object location = GetEnumAttribute(attribs, output_cache.location, typeof(OutputCacheLocation)); OutputCacheLocation loc = default(OutputCacheLocation); if (location != null) { loc = (OutputCacheLocation)location; parameters["Location"] = loc; } // cache-profile string cacheProfile = GetNonEmptyAttribute(attribs, output_cache.cache_profile); if (cacheProfile != null) { parameters["CacheProfile"] = cacheProfile; } bool otherParamsRequired = loc != OutputCacheLocation.None && cacheProfile == null; // duration string durationStr = GetNonEmptyAttribute(attribs, output_cache.duration); if (otherParamsRequired) { EnsureNonNull(durationStr, output_cache.it, output_cache.duration); } if (durationStr != null) { int duration; if (!int.TryParse(durationStr, out duration) || duration <= 0) { throw CreateParseException("The '{0}' attribute must be set to a positive integer value.", output_cache.duration); } parameters["Duration"] = duration; } // vary-by-param string varyByParam = GetNonEmptyAttribute(attribs, output_cache.vary_by_param); if (otherParamsRequired) { EnsureNonNull(varyByParam, output_cache.it, output_cache.vary_by_param); } if (varyByParam != null) { parameters["VaryByParam"] = String.Equals(varyByParam, "none", StringComparison.OrdinalIgnoreCase) ? null : varyByParam; } // no-store bool noStore = default(bool); if (GetBooleanAttribute(attribs, output_cache.no_store, ref noStore)) { parameters["NoStore"] = noStore; } // vary-by-header string varyByHeader = GetNonEmptyAttribute(attribs, output_cache.vary_by_header); if (varyByHeader != null) { parameters["VaryByHeader"] = varyByHeader; } // vary-by-custom string varyByCustom = GetNonEmptyAttribute(attribs, output_cache.vary_by_custom); if (varyByCustom != null) { parameters["VaryByCustom"] = varyByCustom; } // vary-by-content-encodings string varyByContentEncoding = GetNonEmptyAttribute(attribs, output_cache.vary_by_content_encodings); if (varyByContentEncoding != null) { parameters["VaryByContentEncoding"] = varyByContentEncoding; } return parameters; }
internal virtual void AddDirective (string directive, IDictionary atts) { var pageParserFilter = PageParserFilter; if (String.Compare (directive, DefaultDirectiveName, true, Helpers.InvariantCulture) == 0) { bool allowMainDirective = allowedMainDirectives > 0; if (mainAttributes != null && !allowMainDirective) ThrowParseException ("Only 1 " + DefaultDirectiveName + " is allowed"); allowedMainDirectives--; if (mainAttributes != null) return; if (pageParserFilter != null) pageParserFilter.PreprocessDirective (directive.ToLower (Helpers.InvariantCulture), atts); mainAttributes = atts; ProcessMainAttributes (mainAttributes); return; } else if (pageParserFilter != null) pageParserFilter.PreprocessDirective (directive.ToLower (Helpers.InvariantCulture), atts); int cmp = String.Compare ("Assembly", directive, true, Helpers.InvariantCulture); if (cmp == 0) { string name = GetString (atts, "Name", null); string src = GetString (atts, "Src", null); if (atts.Count > 0) ThrowParseException ("Attribute " + GetOneKey (atts) + " unknown."); if (name == null && src == null) ThrowParseException ("You gotta specify Src or Name"); if (name != null && src != null) ThrowParseException ("Src and Name cannot be used together"); if (name != null) { AddAssemblyByName (name); } else { GetAssemblyFromSource (src); } return; } cmp = String.Compare ("Import", directive, true, Helpers.InvariantCulture); if (cmp == 0) { string namesp = GetString (atts, "Namespace", null); if (atts.Count > 0) ThrowParseException ("Attribute " + GetOneKey (atts) + " unknown."); AddImport (namesp); return; } cmp = String.Compare ("Implements", directive, true, Helpers.InvariantCulture); if (cmp == 0) { string ifacename = GetString (atts, "Interface", ""); if (atts.Count > 0) ThrowParseException ("Attribute " + GetOneKey (atts) + " unknown."); Type iface = LoadType (ifacename); if (iface == null) ThrowParseException ("Cannot find type " + ifacename); if (!iface.IsInterface) ThrowParseException (iface + " is not an interface"); AddInterface (iface.FullName); return; } cmp = String.Compare ("OutputCache", directive, true, Helpers.InvariantCulture); if (cmp == 0) { HttpResponse response = HttpContext.Current.Response; if (response != null) response.Cache.SetValidUntilExpires (true); output_cache = true; if (atts ["Duration"] == null) ThrowParseException ("The directive is missing a 'duration' attribute."); if (atts ["VaryByParam"] == null && atts ["VaryByControl"] == null) ThrowParseException ("This directive is missing 'VaryByParam' " + "or 'VaryByControl' attribute, which should be set to \"none\", \"*\", " + "or a list of name/value pairs."); foreach (DictionaryEntry entry in atts) { string key = (string) entry.Key; if (key == null) continue; switch (key.ToLower (Helpers.InvariantCulture)) { case "duration": oc_duration = Int32.Parse ((string) entry.Value); if (oc_duration < 1) ThrowParseException ("The 'duration' attribute must be set " + "to a positive integer value"); break; case "sqldependency": oc_sqldependency = (string) entry.Value; break; case "nostore": try { oc_nostore = Boolean.Parse ((string) entry.Value); oc_parsed_params |= OutputCacheParsedParams.NoStore; } catch { ThrowParseException ("The 'NoStore' attribute is case sensitive" + " and must be set to 'true' or 'false'."); } break; case "cacheprofile": oc_cacheprofile = (string) entry.Value; oc_parsed_params |= OutputCacheParsedParams.CacheProfile; break; case "varybycontentencodings": oc_content_encodings = (string) entry.Value; oc_parsed_params |= OutputCacheParsedParams.VaryByContentEncodings; break; case "varybyparam": oc_param = (string) entry.Value; if (String.Compare (oc_param, "none", true, Helpers.InvariantCulture) == 0) oc_param = null; break; case "varybyheader": oc_header = (string) entry.Value; oc_parsed_params |= OutputCacheParsedParams.VaryByHeader; break; case "varybycustom": oc_custom = (string) entry.Value; oc_parsed_params |= OutputCacheParsedParams.VaryByCustom; break; case "location": if (!(this is PageParser)) goto default; try { oc_location = (OutputCacheLocation) Enum.Parse ( typeof (OutputCacheLocation), (string) entry.Value, true); oc_parsed_params |= OutputCacheParsedParams.Location; } catch { ThrowParseException ("The 'location' attribute is case sensitive and " + "must be one of the following values: Any, Client, " + "Downstream, Server, None, ServerAndClient."); } break; case "varybycontrol": oc_controls = (string) entry.Value; oc_parsed_params |= OutputCacheParsedParams.VaryByControl; break; case "shared": if (this is PageParser) goto default; try { oc_shared = Boolean.Parse ((string) entry.Value); } catch { ThrowParseException ("The 'shared' attribute is case sensitive" + " and must be set to 'true' or 'false'."); } break; default: ThrowParseException ("The '" + key + "' attribute is not " + "supported by the 'Outputcache' directive."); break; } } return; } ThrowParseException ("Unknown directive: " + directive); }