Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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. // //----------------------------------------------------------------------------- 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataTableClearEvent.cs
- TransformationRules.cs
- ExpressionBuilder.cs
- SqlVersion.cs
- WebScriptEndpoint.cs
- AttachedPropertyBrowsableAttribute.cs
- KeyPressEvent.cs
- DbParameterCollectionHelper.cs
- BaseCollection.cs
- LineSegment.cs
- TraceUtility.cs
- BitmapEncoder.cs
- RestHandler.cs
- DesignerDataStoredProcedure.cs
- CustomAttribute.cs
- ValidatingCollection.cs
- EntityDataSourceViewSchema.cs
- PrimitiveCodeDomSerializer.cs
- AssociationTypeEmitter.cs
- ContentPlaceHolder.cs
- MetabaseReader.cs
- MediaPlayerState.cs
- followingsibling.cs
- ComponentDispatcherThread.cs
- Section.cs
- httpstaticobjectscollection.cs
- HebrewNumber.cs
- FacetDescriptionElement.cs
- SourceFileBuildProvider.cs
- XmlSchemaGroup.cs
- MsmqBindingMonitor.cs
- SHA384.cs
- ErrorHandlingAcceptor.cs
- InvokeHandlers.cs
- CapabilitiesAssignment.cs
- ValidationError.cs
- EmissiveMaterial.cs
- InvalidProgramException.cs
- BufferedWebEventProvider.cs
- RootBuilder.cs
- XmlSiteMapProvider.cs
- MediaSystem.cs
- ApplicationServiceManager.cs
- BitmapMetadata.cs
- DataServiceSaveChangesEventArgs.cs
- Track.cs
- StaticExtensionConverter.cs
- HtmlHistory.cs
- DataGridViewBand.cs
- SerializationInfoEnumerator.cs
- HostingEnvironmentWrapper.cs
- Thickness.cs
- DoubleUtil.cs
- WebPartTransformer.cs
- Transform.cs
- TextRangeAdaptor.cs
- RequiredFieldValidator.cs
- RegularExpressionValidator.cs
- DrawingVisualDrawingContext.cs
- UnauthorizedWebPart.cs
- DynamicExpression.cs
- ConstantSlot.cs
- HtmlEncodedRawTextWriter.cs
- SID.cs
- XmlCompatibilityReader.cs
- LambdaExpression.cs
- Literal.cs
- ContainerFilterService.cs
- SQLDoubleStorage.cs
- DataColumnChangeEvent.cs
- TextTreeTextNode.cs
- ConfigurationValues.cs
- PageBreakRecord.cs
- ValidationManager.cs
- CreateUserWizardStep.cs
- SHA384.cs
- TypeBuilderInstantiation.cs
- BitmapEffectGeneralTransform.cs
- RealProxy.cs
- IndentTextWriter.cs
- GeneralTransform3DTo2DTo3D.cs
- Odbc32.cs
- DataGridCellsPanel.cs
- WaitHandleCannotBeOpenedException.cs
- SortableBindingList.cs
- EventEntry.cs
- DbConnectionOptions.cs
- WebEventCodes.cs
- CustomErrorsSection.cs
- Int32KeyFrameCollection.cs
- DataGridItemEventArgs.cs
- EndpointDispatcherTable.cs
- ExpressionsCollectionConverter.cs
- DataSourceCache.cs
- CompilerResults.cs
- DefinitionProperties.cs
- Classification.cs
- EnumUnknown.cs
- HTMLTextWriter.cs
- HttpErrorTraceRecord.cs