Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / FilterableAttribute.cs / 1305376 / 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; ////// [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. // //----------------------------------------------------------------------------- /* */ namespace System.Web.UI { using System; using System.Collections; using System.ComponentModel; using System.Security.Permissions; ////// [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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlEncoding.cs
- remotingproxy.cs
- PipelineDeploymentState.cs
- RectKeyFrameCollection.cs
- DataGridItemCollection.cs
- Button.cs
- ConfigXmlSignificantWhitespace.cs
- TextServicesHost.cs
- FunctionCommandText.cs
- FunctionDetailsReader.cs
- RunInstallerAttribute.cs
- MappingModelBuildProvider.cs
- EmptyEnumerator.cs
- HttpFileCollection.cs
- SqlMethodCallConverter.cs
- FileDialog_Vista.cs
- EffectiveValueEntry.cs
- StateMachineSubscriptionManager.cs
- _CommandStream.cs
- ThaiBuddhistCalendar.cs
- TypeElement.cs
- PropertyStore.cs
- RuntimeCompatibilityAttribute.cs
- ContextMenuAutomationPeer.cs
- hebrewshape.cs
- storepermissionattribute.cs
- NonParentingControl.cs
- HttpListenerContext.cs
- MimeWriter.cs
- Activity.cs
- EnumConverter.cs
- SigningCredentials.cs
- UserPreference.cs
- SpotLight.cs
- Point3D.cs
- InvalidProgramException.cs
- DefaultWorkflowLoaderService.cs
- MessageVersionConverter.cs
- OutOfMemoryException.cs
- SoapEnumAttribute.cs
- Scene3D.cs
- PropertyKey.cs
- BoundsDrawingContextWalker.cs
- _ConnectStream.cs
- ServiceProviders.cs
- TextEditorLists.cs
- Crypto.cs
- Listener.cs
- HttpModuleAction.cs
- BamlVersionHeader.cs
- SmtpCommands.cs
- AssemblyBuilder.cs
- arabicshape.cs
- OverflowException.cs
- QueryOperationResponseOfT.cs
- DbConnectionPoolGroupProviderInfo.cs
- Atom10ItemFormatter.cs
- CookielessHelper.cs
- AliasedSlot.cs
- ServiceControllerDesigner.cs
- mansign.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- PathGradientBrush.cs
- SerializationAttributes.cs
- SynchronizedDispatch.cs
- BitmapEffect.cs
- Helpers.cs
- BitVector32.cs
- SSmlParser.cs
- SmtpNtlmAuthenticationModule.cs
- ToolTipAutomationPeer.cs
- UserControlBuildProvider.cs
- AppSecurityManager.cs
- ScrollViewer.cs
- SimpleWorkerRequest.cs
- CorrelationManager.cs
- GridViewDeleteEventArgs.cs
- FontCacheUtil.cs
- SqlClientPermission.cs
- DataRowCollection.cs
- WebOperationContext.cs
- DrawListViewSubItemEventArgs.cs
- UICuesEvent.cs
- StateMachineWorkflowDesigner.cs
- ConstructorBuilder.cs
- SessionSwitchEventArgs.cs
- Interlocked.cs
- OutputCacheSettingsSection.cs
- InitiatorSessionSymmetricTransportSecurityProtocol.cs
- KeyValueConfigurationElement.cs
- SuppressMessageAttribute.cs
- BindingManagerDataErrorEventArgs.cs
- PageHandlerFactory.cs
- CroppedBitmap.cs
- WhitespaceRule.cs
- Knowncolors.cs
- Column.cs
- SkewTransform.cs
- DecimalAnimation.cs
- GatewayIPAddressInformationCollection.cs