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
- RenderCapability.cs
- HttpInputStream.cs
- RenderDataDrawingContext.cs
- IdentityReference.cs
- ExpressionBindingCollection.cs
- MemoryMappedView.cs
- _NegoState.cs
- ValidationError.cs
- HttpHandlerActionCollection.cs
- TextParagraphProperties.cs
- ComboBoxHelper.cs
- CellPartitioner.cs
- DrawingContextDrawingContextWalker.cs
- TreeNodeEventArgs.cs
- FastPropertyAccessor.cs
- Operand.cs
- InputScopeNameConverter.cs
- CheckBoxPopupAdapter.cs
- KnownTypes.cs
- ApplicationSecurityManager.cs
- DesignerSerializationManager.cs
- SerializationAttributes.cs
- ToolStripSettings.cs
- LinqToSqlWrapper.cs
- cookiecontainer.cs
- DataGridColumnHeaderCollection.cs
- RequestQueue.cs
- DelegatingTypeDescriptionProvider.cs
- TreeViewAutomationPeer.cs
- ToolStripDropDownItem.cs
- TimeSpanValidatorAttribute.cs
- GeneratedContractType.cs
- FrameSecurityDescriptor.cs
- TreeViewDesigner.cs
- CompiledRegexRunner.cs
- ThreadStaticAttribute.cs
- ConstraintCollection.cs
- WebPartDeleteVerb.cs
- WindowsRichEdit.cs
- WebPartAuthorizationEventArgs.cs
- CodeCatchClause.cs
- TemplateManager.cs
- InstanceKeyNotReadyException.cs
- ThemeDirectoryCompiler.cs
- ColumnWidthChangingEvent.cs
- HostVisual.cs
- OleDbParameter.cs
- Column.cs
- activationcontext.cs
- TreeViewBindingsEditor.cs
- ObsoleteAttribute.cs
- HttpResponse.cs
- FacetValueContainer.cs
- XmlSchemaSimpleType.cs
- TextFragmentEngine.cs
- AttachedPropertyBrowsableForChildrenAttribute.cs
- selecteditemcollection.cs
- ComContractElementCollection.cs
- ConstructorNeedsTagAttribute.cs
- Splitter.cs
- ScrollPattern.cs
- AssemblyBuilder.cs
- LinqDataSourceDisposeEventArgs.cs
- ExpressionCopier.cs
- FontStyle.cs
- SqlWebEventProvider.cs
- MessageBuilder.cs
- DecoderExceptionFallback.cs
- FontFamilyConverter.cs
- FixedPageProcessor.cs
- StaticSiteMapProvider.cs
- ScrollableControl.cs
- SqlMetaData.cs
- ColorBlend.cs
- PeerNameRegistration.cs
- ProgressBar.cs
- IndependentAnimationStorage.cs
- dbdatarecord.cs
- TextFindEngine.cs
- ManagementObjectCollection.cs
- TextSearch.cs
- MapPathBasedVirtualPathProvider.cs
- FontStretches.cs
- DictionaryContent.cs
- TextTreeRootTextBlock.cs
- LinqDataSourceContextEventArgs.cs
- recordstatefactory.cs
- MembershipAdapter.cs
- SafeLocalAllocation.cs
- RotateTransform3D.cs
- EndpointAddressMessageFilterTable.cs
- TypeDependencyAttribute.cs
- PathFigureCollectionValueSerializer.cs
- RegexStringValidatorAttribute.cs
- x509utils.cs
- LocalizationComments.cs
- EntityAdapter.cs
- Socket.cs
- DashStyles.cs
- ScriptIgnoreAttribute.cs