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
- FixedPageProcessor.cs
- BaseTreeIterator.cs
- _ScatterGatherBuffers.cs
- CompressedStack.cs
- LinqDataSourceContextData.cs
- RowCache.cs
- StubHelpers.cs
- DesignTimeData.cs
- APCustomTypeDescriptor.cs
- RelationshipSet.cs
- EventMap.cs
- TabletDevice.cs
- IApplicationTrustManager.cs
- FontWeights.cs
- ActivationArguments.cs
- MergeLocalizationDirectives.cs
- LogReservationCollection.cs
- BaseHashHelper.cs
- NativeWindow.cs
- Control.cs
- HierarchicalDataSourceControl.cs
- ApplicationDirectoryMembershipCondition.cs
- WebPartTransformerAttribute.cs
- ExceptionAggregator.cs
- SchemaElementDecl.cs
- TypedAsyncResult.cs
- Classification.cs
- ServiceEndpointCollection.cs
- LinqDataSourceStatusEventArgs.cs
- Slider.cs
- SqlDuplicator.cs
- TextBoxDesigner.cs
- WindowShowOrOpenTracker.cs
- TextRangeEdit.cs
- Size3D.cs
- WindowsRichEdit.cs
- DataControlImageButton.cs
- DefinitionUpdate.cs
- Size3D.cs
- FindCriteriaCD1.cs
- SQLChars.cs
- Activity.cs
- NameNode.cs
- dsa.cs
- OrderByExpression.cs
- ListDictionaryInternal.cs
- PermissionSetTriple.cs
- SubclassTypeValidatorAttribute.cs
- OleDbRowUpdatedEvent.cs
- CertificateManager.cs
- NavigationWindow.cs
- OdbcStatementHandle.cs
- StreamInfo.cs
- HttpCookie.cs
- DataBoundLiteralControl.cs
- OleDbFactory.cs
- UTF32Encoding.cs
- SQLInt16.cs
- MgmtConfigurationRecord.cs
- XmlSerializerNamespaces.cs
- DesigntimeLicenseContextSerializer.cs
- ToolBarTray.cs
- Vector.cs
- TreeViewDesigner.cs
- UrlPropertyAttribute.cs
- ITextView.cs
- UpdateCommand.cs
- HttpApplicationStateBase.cs
- ExpressionDumper.cs
- TraceHwndHost.cs
- StructuralType.cs
- LayoutExceptionEventArgs.cs
- XPathNodeList.cs
- NativeMethods.cs
- TdsParameterSetter.cs
- PolyLineSegmentFigureLogic.cs
- Transform3D.cs
- ScalarOps.cs
- SoapMessage.cs
- SignedInfo.cs
- X509Utils.cs
- ResetableIterator.cs
- Encoding.cs
- WsdlBuildProvider.cs
- FileDialog_Vista.cs
- Paragraph.cs
- SmiEventSink_DeferedProcessing.cs
- BreakSafeBase.cs
- QilCloneVisitor.cs
- SHA256Managed.cs
- XmlIlGenerator.cs
- GradientBrush.cs
- MinimizableAttributeTypeConverter.cs
- RuntimeEnvironment.cs
- AuthenticationConfig.cs
- TemplateAction.cs
- HwndProxyElementProvider.cs
- ZipIOLocalFileBlock.cs
- Underline.cs
- arabicshape.cs