private CacheControlHeaderValue(CacheControlHeaderValue source) { this.noCache = source.noCache; this.noStore = source.noStore; this.maxAge = source.maxAge; this.sharedMaxAge = source.sharedMaxAge; this.maxStale = source.maxStale; this.maxStaleLimit = source.maxStaleLimit; this.minFresh = source.minFresh; this.noTransform = source.noTransform; this.onlyIfCached = source.onlyIfCached; this.publicField = source.publicField; this.privateField = source.privateField; this.mustRevalidate = source.mustRevalidate; this.proxyRevalidate = source.proxyRevalidate; if (source.noCacheHeaders != null) { foreach (string str in source.noCacheHeaders) { this.NoCacheHeaders.Add(str); } } if (source.privateHeaders != null) { foreach (string str2 in source.privateHeaders) { this.PrivateHeaders.Add(str2); } } // SL fixes //if (source.extensions != null) //{ // foreach (NameValueHeaderValue value2 in source.extensions) // { // this.Extensions.Add((NameValueHeaderValue) ((ICloneable) value2).Clone()); // } //} }
internal static int GetCacheControlLength(string input, int startIndex, CacheControlHeaderValue storeValue, out CacheControlHeaderValue parsedValue) { parsedValue = null; if (string.IsNullOrEmpty(input) || (startIndex >= input.Length)) { return 0; } int index = startIndex; object obj2 = null; List<NameValueHeaderValue> nameValueList = new List<NameValueHeaderValue>(); while (index < input.Length) { if (!nameValueListParser.TryParseValue(input, null, ref index, out obj2)) { return 0; } nameValueList.Add(obj2 as NameValueHeaderValue); } CacheControlHeaderValue cc = storeValue; if (cc == null) { cc = new CacheControlHeaderValue(); } if (!TrySetCacheControlValues(cc, nameValueList)) { return 0; } if (storeValue == null) { parsedValue = cc; } return (input.Length - startIndex); }
private static bool TrySetCacheControlValues(CacheControlHeaderValue cc, List<NameValueHeaderValue> nameValueList) { foreach (NameValueHeaderValue value2 in nameValueList) { bool flag = true; switch (value2.Name.ToLowerInvariant()) { case "no-cache": flag = TrySetOptionalTokenList(value2, ref cc.noCache, ref cc.noCacheHeaders); break; case "no-store": flag = TrySetTokenOnlyValue(value2, ref cc.noStore); break; case "max-age": flag = TrySetTimeSpan(value2, ref cc.maxAge); break; case "max-stale": flag = (value2.Value == null) || TrySetTimeSpan(value2, ref cc.maxStaleLimit); if (flag) { cc.maxStale = true; } break; case "min-fresh": flag = TrySetTimeSpan(value2, ref cc.minFresh); break; case "no-transform": flag = TrySetTokenOnlyValue(value2, ref cc.noTransform); break; case "only-if-cached": flag = TrySetTokenOnlyValue(value2, ref cc.onlyIfCached); break; case "public": flag = TrySetTokenOnlyValue(value2, ref cc.publicField); break; case "private": flag = TrySetOptionalTokenList(value2, ref cc.privateField, ref cc.privateHeaders); break; case "must-revalidate": flag = TrySetTokenOnlyValue(value2, ref cc.mustRevalidate); break; case "proxy-revalidate": flag = TrySetTokenOnlyValue(value2, ref cc.proxyRevalidate); break; case "s-maxage": flag = TrySetTimeSpan(value2, ref cc.sharedMaxAge); break; default: cc.Extensions.Add(value2); break; } if (!flag) { return false; } } return true; }
/// <summary>Determines whether a string is valid <see cref="T:NMasters.Silverlight.Net.Http.Headers.CacheControlHeaderValue" /> information.</summary> /// <returns>Returns <see cref="T:System.Boolean" />.true if <paramref name="input" /> is valid <see cref="T:NMasters.Silverlight.Net.Http.Headers.CacheControlHeaderValue" /> information; otherwise, false.</returns> /// <param name="input">The string to validate.</param> /// <param name="parsedValue">The <see cref="T:NMasters.Silverlight.Net.Http.Headers.CacheControlHeaderValue" /> version of the string.</param> public static bool TryParse(string input, out CacheControlHeaderValue parsedValue) { object obj2; int index = 0; parsedValue = null; if (CacheControlHeaderParser.Parser.TryParseValue(input, null, ref index, out obj2)) { parsedValue = (CacheControlHeaderValue) obj2; return true; } return false; }