Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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;
}
}
}
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DeflateEmulationStream.cs
- EdmProperty.cs
- ImageListUtils.cs
- Image.cs
- RoutedPropertyChangedEventArgs.cs
- RedistVersionInfo.cs
- SamlAuthorizationDecisionClaimResource.cs
- Dictionary.cs
- ParseElementCollection.cs
- InstanceView.cs
- PolyBezierSegment.cs
- InstanceNormalEvent.cs
- ButtonStandardAdapter.cs
- QueryOperatorEnumerator.cs
- QilReplaceVisitor.cs
- NativeMethods.cs
- IgnoreFlushAndCloseStream.cs
- SQLSingle.cs
- ObjectDisposedException.cs
- EventDescriptorCollection.cs
- DigestTraceRecordHelper.cs
- DeploymentSectionCache.cs
- HandlerFactoryCache.cs
- basevalidator.cs
- EntityDataReader.cs
- SystemWebCachingSectionGroup.cs
- DataGridViewComboBoxColumn.cs
- HMACSHA1.cs
- SettingsPropertyNotFoundException.cs
- SchemaInfo.cs
- DbConnectionPoolGroup.cs
- HtmlTable.cs
- FloaterBaseParagraph.cs
- ControlUtil.cs
- TypeReference.cs
- WebPart.cs
- SqlNamer.cs
- TextPattern.cs
- X509CertificateInitiatorClientCredential.cs
- BitmapEffectOutputConnector.cs
- XmlBuffer.cs
- AutomationAttributeInfo.cs
- WebServiceReceive.cs
- PolicyValidationException.cs
- DataServiceQueryException.cs
- InputEventArgs.cs
- EntityDataSource.cs
- XmlNode.cs
- ValidationError.cs
- SerializationAttributes.cs
- Ipv6Element.cs
- NoneExcludedImageIndexConverter.cs
- ColorKeyFrameCollection.cs
- MouseCaptureWithinProperty.cs
- DecoderFallback.cs
- DbConnectionClosed.cs
- ProjectionPlan.cs
- TouchesOverProperty.cs
- XmlConvert.cs
- ArrayList.cs
- ImportContext.cs
- ClientConvert.cs
- JavaScriptObjectDeserializer.cs
- HiddenField.cs
- MasterPageCodeDomTreeGenerator.cs
- ScriptResourceDefinition.cs
- CutCopyPasteHelper.cs
- ExpressionNode.cs
- ThumbButtonInfo.cs
- MessageAction.cs
- Iis7Helper.cs
- Visitors.cs
- TypeForwardedFromAttribute.cs
- ValueHandle.cs
- httpapplicationstate.cs
- RequestCache.cs
- HyperLink.cs
- XmlChildNodes.cs
- SkipStoryboardToFill.cs
- EpmContentDeSerializerBase.cs
- XmlCharCheckingWriter.cs
- ModuleConfigurationInfo.cs
- DBPropSet.cs
- XsltInput.cs
- MessageDroppedTraceRecord.cs
- FontCacheLogic.cs
- ExtensionQuery.cs
- ListViewDeletedEventArgs.cs
- CacheEntry.cs
- XamlSerializerUtil.cs
- UnicastIPAddressInformationCollection.cs
- arc.cs
- CompositeFontParser.cs
- DataRecordObjectView.cs
- NavigationProgressEventArgs.cs
- TableItemPattern.cs
- PreDigestedSignedInfo.cs
- ProcessModuleCollection.cs
- OpCodes.cs
- Roles.cs