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
- InstanceHandle.cs
- FontFaceLayoutInfo.cs
- SqlDataSourceDesigner.cs
- Transform3DCollection.cs
- GenericRootAutomationPeer.cs
- RecordsAffectedEventArgs.cs
- TextComposition.cs
- DebuggerAttributes.cs
- DBAsyncResult.cs
- Brushes.cs
- ModelTreeEnumerator.cs
- WorkflowRuntime.cs
- ToolStripPanelRenderEventArgs.cs
- ListViewContainer.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- DoubleLink.cs
- SafeLibraryHandle.cs
- documentsequencetextcontainer.cs
- Types.cs
- SeverityFilter.cs
- InvalidPrinterException.cs
- Rotation3D.cs
- InvalidComObjectException.cs
- DataGridHeadersVisibilityToVisibilityConverter.cs
- DurableInstance.cs
- XmlSchemaElement.cs
- Socket.cs
- WrapPanel.cs
- ImpersonateTokenRef.cs
- RestClientProxyHandler.cs
- SqlConnectionString.cs
- QueryNode.cs
- StateItem.cs
- CryptoApi.cs
- StreamMarshaler.cs
- ReadWriteObjectLock.cs
- SynchronizedInputPattern.cs
- XPathAncestorIterator.cs
- EntityDataSourceConfigureObjectContext.cs
- SplitterEvent.cs
- PrintDialog.cs
- Selector.cs
- ParenthesizePropertyNameAttribute.cs
- ByteAnimation.cs
- MethodBody.cs
- Pointer.cs
- XmlQualifiedName.cs
- GPRECTF.cs
- TdsParser.cs
- HwndHostAutomationPeer.cs
- DataGridCell.cs
- ColumnReorderedEventArgs.cs
- Util.cs
- regiisutil.cs
- ListViewCancelEventArgs.cs
- TriggerBase.cs
- ObjectStateFormatter.cs
- DataGridComponentEditor.cs
- CheckBox.cs
- CommandEventArgs.cs
- GridViewItemAutomationPeer.cs
- BlobPersonalizationState.cs
- KeyConverter.cs
- SoapCodeExporter.cs
- PackUriHelper.cs
- ScriptingSectionGroup.cs
- EventLogEntry.cs
- ObjectItemCollectionAssemblyCacheEntry.cs
- NetPeerTcpBindingElement.cs
- DataService.cs
- TraceEventCache.cs
- ExpressionBuilder.cs
- DataGridViewImageColumn.cs
- RelationshipEndCollection.cs
- SynchronizationLockException.cs
- RecommendedAsConfigurableAttribute.cs
- iisPickupDirectory.cs
- GroupBoxDesigner.cs
- XmlSubtreeReader.cs
- OdbcConnectionPoolProviderInfo.cs
- SoapInteropTypes.cs
- DuplexSecurityProtocolFactory.cs
- InputBuffer.cs
- ContextQuery.cs
- BoolExpression.cs
- HtmlTextViewAdapter.cs
- RegularExpressionValidator.cs
- ModifierKeysValueSerializer.cs
- TextPointerBase.cs
- ColumnCollection.cs
- TokenCreationParameter.cs
- SqlDataSourceQueryConverter.cs
- HScrollBar.cs
- Underline.cs
- UnsafeNativeMethodsCLR.cs
- SHA512.cs
- SqlNotificationEventArgs.cs
- GroupByExpressionRewriter.cs
- TransformerInfo.cs
- TreeViewItem.cs