Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- ListViewInsertEventArgs.cs
- BufferedGenericXmlSecurityToken.cs
- BufferModeSettings.cs
- VectorConverter.cs
- BrowserDefinitionCollection.cs
- AnnotationResource.cs
- HttpServerVarsCollection.cs
- GetWinFXPath.cs
- QueryContinueDragEventArgs.cs
- ScriptComponentDescriptor.cs
- TheQuery.cs
- MultiByteCodec.cs
- PointKeyFrameCollection.cs
- HostingEnvironmentException.cs
- WebPartEventArgs.cs
- SkewTransform.cs
- DynamicDataResources.Designer.cs
- documentsequencetextpointer.cs
- KnowledgeBase.cs
- MemberDomainMap.cs
- TransformedBitmap.cs
- ModuleBuilder.cs
- PerfCounters.cs
- TrailingSpaceComparer.cs
- FlowDocumentReaderAutomationPeer.cs
- MessageQueuePermission.cs
- PropertyInfo.cs
- ReverseInheritProperty.cs
- GenericTypeParameterBuilder.cs
- ResourceReferenceKeyNotFoundException.cs
- IntegerFacetDescriptionElement.cs
- CatalogPartChrome.cs
- PropertyStore.cs
- MetadataUtilsSmi.cs
- TemplateControlParser.cs
- SymmetricSecurityProtocolFactory.cs
- TextHintingModeValidation.cs
- TailCallAnalyzer.cs
- ExtensionWindowHeader.cs
- InteropDesigner.xaml.cs
- Soap.cs
- SettingsPropertyWrongTypeException.cs
- AdRotator.cs
- CommentEmitter.cs
- SmtpFailedRecipientsException.cs
- FontResourceCache.cs
- TextServicesContext.cs
- ResolveCriteriaApril2005.cs
- DocumentAutomationPeer.cs
- BulletedList.cs
- Win32KeyboardDevice.cs
- CSharpCodeProvider.cs
- DesignerTransaction.cs
- XmlSchemaSet.cs
- SchemaContext.cs
- SqlConnectionHelper.cs
- DiscoveryClientElement.cs
- SimplePropertyEntry.cs
- BuildProvider.cs
- CodeIdentifier.cs
- LoginCancelEventArgs.cs
- DataPagerFieldCommandEventArgs.cs
- LocationUpdates.cs
- DocumentScope.cs
- MappingModelBuildProvider.cs
- XpsFixedPageReaderWriter.cs
- glyphs.cs
- ReadOnlyAttribute.cs
- SQLStringStorage.cs
- XmlAutoDetectWriter.cs
- DataRelation.cs
- SiteMapPath.cs
- GridViewSortEventArgs.cs
- TranslateTransform.cs
- _DisconnectOverlappedAsyncResult.cs
- CustomAttributeFormatException.cs
- PagerSettings.cs
- TextFormatter.cs
- ForeignKeyConstraint.cs
- Authorization.cs
- AppSettingsExpressionBuilder.cs
- HideDisabledControlAdapter.cs
- QuaternionAnimationBase.cs
- NetworkAddressChange.cs
- XmlDataCollection.cs
- ProxySimple.cs
- BasicAsyncResult.cs
- WebPartDisplayModeCancelEventArgs.cs
- DataSvcMapFileSerializer.cs
- Literal.cs
- ModulesEntry.cs
- ReadOnlyHierarchicalDataSource.cs
- Misc.cs
- DataGridViewBand.cs
- SystemSounds.cs
- XmlTextReader.cs
- ContentDefinition.cs
- DataControlFieldCollection.cs
- ListBindingConverter.cs
- SoundPlayer.cs