Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / FilterableAttribute.cs / 1305376 / 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;
///
///
///
[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
- TimeSpanOrInfiniteValidator.cs
- ProcessInfo.cs
- WebServiceMethodData.cs
- MexServiceChannelBuilder.cs
- MemberAccessException.cs
- WebUtil.cs
- ILGen.cs
- NavigationEventArgs.cs
- MenuBase.cs
- ContextMenuStripGroup.cs
- EntitySetDataBindingList.cs
- EntityException.cs
- ComponentEvent.cs
- SQLResource.cs
- PenThread.cs
- SiteMapNodeCollection.cs
- StreamGeometry.cs
- AccessViolationException.cs
- CombinedGeometry.cs
- WebRequest.cs
- FormClosingEvent.cs
- SqlResolver.cs
- BitmapSizeOptions.cs
- TextSelectionHighlightLayer.cs
- MessageBox.cs
- LoginView.cs
- Configuration.cs
- Function.cs
- DeclarativeExpressionConditionDeclaration.cs
- PasswordRecovery.cs
- CodeExporter.cs
- DataGridViewRowHeaderCell.cs
- DataSourceCacheDurationConverter.cs
- PerCallInstanceContextProvider.cs
- CategoryAttribute.cs
- PageTheme.cs
- VSWCFServiceContractGenerator.cs
- CodeGenerationManager.cs
- DataGridViewSelectedColumnCollection.cs
- HwndSourceParameters.cs
- JpegBitmapDecoder.cs
- BlurEffect.cs
- SQLResource.cs
- Activation.cs
- WsdlInspector.cs
- X509Utils.cs
- OdbcConnectionPoolProviderInfo.cs
- cookie.cs
- ParseNumbers.cs
- SID.cs
- XpsS0ValidatingLoader.cs
- DynamicRendererThreadManager.cs
- XmlSubtreeReader.cs
- FunctionDetailsReader.cs
- FastEncoderWindow.cs
- ThreadStartException.cs
- PopupRoot.cs
- Rect.cs
- WebServiceClientProxyGenerator.cs
- ToolStripCollectionEditor.cs
- NetMsmqSecurityMode.cs
- TypeUtils.cs
- RequestQueue.cs
- sqlstateclientmanager.cs
- KnownBoxes.cs
- CompressStream.cs
- XmlObjectSerializerReadContext.cs
- StyleXamlTreeBuilder.cs
- ToolStripProgressBar.cs
- safePerfProviderHandle.cs
- DiscoveryRequestHandler.cs
- TcpChannelHelper.cs
- LoginDesigner.cs
- CryptoHelper.cs
- EncodingTable.cs
- AttachedPropertyBrowsableAttribute.cs
- DateTimeFormatInfo.cs
- VoiceChangeEventArgs.cs
- DataGridViewColumnTypeEditor.cs
- ChannelFactory.cs
- CodeAssignStatement.cs
- Page.cs
- RequestTimeoutManager.cs
- Error.cs
- ListViewSelectEventArgs.cs
- XmlDataLoader.cs
- SiteIdentityPermission.cs
- QilBinary.cs
- FileNotFoundException.cs
- InfoCardTrace.cs
- filewebresponse.cs
- SafeWaitHandle.cs
- WebBrowsableAttribute.cs
- FixedPageStructure.cs
- StringUtil.cs
- Literal.cs
- SafeHandles.cs
- ToolStripItem.cs
- SafeWaitHandle.cs
- XPathDocumentIterator.cs