Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Configuration / SqlCacheDependencyDatabase.cs / 1305376 / SqlCacheDependencyDatabase.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Configuration { using System; using System.Xml; using System.Configuration; using System.Collections.Specialized; using System.Collections; using System.Globalization; using System.IO; using System.Text; using System.Diagnostics; using System.Security.Permissions; // class SqlCacheDependencySection public sealed class SqlCacheDependencyDatabase : ConfigurationElement { private static readonly ConfigurationElementProperty s_elemProperty = new ConfigurationElementProperty(new CallbackValidator(typeof(SqlCacheDependencyDatabase), Validate)); private static ConfigurationPropertyCollection _properties; private static readonly ConfigurationProperty _propName; private static readonly ConfigurationProperty _propConnectionStringName; private static readonly ConfigurationProperty _propPollTime; static SqlCacheDependencyDatabase() { // Property initialization _properties = new ConfigurationPropertyCollection(); _propName = new ConfigurationProperty("name", typeof(string), null, null, StdValidatorsAndConverters.NonEmptyStringValidator, ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey); _propConnectionStringName = new ConfigurationProperty("connectionStringName", typeof(string), null, null, StdValidatorsAndConverters.NonEmptyStringValidator, ConfigurationPropertyOptions.IsRequired); _propPollTime = new ConfigurationProperty("pollTime", typeof(int), 60000, ConfigurationPropertyOptions.None); _properties.Add(_propName); _properties.Add(_propConnectionStringName); _properties.Add(_propPollTime); } private int defaultPollTime; // This may be set by the outer node to specify the default poll time (i.e. not specified on this node) public SqlCacheDependencyDatabase(string name, string connectionStringName, int pollTime) { Name = name; ConnectionStringName = connectionStringName; PollTime = pollTime; } public SqlCacheDependencyDatabase(string name, string connectionStringName) { Name = name; ConnectionStringName = connectionStringName; } internal SqlCacheDependencyDatabase() { } protected override ConfigurationPropertyCollection Properties { get { return _properties; } } protected override ConfigurationElementProperty ElementProperty { get { return s_elemProperty; } } private static void Validate(object value) { if (value == null) { throw new ArgumentNullException("sqlCacheDependencyDatabase"); } Debug.Assert(value is SqlCacheDependencyDatabase); SqlCacheDependencyDatabase elem = (SqlCacheDependencyDatabase)value; if (elem.PollTime != 0 && elem.PollTime < 500) { throw new ConfigurationErrorsException( SR.GetString(SR.Invalid_sql_cache_dep_polltime), elem.ElementInformation.Properties["pollTime"].Source, elem.ElementInformation.Properties["pollTime"].LineNumber); } } internal void CheckDefaultPollTime(int value) { // This method will be called by the outer node. // If the poolTime property is not specified in the node, then grab the one // from above. if (ElementInformation.Properties["pollTime"].ValueOrigin == PropertyValueOrigin.Default) { defaultPollTime = value; } } [ConfigurationProperty("name", IsRequired = true, IsKey = true)] [StringValidator(MinLength = 1)] public string Name { get { return (string)base[_propName]; } set { base[_propName] = value; } } [ConfigurationProperty("connectionStringName", IsRequired = true)] [StringValidator(MinLength = 1)] public string ConnectionStringName { get { return (string)base[_propConnectionStringName]; } set { base[_propConnectionStringName] = value; } } [ConfigurationProperty("pollTime", DefaultValue = 60000)] public int PollTime { get { if (ElementInformation.Properties["pollTime"].ValueOrigin == PropertyValueOrigin.Default) { return defaultPollTime; // Return the default value from outer node } else { return (int)base[_propPollTime]; } } set { base[_propPollTime] = value; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Configuration { using System; using System.Xml; using System.Configuration; using System.Collections.Specialized; using System.Collections; using System.Globalization; using System.IO; using System.Text; using System.Diagnostics; using System.Security.Permissions; // class SqlCacheDependencySection public sealed class SqlCacheDependencyDatabase : ConfigurationElement { private static readonly ConfigurationElementProperty s_elemProperty = new ConfigurationElementProperty(new CallbackValidator(typeof(SqlCacheDependencyDatabase), Validate)); private static ConfigurationPropertyCollection _properties; private static readonly ConfigurationProperty _propName; private static readonly ConfigurationProperty _propConnectionStringName; private static readonly ConfigurationProperty _propPollTime; static SqlCacheDependencyDatabase() { // Property initialization _properties = new ConfigurationPropertyCollection(); _propName = new ConfigurationProperty("name", typeof(string), null, null, StdValidatorsAndConverters.NonEmptyStringValidator, ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey); _propConnectionStringName = new ConfigurationProperty("connectionStringName", typeof(string), null, null, StdValidatorsAndConverters.NonEmptyStringValidator, ConfigurationPropertyOptions.IsRequired); _propPollTime = new ConfigurationProperty("pollTime", typeof(int), 60000, ConfigurationPropertyOptions.None); _properties.Add(_propName); _properties.Add(_propConnectionStringName); _properties.Add(_propPollTime); } private int defaultPollTime; // This may be set by the outer node to specify the default poll time (i.e. not specified on this node) public SqlCacheDependencyDatabase(string name, string connectionStringName, int pollTime) { Name = name; ConnectionStringName = connectionStringName; PollTime = pollTime; } public SqlCacheDependencyDatabase(string name, string connectionStringName) { Name = name; ConnectionStringName = connectionStringName; } internal SqlCacheDependencyDatabase() { } protected override ConfigurationPropertyCollection Properties { get { return _properties; } } protected override ConfigurationElementProperty ElementProperty { get { return s_elemProperty; } } private static void Validate(object value) { if (value == null) { throw new ArgumentNullException("sqlCacheDependencyDatabase"); } Debug.Assert(value is SqlCacheDependencyDatabase); SqlCacheDependencyDatabase elem = (SqlCacheDependencyDatabase)value; if (elem.PollTime != 0 && elem.PollTime < 500) { throw new ConfigurationErrorsException( SR.GetString(SR.Invalid_sql_cache_dep_polltime), elem.ElementInformation.Properties["pollTime"].Source, elem.ElementInformation.Properties["pollTime"].LineNumber); } } internal void CheckDefaultPollTime(int value) { // This method will be called by the outer node. // If the poolTime property is not specified in the node, then grab the one // from above. if (ElementInformation.Properties["pollTime"].ValueOrigin == PropertyValueOrigin.Default) { defaultPollTime = value; } } [ConfigurationProperty("name", IsRequired = true, IsKey = true)] [StringValidator(MinLength = 1)] public string Name { get { return (string)base[_propName]; } set { base[_propName] = value; } } [ConfigurationProperty("connectionStringName", IsRequired = true)] [StringValidator(MinLength = 1)] public string ConnectionStringName { get { return (string)base[_propConnectionStringName]; } set { base[_propConnectionStringName] = value; } } [ConfigurationProperty("pollTime", DefaultValue = 60000)] public int PollTime { get { if (ElementInformation.Properties["pollTime"].ValueOrigin == PropertyValueOrigin.Default) { return defaultPollTime; // Return the default value from outer node } else { return (int)base[_propPollTime]; } } set { base[_propPollTime] = value; } } } } // 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
- TextParagraphCache.cs
- _RequestCacheProtocol.cs
- ListViewHitTestInfo.cs
- JulianCalendar.cs
- AttachedAnnotationChangedEventArgs.cs
- ItemAutomationPeer.cs
- EndpointIdentityConverter.cs
- StorageEndPropertyMapping.cs
- shaperfactoryquerycachekey.cs
- IndicShape.cs
- EqualityComparer.cs
- HtmlTernaryTree.cs
- DropShadowBitmapEffect.cs
- SystemIPGlobalProperties.cs
- SymbolTable.cs
- XmlSchemaSimpleContentRestriction.cs
- XamlWriter.cs
- CodeAttributeDeclaration.cs
- datacache.cs
- ExceptionWrapper.cs
- Stack.cs
- WorkItem.cs
- WindowsRebar.cs
- EventDescriptorCollection.cs
- XmlQueryContext.cs
- TextParagraphView.cs
- ListMarkerSourceInfo.cs
- MemoryRecordBuffer.cs
- Keyboard.cs
- SiteMapDataSource.cs
- ObjectSpanRewriter.cs
- XPathParser.cs
- MethodExpr.cs
- ErrorEventArgs.cs
- Transform3DGroup.cs
- MultiTrigger.cs
- PaperSource.cs
- NativeMethods.cs
- EntityException.cs
- PagerSettings.cs
- CqlQuery.cs
- DesignerTransaction.cs
- XmlObjectSerializerReadContext.cs
- DesignTimeTemplateParser.cs
- OledbConnectionStringbuilder.cs
- WindowsImpersonationContext.cs
- MsmqIntegrationInputMessage.cs
- PlatformNotSupportedException.cs
- InkCanvasSelection.cs
- XmlSchemaExternal.cs
- ClientScriptManager.cs
- NativeRecognizer.cs
- SR.cs
- IPAddress.cs
- SortedList.cs
- Matrix3D.cs
- SrgsDocument.cs
- FontDriver.cs
- _OverlappedAsyncResult.cs
- DataGridViewLinkCell.cs
- AddInActivator.cs
- CodeGenerator.cs
- ListItemCollection.cs
- InstanceNotReadyException.cs
- PkcsMisc.cs
- ExceptionCollection.cs
- XmlSchemaFacet.cs
- TextBlockAutomationPeer.cs
- TextUtf8RawTextWriter.cs
- ByteFacetDescriptionElement.cs
- RootProfilePropertySettingsCollection.cs
- SafeProcessHandle.cs
- SoapIgnoreAttribute.cs
- CreateParams.cs
- BitmapEffectrendercontext.cs
- ArrangedElementCollection.cs
- CultureInfoConverter.cs
- EndpointInfoCollection.cs
- DependencyPropertyHelper.cs
- AvTrace.cs
- ProxyHelper.cs
- PersonalizableAttribute.cs
- DocumentPage.cs
- OracleSqlParser.cs
- MetadataCollection.cs
- SystemIPGlobalProperties.cs
- XamlTemplateSerializer.cs
- Wildcard.cs
- NonParentingControl.cs
- VerificationException.cs
- Schema.cs
- ToolStripAdornerWindowService.cs
- SqlWriter.cs
- httpapplicationstate.cs
- GlyphCache.cs
- TextDecorationUnitValidation.cs
- Environment.cs
- EndGetFileNameFromUserRequest.cs
- SelectionItemPattern.cs
- ToolStripArrowRenderEventArgs.cs