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 / FilterableAttribute.cs / 1 / FilterableAttribute.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
*/
namespace System.Web.UI {
using System;
using System.Collections;
using System.ComponentModel;
using System.Security.Permissions;
///
///
///
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class)]
public sealed class FilterableAttribute : Attribute {
///
///
///
///
public static readonly FilterableAttribute Yes = new FilterableAttribute(true);
///
///
///
///
public static readonly FilterableAttribute No = new FilterableAttribute(false);
///
///
///
///
public static readonly FilterableAttribute Default = Yes;
private bool _filterable = false;
private static Hashtable _filterableTypes;
static FilterableAttribute() {
// Create a synchronized wrapper
_filterableTypes = Hashtable.Synchronized(new Hashtable());
}
///
///
public FilterableAttribute(bool filterable) {
_filterable = filterable;
}
///
/// Indicates if the property is Filterable.
///
public bool Filterable {
get {
return _filterable;
}
}
///
public override bool Equals(object obj) {
if (obj == this) {
return true;
}
FilterableAttribute other = obj as FilterableAttribute;
return (other != null) && (other.Filterable == _filterable);
}
///
public override int GetHashCode() {
return _filterable.GetHashCode();
}
///
public override bool IsDefaultAttribute() {
return this.Equals(Default);
}
public static bool IsObjectFilterable(Object instance) {
if (instance == null)
throw new ArgumentNullException("instance");
return IsTypeFilterable(instance.GetType());
}
public static bool IsPropertyFilterable(PropertyDescriptor propertyDescriptor) {
FilterableAttribute filterableAttr = (FilterableAttribute)propertyDescriptor.Attributes[typeof(FilterableAttribute)];
if (filterableAttr != null) {
return filterableAttr.Filterable;
}
return true;
}
public static bool IsTypeFilterable(Type type) {
if (type == null)
throw new ArgumentNullException("type");
object result = _filterableTypes[type];
if (result != null) {
return (bool)result;
}
System.ComponentModel.AttributeCollection attrs = TypeDescriptor.GetAttributes(type);
FilterableAttribute attr = (FilterableAttribute)attrs[typeof(FilterableAttribute)];
result = (attr != null) && attr.Filterable;
_filterableTypes[type] = result;
return (bool)result;
}
}
}
// 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.Collections;
using System.ComponentModel;
using System.Security.Permissions;
///
///
///
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class)]
public sealed class FilterableAttribute : Attribute {
///
///
///
///
public static readonly FilterableAttribute Yes = new FilterableAttribute(true);
///
///
///
///
public static readonly FilterableAttribute No = new FilterableAttribute(false);
///
///
///
///
public static readonly FilterableAttribute Default = Yes;
private bool _filterable = false;
private static Hashtable _filterableTypes;
static FilterableAttribute() {
// Create a synchronized wrapper
_filterableTypes = Hashtable.Synchronized(new Hashtable());
}
///
///
public FilterableAttribute(bool filterable) {
_filterable = filterable;
}
///
/// Indicates if the property is Filterable.
///
public bool Filterable {
get {
return _filterable;
}
}
///
public override bool Equals(object obj) {
if (obj == this) {
return true;
}
FilterableAttribute other = obj as FilterableAttribute;
return (other != null) && (other.Filterable == _filterable);
}
///
public override int GetHashCode() {
return _filterable.GetHashCode();
}
///
public override bool IsDefaultAttribute() {
return this.Equals(Default);
}
public static bool IsObjectFilterable(Object instance) {
if (instance == null)
throw new ArgumentNullException("instance");
return IsTypeFilterable(instance.GetType());
}
public static bool IsPropertyFilterable(PropertyDescriptor propertyDescriptor) {
FilterableAttribute filterableAttr = (FilterableAttribute)propertyDescriptor.Attributes[typeof(FilterableAttribute)];
if (filterableAttr != null) {
return filterableAttr.Filterable;
}
return true;
}
public static bool IsTypeFilterable(Type type) {
if (type == null)
throw new ArgumentNullException("type");
object result = _filterableTypes[type];
if (result != null) {
return (bool)result;
}
System.ComponentModel.AttributeCollection attrs = TypeDescriptor.GetAttributes(type);
FilterableAttribute attr = (FilterableAttribute)attrs[typeof(FilterableAttribute)];
result = (attr != null) && attr.Filterable;
_filterableTypes[type] = result;
return (bool)result;
}
}
}
// 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
- OLEDB_Enum.cs
- NamedPermissionSet.cs
- FilteredAttributeCollection.cs
- XmlQualifiedName.cs
- MethodToken.cs
- BulletedList.cs
- TimeZone.cs
- ElementsClipboardData.cs
- httpserverutility.cs
- Publisher.cs
- AppSettingsReader.cs
- ObfuscationAttribute.cs
- SizeIndependentAnimationStorage.cs
- TextElement.cs
- RestrictedTransactionalPackage.cs
- MergablePropertyAttribute.cs
- MailBnfHelper.cs
- AnnotationHelper.cs
- HandledEventArgs.cs
- MetaTable.cs
- MessageQueue.cs
- WebReferencesBuildProvider.cs
- _SSPISessionCache.cs
- BackoffTimeoutHelper.cs
- GridViewAutomationPeer.cs
- CanonicalFormWriter.cs
- MemberAccessException.cs
- PropertyNames.cs
- BitmapMetadataEnumerator.cs
- SqlDataSourceCache.cs
- SystemIPAddressInformation.cs
- HttpServerUtilityWrapper.cs
- ModelUIElement3D.cs
- CapabilitiesPattern.cs
- PropertyValueChangedEvent.cs
- TracedNativeMethods.cs
- UnionCodeGroup.cs
- FactoryMaker.cs
- MessageAction.cs
- InsufficientMemoryException.cs
- OleDbConnectionFactory.cs
- CallTemplateAction.cs
- CustomCategoryAttribute.cs
- ADRoleFactoryConfiguration.cs
- XmlElement.cs
- DataSourceNameHandler.cs
- XmlSchemaChoice.cs
- TrustManagerPromptUI.cs
- PropertiesTab.cs
- ColorKeyFrameCollection.cs
- ExpressionBinding.cs
- shaperfactoryquerycacheentry.cs
- BuildResultCache.cs
- PagerSettings.cs
- _NativeSSPI.cs
- OdbcFactory.cs
- ProcessingInstructionAction.cs
- EventLogPermission.cs
- EndOfStreamException.cs
- MsmqTransportElement.cs
- TdsParameterSetter.cs
- DictionaryKeyPropertyAttribute.cs
- DependencySource.cs
- DependentList.cs
- ColorConverter.cs
- Keywords.cs
- DataPagerFieldCommandEventArgs.cs
- XmlTextWriter.cs
- _ProxyChain.cs
- ParentUndoUnit.cs
- Utility.cs
- KeyedPriorityQueue.cs
- XmlDataDocument.cs
- ClientCredentialsElement.cs
- WebBrowserEvent.cs
- Rule.cs
- CounterSet.cs
- IgnorePropertiesAttribute.cs
- SerializationInfo.cs
- ScriptResourceHandler.cs
- NumericUpDownAcceleration.cs
- FormViewInsertedEventArgs.cs
- AnimationClock.cs
- SelectiveScrollingGrid.cs
- DesignerResources.cs
- ColumnBinding.cs
- ResourceManagerWrapper.cs
- ConnectionPoolManager.cs
- HttpChannelBindingToken.cs
- COAUTHINFO.cs
- PolicyLevel.cs
- control.ime.cs
- SplitContainerDesigner.cs
- ExcludeFromCodeCoverageAttribute.cs
- DockPatternIdentifiers.cs
- CategoryGridEntry.cs
- CaseInsensitiveOrdinalStringComparer.cs
- EventLogEntryCollection.cs
- BadImageFormatException.cs
- Int32CollectionValueSerializer.cs