Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / 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; } ////// public bool Filterable { get { return _filterable; } } ///Indicates if the property is 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. //------------------------------------------------------------------------------ // // 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; } ////// public bool Filterable { get { return _filterable; } } ///Indicates if the property is 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DependencyPropertyHelper.cs
- EventLogInformation.cs
- OperationCanceledException.cs
- xmlfixedPageInfo.cs
- BamlLocalizabilityResolver.cs
- PointCollectionConverter.cs
- SettingsPropertyValueCollection.cs
- ObjectStorage.cs
- MenuItem.cs
- TcpStreams.cs
- DataGridViewColumnHeaderCell.cs
- BCLDebug.cs
- HostedNamedPipeTransportManager.cs
- XmlSchemaSequence.cs
- AnimationLayer.cs
- BoundsDrawingContextWalker.cs
- CultureTable.cs
- DataGridToolTip.cs
- NullableDoubleAverageAggregationOperator.cs
- DynamicRenderer.cs
- FlagsAttribute.cs
- ControlPropertyNameConverter.cs
- PathGeometry.cs
- DateTimeValueSerializerContext.cs
- JsonEncodingStreamWrapper.cs
- WebControl.cs
- ListQueryResults.cs
- TypeUtil.cs
- InputMethodStateTypeInfo.cs
- AudienceUriMode.cs
- ActivityBuilder.cs
- SequentialUshortCollection.cs
- HtmlElement.cs
- LinkedResource.cs
- HitTestFilterBehavior.cs
- cookiecollection.cs
- AcceleratedTokenProviderState.cs
- StylusLogic.cs
- CharacterMetricsDictionary.cs
- EnterpriseServicesHelper.cs
- X509ImageLogo.cs
- SizeConverter.cs
- AssemblyName.cs
- BaseHashHelper.cs
- WebPartManagerInternals.cs
- ColorAnimation.cs
- TextTreeTextElementNode.cs
- TextWriterEngine.cs
- WebPartActionVerb.cs
- SmiMetaDataProperty.cs
- LineGeometry.cs
- Bidi.cs
- Accessible.cs
- RotateTransform3D.cs
- CharacterHit.cs
- DateTimeOffset.cs
- SizeAnimationUsingKeyFrames.cs
- SQLMoneyStorage.cs
- XPathCompileException.cs
- InstanceLockLostException.cs
- UrlPath.cs
- SessionPageStatePersister.cs
- XmlAnyElementAttribute.cs
- TraceContextRecord.cs
- HttpModuleAction.cs
- WriteLineDesigner.xaml.cs
- TriggerActionCollection.cs
- CapiHashAlgorithm.cs
- ToolStripItem.cs
- ProcessHostConfigUtils.cs
- RemoteWebConfigurationHostServer.cs
- FixedSOMPageElement.cs
- BypassElementCollection.cs
- RecognizedWordUnit.cs
- NativeRightsManagementAPIsStructures.cs
- XPathParser.cs
- TemplatePartAttribute.cs
- ParallelQuery.cs
- CatalogPart.cs
- WorkflowTraceTransfer.cs
- AppSettingsExpressionEditor.cs
- TimeSpanSecondsConverter.cs
- DataGridViewCellStyleConverter.cs
- StrongNameMembershipCondition.cs
- AssemblyUtil.cs
- HtmlElementEventArgs.cs
- AssociatedControlConverter.cs
- ResourceExpressionBuilder.cs
- HotSpotCollectionEditor.cs
- SingleTagSectionHandler.cs
- XmlCharCheckingWriter.cs
- CodeAttributeArgument.cs
- HtmlHead.cs
- OperandQuery.cs
- TextInfo.cs
- BrushValueSerializer.cs
- PriorityRange.cs
- ObjectDataSourceMethodEventArgs.cs
- DataListGeneralPage.cs
- WebZone.cs