Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- SmiEventSink_Default.cs
- _SslState.cs
- bidPrivateBase.cs
- RoleServiceManager.cs
- DropDownHolder.cs
- TextPointer.cs
- EntityDataSourceUtil.cs
- CompatibleIComparer.cs
- DrawingImage.cs
- SmtpFailedRecipientsException.cs
- DefaultTextStore.cs
- GroupBox.cs
- Metadata.cs
- GridItem.cs
- ResolveMatches11.cs
- CompilerError.cs
- OSFeature.cs
- _emptywebproxy.cs
- WebPartDescription.cs
- MatrixTransform.cs
- JoinElimination.cs
- SqlRecordBuffer.cs
- InfoCardProofToken.cs
- Point3D.cs
- ThreadStaticAttribute.cs
- PerfCounters.cs
- ButtonColumn.cs
- GridViewCellAutomationPeer.cs
- SchemaConstraints.cs
- NameValueConfigurationCollection.cs
- XPathMultyIterator.cs
- ObjectAssociationEndMapping.cs
- CompilerWrapper.cs
- WebPartZoneBase.cs
- RemoteWebConfigurationHostStream.cs
- Opcode.cs
- TreeNodeCollectionEditorDialog.cs
- ComboBox.cs
- WindowsSspiNegotiation.cs
- _FixedSizeReader.cs
- WindowsAltTab.cs
- IntellisenseTextBox.cs
- UnsafeNativeMethods.cs
- CryptoProvider.cs
- MissingManifestResourceException.cs
- XmlWrappingWriter.cs
- PersonalizationStateInfoCollection.cs
- TimeZoneInfo.cs
- XmlReaderSettings.cs
- Internal.cs
- OdbcConnectionPoolProviderInfo.cs
- ConfigXmlComment.cs
- UrlAuthFailedErrorFormatter.cs
- ManagedWndProcTracker.cs
- ObjectCloneHelper.cs
- ToolstripProfessionalRenderer.cs
- WebServiceClientProxyGenerator.cs
- DesignerObjectListAdapter.cs
- TransactionScope.cs
- WebPartVerb.cs
- ping.cs
- Wildcard.cs
- TableItemStyle.cs
- CollectionChangedEventManager.cs
- WhitespaceRule.cs
- TemplatingOptionsDialog.cs
- InputLanguage.cs
- SafeHandle.cs
- MasterPageParser.cs
- ToolStripPanelRenderEventArgs.cs
- BounceEase.cs
- ApplicationHost.cs
- TimeSpanStorage.cs
- SelectedDatesCollection.cs
- FormatSettings.cs
- DependencyProperty.cs
- AddressingProperty.cs
- EventSinkHelperWriter.cs
- ViewCellSlot.cs
- PenCursorManager.cs
- FieldCollectionEditor.cs
- ProxyElement.cs
- TypeLibConverter.cs
- FrameDimension.cs
- RectAnimationClockResource.cs
- RepeatBehaviorConverter.cs
- SQLByteStorage.cs
- ColorConvertedBitmap.cs
- NameValuePair.cs
- GroupQuery.cs
- DataObjectCopyingEventArgs.cs
- ToolStripLabel.cs
- RemotingClientProxy.cs
- StringReader.cs
- XmlObjectSerializerWriteContextComplexJson.cs
- HttpPostLocalhostServerProtocol.cs
- ApplicationServiceManager.cs
- InstanceLockLostException.cs
- OleServicesContext.cs
- MenuTracker.cs