Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- ObjectDataSourceStatusEventArgs.cs
- SqlMethodTransformer.cs
- LogSwitch.cs
- httpserverutility.cs
- VSDExceptions.cs
- WebPartsSection.cs
- HttpVersion.cs
- safex509handles.cs
- TreeViewDesigner.cs
- AnimationClock.cs
- TextCompositionManager.cs
- Comparer.cs
- InputScope.cs
- IMembershipProvider.cs
- UIElement.cs
- DebuggerAttributes.cs
- GiveFeedbackEventArgs.cs
- DLinqDataModelProvider.cs
- DiscreteKeyFrames.cs
- UITypeEditor.cs
- ContentElement.cs
- QuaternionKeyFrameCollection.cs
- EventListener.cs
- XmlReader.cs
- DecimalAnimationUsingKeyFrames.cs
- NodeInfo.cs
- DispatcherOperation.cs
- AttachmentService.cs
- CoTaskMemUnicodeSafeHandle.cs
- BuildResultCache.cs
- HwndMouseInputProvider.cs
- XmlQualifiedNameTest.cs
- CheckBoxField.cs
- FastEncoderStatics.cs
- ContractsBCL.cs
- DockAndAnchorLayout.cs
- RightsManagementInformation.cs
- ManipulationStartedEventArgs.cs
- querybuilder.cs
- BinaryObjectInfo.cs
- BamlLocalizationDictionary.cs
- base64Transforms.cs
- ProfileService.cs
- DataKeyArray.cs
- TemplatedWizardStep.cs
- XamlTemplateSerializer.cs
- ColumnReorderedEventArgs.cs
- EventLogEntry.cs
- AnnotationResource.cs
- ColorConvertedBitmapExtension.cs
- InlinedLocationReference.cs
- RewritingSimplifier.cs
- WebPartZoneCollection.cs
- NullableDecimalMinMaxAggregationOperator.cs
- ObservableDictionary.cs
- WebPartUserCapability.cs
- SqlConnectionPoolGroupProviderInfo.cs
- FindSimilarActivitiesVerb.cs
- EncoderReplacementFallback.cs
- ExpressionCopier.cs
- VerticalAlignConverter.cs
- DataObjectFieldAttribute.cs
- ProfilePropertySettings.cs
- SchemaImporterExtension.cs
- TextBreakpoint.cs
- CalendarKeyboardHelper.cs
- ObjectMaterializedEventArgs.cs
- ActivityDesignerLayoutSerializers.cs
- AudioStateChangedEventArgs.cs
- WorkflowRuntimeSection.cs
- GPRECTF.cs
- InvalidDocumentContentsException.cs
- XmlHelper.cs
- TdsValueSetter.cs
- GlobalizationAssembly.cs
- AppSettingsReader.cs
- PrivacyNoticeBindingElement.cs
- safemediahandle.cs
- FontCollection.cs
- SharedStatics.cs
- ObservableDictionary.cs
- UiaCoreProviderApi.cs
- ReadContentAsBinaryHelper.cs
- CounterSample.cs
- Partitioner.cs
- BitmapEffectDrawingContextWalker.cs
- PeerInvitationResponse.cs
- MeshGeometry3D.cs
- SendingRequestEventArgs.cs
- WsdlBuildProvider.cs
- AutomationProperties.cs
- DbMetaDataCollectionNames.cs
- DataSourceXmlSerializationAttribute.cs
- JoinTreeSlot.cs
- DnsPermission.cs
- AnnotationHelper.cs
- ContainerVisual.cs
- AffineTransform3D.cs
- SourceInterpreter.cs
- ImageListImage.cs