Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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); } } }
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataGridItemCollection.cs
- XmlChoiceIdentifierAttribute.cs
- ReflectTypeDescriptionProvider.cs
- CompensationExtension.cs
- XmlWhitespace.cs
- _NetRes.cs
- CaseStatement.cs
- TranslateTransform3D.cs
- TypeDefinition.cs
- TraceContext.cs
- DtdParser.cs
- XmlBaseWriter.cs
- Stacktrace.cs
- TypeInitializationException.cs
- ObjectParameterCollection.cs
- WebContext.cs
- XmlNamedNodeMap.cs
- documentsequencetextview.cs
- LinkTarget.cs
- ConfigXmlElement.cs
- IdentityReference.cs
- NamespaceList.cs
- XmlDocumentType.cs
- SerializationSectionGroup.cs
- OdbcEnvironmentHandle.cs
- DataGridViewImageCell.cs
- MenuItem.cs
- Win32MouseDevice.cs
- ComplexPropertyEntry.cs
- OptimizerPatterns.cs
- DoubleKeyFrameCollection.cs
- TypeElementCollection.cs
- MenuCommandService.cs
- ControlCollection.cs
- XXXOnTypeBuilderInstantiation.cs
- ClientTarget.cs
- ValuePattern.cs
- Argument.cs
- EncoderParameters.cs
- ToolStripGripRenderEventArgs.cs
- WorkflowRuntimeBehavior.cs
- CoTaskMemSafeHandle.cs
- ConditionalAttribute.cs
- GlyphManager.cs
- AlphaSortedEnumConverter.cs
- HttpProfileGroupBase.cs
- RoleBoolean.cs
- ExpressionCopier.cs
- PropertyChangedEventManager.cs
- SmiXetterAccessMap.cs
- ThreadStateException.cs
- wmiprovider.cs
- OleDbMetaDataFactory.cs
- PixelFormat.cs
- TransformedBitmap.cs
- BitmapMetadataBlob.cs
- PictureBox.cs
- CngProvider.cs
- DataGridBoolColumn.cs
- AssemblyAttributesGoHere.cs
- serverconfig.cs
- DetailsViewInsertEventArgs.cs
- TimersDescriptionAttribute.cs
- SmiContext.cs
- DependencyPropertyDescriptor.cs
- ComponentResourceKey.cs
- ExtentKey.cs
- CryptoHelper.cs
- TextServicesProperty.cs
- DataDocumentXPathNavigator.cs
- DispatcherFrame.cs
- TimeSpan.cs
- DataGridViewComboBoxEditingControl.cs
- UIPropertyMetadata.cs
- TextServicesProperty.cs
- KernelTypeValidation.cs
- TemplatedMailWebEventProvider.cs
- ElementAtQueryOperator.cs
- ProxyGenerationError.cs
- DesignerVerbCollection.cs
- MLangCodePageEncoding.cs
- CodeCatchClauseCollection.cs
- FileRecordSequenceCompletedAsyncResult.cs
- Point4DValueSerializer.cs
- Compiler.cs
- DoubleCollectionConverter.cs
- ServiceModelConfiguration.cs
- Stackframe.cs
- UriWriter.cs
- ToolBarOverflowPanel.cs
- EntityDataSourceQueryBuilder.cs
- FormatControl.cs
- SmiContext.cs
- PropertyManager.cs
- ProxyGenerator.cs
- CommandEventArgs.cs
- SiteOfOriginContainer.cs
- DataServiceBuildProvider.cs
- ComponentSerializationService.cs
- ToolStripPanelRenderEventArgs.cs