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
- WebBaseEventKeyComparer.cs
- StyleSheet.cs
- HttpStreamMessageEncoderFactory.cs
- CookieProtection.cs
- DataGrid.cs
- DtdParser.cs
- ExpressionWriter.cs
- OdbcError.cs
- ExpressionNode.cs
- PointIndependentAnimationStorage.cs
- WebPartConnectionsCloseVerb.cs
- CreateUserWizardStep.cs
- CreateUserErrorEventArgs.cs
- XmlAttributeCollection.cs
- OdbcDataReader.cs
- FamilyMap.cs
- WebPartActionVerb.cs
- UserControlCodeDomTreeGenerator.cs
- Imaging.cs
- MessageHeader.cs
- DictionaryBase.cs
- PathSegmentCollection.cs
- EnumConverter.cs
- NativeBuffer.cs
- RawUIStateInputReport.cs
- MenuItemStyleCollectionEditor.cs
- DBProviderConfigurationHandler.cs
- DeleteWorkflowOwnerCommand.cs
- TdsParserSafeHandles.cs
- WebPartConnectionsEventArgs.cs
- OdbcFactory.cs
- NavigatorOutput.cs
- NameValuePermission.cs
- ResourceSetExpression.cs
- TimeSpanStorage.cs
- HebrewNumber.cs
- Effect.cs
- Menu.cs
- ToolZone.cs
- WithStatement.cs
- M3DUtil.cs
- PathSegment.cs
- LoadedOrUnloadedOperation.cs
- EntityContainerAssociationSet.cs
- SqlInternalConnectionSmi.cs
- PersonalizablePropertyEntry.cs
- DateTimeEditor.cs
- PenContext.cs
- GroupStyle.cs
- HtmlEmptyTagControlBuilder.cs
- MenuAdapter.cs
- XmlSchemaAnyAttribute.cs
- PasswordDeriveBytes.cs
- ApplicationProxyInternal.cs
- PenCursorManager.cs
- EmptyEnumerator.cs
- CompiledIdentityConstraint.cs
- ControlHelper.cs
- SocketAddress.cs
- BaseValidator.cs
- TreeNodeEventArgs.cs
- DrawListViewColumnHeaderEventArgs.cs
- MLangCodePageEncoding.cs
- SqlError.cs
- Drawing.cs
- TemplateComponentConnector.cs
- unsafenativemethodstextservices.cs
- UserPreferenceChangedEventArgs.cs
- Int64KeyFrameCollection.cs
- HwndSource.cs
- XmlAttributeAttribute.cs
- BamlBinaryReader.cs
- ColumnHeaderCollectionEditor.cs
- MatchSingleFxEngineOpcode.cs
- ReadOnlyPropertyMetadata.cs
- PageRouteHandler.cs
- ServiceHttpHandlerFactory.cs
- EarlyBoundInfo.cs
- DotExpr.cs
- IisTraceWebEventProvider.cs
- FileAccessException.cs
- EnumUnknown.cs
- DataKeyCollection.cs
- BitArray.cs
- XPathDocumentBuilder.cs
- PointCollection.cs
- SafeHandles.cs
- JsonFormatGeneratorStatics.cs
- BasePattern.cs
- PictureBox.cs
- ItemContainerPattern.cs
- PrePrepareMethodAttribute.cs
- MachineKeySection.cs
- MailWebEventProvider.cs
- ServicePoint.cs
- FloaterParaClient.cs
- WebPartMenuStyle.cs
- AsymmetricAlgorithm.cs
- ComboBoxAutomationPeer.cs
- ConfigurationStrings.cs