Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / ndp / fx / src / xsp / System / Web / HttpCacheVaryByContentEncodings.cs / 1 / HttpCacheVaryByContentEncodings.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* * HttpCacheVaryByContentEncodings * * Copyright (c) 1998 Microsoft Corporation */ namespace System.Web { using System.Text; using System.Runtime.InteropServices; using System.Web.Util; using System.Security.Permissions; ////// [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] public sealed class HttpCacheVaryByContentEncodings { String[] _contentEncodings; bool _isModified; internal HttpCacheVaryByContentEncodings() { Reset(); } internal void Reset() { _isModified = false; _contentEncodings = null; } /* * Reset based on content encodings. */ internal void ResetFromContentEncodings(String[] contentEncodings) { Reset(); if (contentEncodings != null) { _isModified = true; _contentEncodings = new String[contentEncodings.Length]; for (int i = 0; i < contentEncodings.Length; i++) { _contentEncodings[i] = contentEncodings[i]; } } } // the response is not cacheable if we're varying by content encoding // and the content-encoding header is not one of the encodings that we're // varying by internal bool IsCacheableEncoding(string coding) { // return true if we are not varying by content encoding. if (_contentEncodings == null) { return true; } // return true if there is no Content-Encoding header if (coding == null) { return true; } // return true if the Content-Encoding header is listed for (int i = 0; i < _contentEncodings.Length; i++) { if (_contentEncodings[i] == coding) { return true; } } // return false if the Content-Encoding header is not listed return false; } internal bool IsModified() { return _isModified; } internal String[] GetContentEncodings() { return _contentEncodings; } // // Public methods and properties // ///Provides a type-safe way to vary by Content-Encoding. ////// public bool this[String contentEncoding] { get { if (String.IsNullOrEmpty(contentEncoding)) { throw new ArgumentNullException(SR.GetString(SR.Parameter_NullOrEmpty, "contentEncoding")); } if (_contentEncodings == null) { return false; } for(int i = 0; i < _contentEncodings.Length; i++) { if (_contentEncodings[i] == contentEncoding) { return true; } } return false; } set { if (String.IsNullOrEmpty(contentEncoding)) { throw new ArgumentNullException(SR.GetString(SR.Parameter_NullOrEmpty, "contentEncoding")); } // if someone enabled it, don't allow someone else to disable it. if (!value) { return; } _isModified = true; if (_contentEncodings != null) { string[] contentEncodings = new String[_contentEncodings.Length + 1]; for (int i = 0; i < _contentEncodings.Length; i++) { contentEncodings[i] = _contentEncodings[i]; } contentEncodings[contentEncodings.Length - 1] = contentEncoding; _contentEncodings = contentEncodings; return; } _contentEncodings = new String[1]; _contentEncodings[0] = contentEncoding; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------------------------ //Default property. /// Indexed property indicating that a cache should (or should not) vary according /// to a Content-Encoding. ///// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* * HttpCacheVaryByContentEncodings * * Copyright (c) 1998 Microsoft Corporation */ namespace System.Web { using System.Text; using System.Runtime.InteropServices; using System.Web.Util; using System.Security.Permissions; ////// [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] public sealed class HttpCacheVaryByContentEncodings { String[] _contentEncodings; bool _isModified; internal HttpCacheVaryByContentEncodings() { Reset(); } internal void Reset() { _isModified = false; _contentEncodings = null; } /* * Reset based on content encodings. */ internal void ResetFromContentEncodings(String[] contentEncodings) { Reset(); if (contentEncodings != null) { _isModified = true; _contentEncodings = new String[contentEncodings.Length]; for (int i = 0; i < contentEncodings.Length; i++) { _contentEncodings[i] = contentEncodings[i]; } } } // the response is not cacheable if we're varying by content encoding // and the content-encoding header is not one of the encodings that we're // varying by internal bool IsCacheableEncoding(string coding) { // return true if we are not varying by content encoding. if (_contentEncodings == null) { return true; } // return true if there is no Content-Encoding header if (coding == null) { return true; } // return true if the Content-Encoding header is listed for (int i = 0; i < _contentEncodings.Length; i++) { if (_contentEncodings[i] == coding) { return true; } } // return false if the Content-Encoding header is not listed return false; } internal bool IsModified() { return _isModified; } internal String[] GetContentEncodings() { return _contentEncodings; } // // Public methods and properties // ///Provides a type-safe way to vary by Content-Encoding. ////// public bool this[String contentEncoding] { get { if (String.IsNullOrEmpty(contentEncoding)) { throw new ArgumentNullException(SR.GetString(SR.Parameter_NullOrEmpty, "contentEncoding")); } if (_contentEncodings == null) { return false; } for(int i = 0; i < _contentEncodings.Length; i++) { if (_contentEncodings[i] == contentEncoding) { return true; } } return false; } set { if (String.IsNullOrEmpty(contentEncoding)) { throw new ArgumentNullException(SR.GetString(SR.Parameter_NullOrEmpty, "contentEncoding")); } // if someone enabled it, don't allow someone else to disable it. if (!value) { return; } _isModified = true; if (_contentEncodings != null) { string[] contentEncodings = new String[_contentEncodings.Length + 1]; for (int i = 0; i < _contentEncodings.Length; i++) { contentEncodings[i] = _contentEncodings[i]; } contentEncodings[contentEncodings.Length - 1] = contentEncoding; _contentEncodings = contentEncodings; return; } _contentEncodings = new String[1]; _contentEncodings[0] = contentEncoding; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.Default property. /// Indexed property indicating that a cache should (or should not) vary according /// to a Content-Encoding. ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataListCommandEventArgs.cs
- LineServices.cs
- CompiledQueryCacheEntry.cs
- SafeNativeMethodsCLR.cs
- DataDesignUtil.cs
- PrivateFontCollection.cs
- WebPartEditorApplyVerb.cs
- XmlNamespaceMappingCollection.cs
- Command.cs
- ActiveXSite.cs
- InternalControlCollection.cs
- AlphaSortedEnumConverter.cs
- XmlCustomFormatter.cs
- XsltInput.cs
- SqlMethodAttribute.cs
- BatchWriter.cs
- SqlDataSourceCache.cs
- SpecularMaterial.cs
- IdentifierService.cs
- JsonServiceDocumentSerializer.cs
- CatchBlock.cs
- TraceShell.cs
- PropertyEmitterBase.cs
- HtmlTableCell.cs
- FixedBufferAttribute.cs
- DefaultValueTypeConverter.cs
- ComNativeDescriptor.cs
- ChannelProtectionRequirements.cs
- PeerTransportListenAddressValidatorAttribute.cs
- SHA384.cs
- Int32RectConverter.cs
- GPRECT.cs
- QueuePathDialog.cs
- XmlLanguageConverter.cs
- TabControlCancelEvent.cs
- Light.cs
- XslCompiledTransform.cs
- BooleanFunctions.cs
- SecurityDocument.cs
- UriSectionData.cs
- ComponentResourceManager.cs
- SmtpMail.cs
- ComponentEvent.cs
- WebPartCloseVerb.cs
- SharingService.cs
- DrawingServices.cs
- ImportOptions.cs
- Utility.cs
- ButtonChrome.cs
- Errors.cs
- WsatEtwTraceListener.cs
- TCPClient.cs
- CalendarData.cs
- NativeWindow.cs
- GenericAuthenticationEventArgs.cs
- FillErrorEventArgs.cs
- StreamSecurityUpgradeInitiator.cs
- HwndStylusInputProvider.cs
- FixedSOMLineRanges.cs
- WebPartDisplayModeCollection.cs
- BatchStream.cs
- LinkLabelLinkClickedEvent.cs
- RectAnimation.cs
- AuthenticateEventArgs.cs
- ChtmlLinkAdapter.cs
- StateDesigner.Layouts.cs
- PerformanceCounterManager.cs
- DataSourceXmlTextReader.cs
- PlanCompilerUtil.cs
- ObjectDisposedException.cs
- ConfigurationSchemaErrors.cs
- SubMenuStyleCollection.cs
- WebPartsPersonalization.cs
- XmlEncoding.cs
- HtmlControl.cs
- DesignerEditorPartChrome.cs
- WindowsEditBoxRange.cs
- PtsCache.cs
- DurableEnlistmentState.cs
- WsatAdminException.cs
- TextAnchor.cs
- StringResourceManager.cs
- RightsManagementInformation.cs
- Hyperlink.cs
- DrawingContextDrawingContextWalker.cs
- ToolStripItemClickedEventArgs.cs
- AuthenticationService.cs
- HttpDictionary.cs
- AlphabetConverter.cs
- WindowsScroll.cs
- DispatcherHookEventArgs.cs
- WinEventWrap.cs
- StringToken.cs
- FileIOPermission.cs
- RootProfilePropertySettingsCollection.cs
- TcpAppDomainProtocolHandler.cs
- ButtonBase.cs
- ProjectionPlan.cs
- WorkflowExecutor.cs
- CodeDOMUtility.cs