示例#1
0
		public void Apply(HttpCachePolicyBase policy)
		{
			policy.ThrowIfNull("policy");

			if (!_hasPolicy)
			{
				return;
			}

			switch (_cacheability)
			{
				case HttpCacheability.NoCache:
					policy.SetCacheability(_allowsServerCaching == true ? HttpCacheability.ServerAndNoCache : HttpCacheability.NoCache);
					break;
				case HttpCacheability.Private:
					policy.SetCacheability(_allowsServerCaching == true ? HttpCacheability.ServerAndPrivate : HttpCacheability.Private);
					break;
				case HttpCacheability.Public:
					policy.SetCacheability(HttpCacheability.Public);
					break;
			}
			if (_noStore == true)
			{
				policy.SetNoStore();
			}
			if (_noTransforms == true)
			{
				policy.SetNoTransforms();
			}
			if (_clientCacheExpirationUtcTimestamp != null)
			{
				policy.SetExpires(_clientCacheExpirationUtcTimestamp.Value);
			}
			if (_clientCacheMaxAge != null)
			{
				policy.SetMaxAge(_clientCacheMaxAge.Value);
			}
			if (_allowResponseInBrowserHistory != null)
			{
				policy.SetAllowResponseInBrowserHistory(_allowResponseInBrowserHistory.Value);
			}
			if (_eTag != null)
			{
				policy.SetETag(_eTag);
			}
			if (_omitVaryStar != null)
			{
				policy.SetOmitVaryStar(_omitVaryStar.Value);
			}
			if (_proxyMaxAge != null)
			{
				policy.SetProxyMaxAge(_proxyMaxAge.Value);
			}
			if (_revalidation != null)
			{
				policy.SetRevalidation(_revalidation.Value);
			}
		}