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
- InternalPolicyElement.cs
- AppDomainProtocolHandler.cs
- Peer.cs
- ArrayElementGridEntry.cs
- LabelLiteral.cs
- MarshalByValueComponent.cs
- DataViewManager.cs
- GridLengthConverter.cs
- HttpInputStream.cs
- WebPartDisplayMode.cs
- IPEndPoint.cs
- HttpConfigurationContext.cs
- FormViewDeleteEventArgs.cs
- DWriteFactory.cs
- ClientEventManager.cs
- BuildDependencySet.cs
- TextParagraphCache.cs
- EntityProviderFactory.cs
- LayoutUtils.cs
- OperatingSystemVersionCheck.cs
- DataControlImageButton.cs
- WindowAutomationPeer.cs
- PkcsUtils.cs
- CollectionView.cs
- VectorKeyFrameCollection.cs
- TextEncodedRawTextWriter.cs
- OptionUsage.cs
- _AutoWebProxyScriptEngine.cs
- WebPartConnection.cs
- RectAnimationBase.cs
- BulletChrome.cs
- TextTreeInsertUndoUnit.cs
- DataGridViewCheckBoxCell.cs
- TdsParameterSetter.cs
- SoapSchemaExporter.cs
- Path.cs
- ToolStripPanelRenderEventArgs.cs
- HttpCachePolicy.cs
- FixedSOMTextRun.cs
- SiteMapPath.cs
- XslTransform.cs
- CurrencyWrapper.cs
- ParentControlDesigner.cs
- PropagationProtocolsTracing.cs
- CollectionsUtil.cs
- PerformanceCounterLib.cs
- StreamWriter.cs
- InfoCardRequestException.cs
- IndentTextWriter.cs
- HttpCachePolicyWrapper.cs
- RuleInfoComparer.cs
- SQLGuid.cs
- XLinq.cs
- DependencyPropertyChangedEventArgs.cs
- OleDbTransaction.cs
- ColumnMapCopier.cs
- JsonServiceDocumentSerializer.cs
- PropertyEntry.cs
- Site.cs
- SingleAnimation.cs
- Condition.cs
- XhtmlMobileTextWriter.cs
- DetailsViewInsertedEventArgs.cs
- PageFunction.cs
- IteratorFilter.cs
- ZipIOCentralDirectoryFileHeader.cs
- BitmapMetadataBlob.cs
- ModelPropertyDescriptor.cs
- RotateTransform.cs
- Expression.cs
- AstTree.cs
- diagnosticsswitches.cs
- FieldNameLookup.cs
- HtmlValidationSummaryAdapter.cs
- SecureStringHasher.cs
- OptionalMessageQuery.cs
- TreeSet.cs
- PerspectiveCamera.cs
- ConfigurationSettings.cs
- UTF7Encoding.cs
- RuleSetDialog.cs
- NetTcpBinding.cs
- FileLogRecord.cs
- ListViewItem.cs
- Dispatcher.cs
- BinaryWriter.cs
- FontSizeConverter.cs
- TraceEventCache.cs
- WebPartAuthorizationEventArgs.cs
- SizeAnimationBase.cs
- ComponentFactoryHelpers.cs
- PseudoWebRequest.cs
- DataGridViewMethods.cs
- ArgumentNullException.cs
- Menu.cs
- TraceSection.cs
- EmptyStringExpandableObjectConverter.cs
- BamlLocalizer.cs
- LingerOption.cs
- MiniConstructorInfo.cs