Code:
/ DotNET / DotNET / 8.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
- ActiveXContainer.cs
- MediaTimeline.cs
- PackageRelationshipSelector.cs
- SizeKeyFrameCollection.cs
- AdornerPresentationContext.cs
- DataColumnCollection.cs
- XPathExpr.cs
- DecimalAnimationBase.cs
- XmlStringTable.cs
- latinshape.cs
- Geometry3D.cs
- WindowProviderWrapper.cs
- PerformanceCountersElement.cs
- XmlSchemaAttributeGroupRef.cs
- HMACSHA512.cs
- DrawingGroup.cs
- TypeLoadException.cs
- Journaling.cs
- LinkTarget.cs
- RegexStringValidator.cs
- SchemaElementDecl.cs
- unitconverter.cs
- FolderBrowserDialog.cs
- CipherData.cs
- ConfigXmlElement.cs
- DbConnectionPoolGroupProviderInfo.cs
- MultidimensionalArrayItemReference.cs
- TextPenaltyModule.cs
- SafePipeHandle.cs
- EncryptedPackageFilter.cs
- datacache.cs
- SchemaObjectWriter.cs
- BeginStoryboard.cs
- TcpHostedTransportConfiguration.cs
- DataGridViewCellStyleConverter.cs
- XPathConvert.cs
- QualificationDataAttribute.cs
- DbModificationCommandTree.cs
- Soap12ServerProtocol.cs
- SmtpNetworkElement.cs
- PopupEventArgs.cs
- MarshalByRefObject.cs
- Decimal.cs
- LocalizationComments.cs
- PersonalizableAttribute.cs
- ProfileSettingsCollection.cs
- ConfigurationException.cs
- WinInetCache.cs
- ParsedRoute.cs
- JsonUriDataContract.cs
- ObjectDataSourceMethodEventArgs.cs
- CodeArrayIndexerExpression.cs
- PointAnimationUsingPath.cs
- SQLByteStorage.cs
- SmiConnection.cs
- HttpTransportSecurity.cs
- BinaryFormatterWriter.cs
- SplashScreenNativeMethods.cs
- FigureParaClient.cs
- ComponentChangedEvent.cs
- TextTreeUndo.cs
- ConsumerConnectionPointCollection.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- NetworkStream.cs
- SizeF.cs
- ComplexTypeEmitter.cs
- HtmlDocument.cs
- ReflectPropertyDescriptor.cs
- ComponentChangedEvent.cs
- Debug.cs
- SQLUtility.cs
- XmlWrappingWriter.cs
- ConnectionManagementElement.cs
- ScrollBar.cs
- BitmapEffectDrawing.cs
- Track.cs
- TextServicesManager.cs
- _Semaphore.cs
- BitmapCodecInfoInternal.cs
- XmlEncoding.cs
- _ProxyRegBlob.cs
- DataBoundControlAdapter.cs
- ExpressionVisitor.cs
- ShowExpandedMultiValueConverter.cs
- ResourceWriter.cs
- HostingEnvironment.cs
- OdbcException.cs
- Win32Interop.cs
- DummyDataSource.cs
- DBParameter.cs
- exports.cs
- IncrementalReadDecoders.cs
- KeySpline.cs
- GeneralTransform2DTo3DTo2D.cs
- CorrelationResolver.cs
- RIPEMD160Managed.cs
- NumberEdit.cs
- ReadOnlyDictionary.cs
- GeneralTransform3DTo2D.cs
- TypeDependencyAttribute.cs