Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / ndp / fx / src / xsp / System / Web / UI / ControlCachePolicy.cs / 1 / ControlCachePolicy.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System; using System.IO; using System.Text; using System.Collections; using System.Collections.Specialized; using System.ComponentModel; using System.ComponentModel.Design; using System.Globalization; using System.Web; using System.Web.Util; using System.Web.UI.WebControls; using System.Web.Caching; using System.Security.Permissions; [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] public sealed class ControlCachePolicy { private static ControlCachePolicy _cachePolicyStub = new ControlCachePolicy(); private BasePartialCachingControl _pcc; internal ControlCachePolicy() { } internal ControlCachePolicy(BasePartialCachingControl pcc) { _pcc = pcc; } internal static ControlCachePolicy GetCachePolicyStub() { // Return a stub, which returns SupportsCaching==false and throws on everything else. return _cachePolicyStub; } // Check whether it is valid to access properties on this object private void CheckValidCallingContext() { // If it's not being cached, the CachePolicy can't be used if (_pcc == null) { throw new HttpException( SR.GetString(SR.UC_not_cached)); } // Make sure it's not being used too late if (_pcc.ControlState >= ControlState.PreRendered) { throw new HttpException( SR.GetString(SR.UCCachePolicy_unavailable)); } } public bool SupportsCaching { get { // Caching is supported if we have a PartialCachingControl return (_pcc != null); } } public bool Cached { get { CheckValidCallingContext(); return !_pcc._cachingDisabled; } set { CheckValidCallingContext(); _pcc._cachingDisabled = !value; } } public TimeSpan Duration { get { CheckValidCallingContext(); return _pcc.Duration; } set { CheckValidCallingContext(); _pcc.Duration = value; } } public HttpCacheVaryByParams VaryByParams { get { CheckValidCallingContext(); return _pcc.VaryByParams; } } public string VaryByControl { get { CheckValidCallingContext(); return _pcc.VaryByControl; } set { CheckValidCallingContext(); _pcc.VaryByControl = value; } } public CacheDependency Dependency { get { CheckValidCallingContext(); return _pcc.Dependency; } set { CheckValidCallingContext(); _pcc.Dependency = value; } } public void SetVaryByCustom(string varyByCustom) { CheckValidCallingContext(); _pcc._varyByCustom = varyByCustom; } public void SetSlidingExpiration(bool useSlidingExpiration) { CheckValidCallingContext(); _pcc._useSlidingExpiration = useSlidingExpiration; } public void SetExpires(DateTime expirationTime) { CheckValidCallingContext(); _pcc._utcExpirationTime = DateTimeUtil.ConvertToUniversalTime(expirationTime); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System; using System.IO; using System.Text; using System.Collections; using System.Collections.Specialized; using System.ComponentModel; using System.ComponentModel.Design; using System.Globalization; using System.Web; using System.Web.Util; using System.Web.UI.WebControls; using System.Web.Caching; using System.Security.Permissions; [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] public sealed class ControlCachePolicy { private static ControlCachePolicy _cachePolicyStub = new ControlCachePolicy(); private BasePartialCachingControl _pcc; internal ControlCachePolicy() { } internal ControlCachePolicy(BasePartialCachingControl pcc) { _pcc = pcc; } internal static ControlCachePolicy GetCachePolicyStub() { // Return a stub, which returns SupportsCaching==false and throws on everything else. return _cachePolicyStub; } // Check whether it is valid to access properties on this object private void CheckValidCallingContext() { // If it's not being cached, the CachePolicy can't be used if (_pcc == null) { throw new HttpException( SR.GetString(SR.UC_not_cached)); } // Make sure it's not being used too late if (_pcc.ControlState >= ControlState.PreRendered) { throw new HttpException( SR.GetString(SR.UCCachePolicy_unavailable)); } } public bool SupportsCaching { get { // Caching is supported if we have a PartialCachingControl return (_pcc != null); } } public bool Cached { get { CheckValidCallingContext(); return !_pcc._cachingDisabled; } set { CheckValidCallingContext(); _pcc._cachingDisabled = !value; } } public TimeSpan Duration { get { CheckValidCallingContext(); return _pcc.Duration; } set { CheckValidCallingContext(); _pcc.Duration = value; } } public HttpCacheVaryByParams VaryByParams { get { CheckValidCallingContext(); return _pcc.VaryByParams; } } public string VaryByControl { get { CheckValidCallingContext(); return _pcc.VaryByControl; } set { CheckValidCallingContext(); _pcc.VaryByControl = value; } } public CacheDependency Dependency { get { CheckValidCallingContext(); return _pcc.Dependency; } set { CheckValidCallingContext(); _pcc.Dependency = value; } } public void SetVaryByCustom(string varyByCustom) { CheckValidCallingContext(); _pcc._varyByCustom = varyByCustom; } public void SetSlidingExpiration(bool useSlidingExpiration) { CheckValidCallingContext(); _pcc._useSlidingExpiration = useSlidingExpiration; } public void SetExpires(DateTime expirationTime) { CheckValidCallingContext(); _pcc._utcExpirationTime = DateTimeUtil.ConvertToUniversalTime(expirationTime); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SynchronizedDispatch.cs
- ChannelSinkStacks.cs
- WebPageTraceListener.cs
- ProcessHostMapPath.cs
- DSGeneratorProblem.cs
- ToolStripTemplateNode.cs
- Collection.cs
- ToolStripControlHost.cs
- NamespaceMapping.cs
- ImageFormatConverter.cs
- TabControlEvent.cs
- DataRow.cs
- PersianCalendar.cs
- CatalogPart.cs
- RequestResponse.cs
- DesignTimeTemplateParser.cs
- LayoutManager.cs
- WebScriptMetadataMessageEncoderFactory.cs
- XPathSelfQuery.cs
- TextTreeExtractElementUndoUnit.cs
- MatrixUtil.cs
- X509ImageLogo.cs
- CommandBindingCollection.cs
- DbParameterCollectionHelper.cs
- PreloadedPackages.cs
- EntityException.cs
- CallbackBehaviorAttribute.cs
- arc.cs
- XmlDesigner.cs
- FillBehavior.cs
- UIElement.cs
- JsonWriter.cs
- TraceData.cs
- ILGenerator.cs
- MultiSelector.cs
- IdentityValidationException.cs
- ParallelLoopState.cs
- PropertyIDSet.cs
- OuterGlowBitmapEffect.cs
- PropertyEmitter.cs
- PermissionSetEnumerator.cs
- basenumberconverter.cs
- Attributes.cs
- ComponentChangedEvent.cs
- StreamWithDictionary.cs
- DataGridViewIntLinkedList.cs
- Composition.cs
- WindowsTreeView.cs
- ConnectionManagementElement.cs
- XmlUnspecifiedAttribute.cs
- MaskedTextBoxTextEditor.cs
- RegisteredScript.cs
- Rijndael.cs
- Reference.cs
- ProviderException.cs
- SemanticTag.cs
- WorkflowMarkupSerializer.cs
- XPathNode.cs
- SpanIndex.cs
- Brush.cs
- SqlStream.cs
- LeaseManager.cs
- CompilationUnit.cs
- Int32AnimationUsingKeyFrames.cs
- SplitContainer.cs
- AndAlso.cs
- ThreadAttributes.cs
- ArglessEventHandlerProxy.cs
- FontInfo.cs
- SystemMulticastIPAddressInformation.cs
- FrameworkPropertyMetadata.cs
- KnownColorTable.cs
- UshortList2.cs
- UrlMappingsModule.cs
- XmlSchema.cs
- XmlNullResolver.cs
- BitmapMetadataEnumerator.cs
- DiscriminatorMap.cs
- Logging.cs
- QilGeneratorEnv.cs
- ViewUtilities.cs
- TextFindEngine.cs
- DetailsView.cs
- XmlAnyElementAttribute.cs
- WebPartExportVerb.cs
- ClientTarget.cs
- BitmapFrame.cs
- ISAPIApplicationHost.cs
- ContainerAction.cs
- HTMLTextWriter.cs
- SmiEventStream.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- TemplateBamlRecordReader.cs
- Validator.cs
- RegisteredArrayDeclaration.cs
- XmlSchemaIdentityConstraint.cs
- WorkflowRuntimeSection.cs
- TextLine.cs
- CursorConverter.cs
- DbException.cs