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
- ErrorFormatter.cs
- TextTreeExtractElementUndoUnit.cs
- XsdCachingReader.cs
- AttachmentCollection.cs
- XmlEnumAttribute.cs
- EdmPropertyAttribute.cs
- WindowsEditBox.cs
- ExceptionUtil.cs
- ObjectSecurity.cs
- BitmapDownload.cs
- JavaScriptObjectDeserializer.cs
- _MultipleConnectAsync.cs
- AttributeData.cs
- DataGridViewRowEventArgs.cs
- RouteCollection.cs
- WebPartCatalogAddVerb.cs
- OracleConnectionStringBuilder.cs
- BindingValueChangedEventArgs.cs
- SQLDoubleStorage.cs
- ControlLocalizer.cs
- AppDomainUnloadedException.cs
- SafeCryptoHandles.cs
- Rectangle.cs
- namescope.cs
- ListCommandEventArgs.cs
- QueryOutputWriter.cs
- DictionarySurrogate.cs
- DefinitionUpdate.cs
- SQLBoolean.cs
- ResourcePool.cs
- ObjectItemCollection.cs
- UnSafeCharBuffer.cs
- FileAuthorizationModule.cs
- DBSchemaTable.cs
- XmlDataSource.cs
- SvcMapFileSerializer.cs
- Column.cs
- TreeNodeSelectionProcessor.cs
- Parsers.cs
- CapabilitiesPattern.cs
- CompositeControl.cs
- FontEmbeddingManager.cs
- StrokeIntersection.cs
- PrintPageEvent.cs
- ConfigXmlText.cs
- SqlHelper.cs
- SqlCharStream.cs
- IgnoreFileBuildProvider.cs
- ConfigXmlComment.cs
- Oid.cs
- SqlDataSourceCommandEventArgs.cs
- XmlSchemaExternal.cs
- BuildProvider.cs
- QilLoop.cs
- SqlServer2KCompatibilityCheck.cs
- versioninfo.cs
- RotateTransform.cs
- LinqDataSource.cs
- BitStack.cs
- ObjectStateManagerMetadata.cs
- MimeMapping.cs
- SoapAttributeOverrides.cs
- UIPermission.cs
- SqlGenerator.cs
- Models.cs
- DataBindingCollection.cs
- DataGridViewCellConverter.cs
- HttpAsyncResult.cs
- Pair.cs
- MemberPathMap.cs
- UnsafeNativeMethodsMilCoreApi.cs
- FaultHandlingFilter.cs
- DatePickerAutomationPeer.cs
- OrderByLifter.cs
- DataSpaceManager.cs
- SerializationInfo.cs
- DataGridViewCellEventArgs.cs
- RotationValidation.cs
- XmlHelper.cs
- InstanceNormalEvent.cs
- QualifiedCellIdBoolean.cs
- ToolStripItemDataObject.cs
- SQLSingle.cs
- MULTI_QI.cs
- ActionItem.cs
- CompilerGlobalScopeAttribute.cs
- DrawingContextDrawingContextWalker.cs
- X509Logo.cs
- CryptographicAttribute.cs
- ConnectionInterfaceCollection.cs
- PersonalizationState.cs
- DesignerVerb.cs
- SrgsRule.cs
- DocumentApplicationJournalEntry.cs
- MenuItemBinding.cs
- DesignerForm.cs
- Token.cs
- ListBoxItemAutomationPeer.cs
- DebugViewWriter.cs
- WindowsEditBoxRange.cs