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
- SqlExpressionNullability.cs
- X509CertificateValidationMode.cs
- xamlnodes.cs
- ReadOnlyCollection.cs
- FormClosingEvent.cs
- ThreadStateException.cs
- WebResourceAttribute.cs
- SerializerWriterEventHandlers.cs
- UnicastIPAddressInformationCollection.cs
- XmlSchemaSequence.cs
- PaperSource.cs
- FlowDocumentReader.cs
- BamlTreeNode.cs
- X509CertificateValidationMode.cs
- KeyValueConfigurationElement.cs
- SequentialUshortCollection.cs
- CompModHelpers.cs
- SwitchAttribute.cs
- ConfigurationStrings.cs
- EnterpriseServicesHelper.cs
- MaterialGroup.cs
- TableLayoutStyle.cs
- Registry.cs
- GetKeyedHashRequest.cs
- SqlConnection.cs
- MimeObjectFactory.cs
- PKCS1MaskGenerationMethod.cs
- DataColumnCollection.cs
- SiteMapProvider.cs
- SvcMapFileSerializer.cs
- UriTemplateVariableQueryValue.cs
- ExpressionBuilder.cs
- CodeSnippetExpression.cs
- AsnEncodedData.cs
- DesignTimeVisibleAttribute.cs
- CharacterShapingProperties.cs
- CustomTrackingQuery.cs
- SharedDp.cs
- CompilerCollection.cs
- GcSettings.cs
- SendOperation.cs
- WsdlInspector.cs
- SymLanguageVendor.cs
- TypeUnloadedException.cs
- NullableFloatMinMaxAggregationOperator.cs
- HiddenFieldPageStatePersister.cs
- IisTraceListener.cs
- __ComObject.cs
- DataGridViewRowsAddedEventArgs.cs
- SchemaElementLookUpTable.cs
- TypeDescriptionProvider.cs
- Attributes.cs
- SystemIPv4InterfaceProperties.cs
- DataGridViewTextBoxEditingControl.cs
- httpstaticobjectscollection.cs
- XmlBinaryReader.cs
- ColorKeyFrameCollection.cs
- ScrollViewer.cs
- GridEntry.cs
- BufferedGraphics.cs
- Event.cs
- SelectionProviderWrapper.cs
- SiteMapHierarchicalDataSourceView.cs
- ObjectAssociationEndMapping.cs
- ValidatingReaderNodeData.cs
- SchemaObjectWriter.cs
- ReadOnlyPropertyMetadata.cs
- listitem.cs
- TimeSpanStorage.cs
- XmlChoiceIdentifierAttribute.cs
- ConfigXmlDocument.cs
- PerfService.cs
- Menu.cs
- prefixendpointaddressmessagefiltertable.cs
- ContextMenu.cs
- ObjectItemLoadingSessionData.cs
- HtmlCommandAdapter.cs
- TypeReference.cs
- EventTrigger.cs
- PictureBox.cs
- XmlMembersMapping.cs
- GridView.cs
- Parsers.cs
- DesignTimeTemplateParser.cs
- SByte.cs
- NativeBuffer.cs
- CodeConditionStatement.cs
- KnownTypeAttribute.cs
- Misc.cs
- SurrogateEncoder.cs
- ListControl.cs
- ImagingCache.cs
- HMACMD5.cs
- ProtectedProviderSettings.cs
- ProfileSection.cs
- ActivityBindForm.Designer.cs
- ObjectQueryState.cs
- FontNameEditor.cs
- EventLogEntry.cs
- CodeObject.cs