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
- WebConfigurationFileMap.cs
- IconConverter.cs
- UniqueConstraint.cs
- WorkItem.cs
- SymbolEqualComparer.cs
- XmlSchemaAll.cs
- PassportAuthenticationEventArgs.cs
- Semaphore.cs
- StopStoryboard.cs
- RuleProcessor.cs
- ImageSourceValueSerializer.cs
- DependsOnAttribute.cs
- FixedDocument.cs
- PtsContext.cs
- Point.cs
- Rules.cs
- TextTreeTextBlock.cs
- TileModeValidation.cs
- WSSecurityOneDotZeroReceiveSecurityHeader.cs
- SqlHelper.cs
- GAC.cs
- TemplateControl.cs
- SoapReflector.cs
- PreviewKeyDownEventArgs.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- Tracer.cs
- AsymmetricKeyExchangeFormatter.cs
- MsmqIntegrationReceiveParameters.cs
- ElapsedEventArgs.cs
- DefaultHttpHandler.cs
- DataSetMappper.cs
- AsymmetricSignatureDeformatter.cs
- DataGridViewSortCompareEventArgs.cs
- TimerElapsedEvenArgs.cs
- XmlSchemaExporter.cs
- ToolboxDataAttribute.cs
- Simplifier.cs
- UTF7Encoding.cs
- XmlMapping.cs
- ColumnCollection.cs
- TimeSpan.cs
- NumberFormatter.cs
- AddInAdapter.cs
- MsmqOutputChannel.cs
- SafeRightsManagementEnvironmentHandle.cs
- listviewsubitemcollectioneditor.cs
- EventLogger.cs
- ObjectListFieldCollection.cs
- BitmapDecoder.cs
- WinCategoryAttribute.cs
- ProtocolsConfiguration.cs
- XmlRawWriter.cs
- RouteCollection.cs
- DocumentPageViewAutomationPeer.cs
- CheckBoxStandardAdapter.cs
- ImageMapEventArgs.cs
- ReadOnlyAttribute.cs
- Win32Exception.cs
- _SslState.cs
- ping.cs
- EdmScalarPropertyAttribute.cs
- _SecureChannel.cs
- SamlAuthorityBinding.cs
- EntityWrapperFactory.cs
- Separator.cs
- DesignerActionKeyboardBehavior.cs
- TraceContextRecord.cs
- DbSourceCommand.cs
- XmlSortKey.cs
- ClientTarget.cs
- ToolboxItemFilterAttribute.cs
- DesignerTextViewAdapter.cs
- CodeGeneratorOptions.cs
- KeyInstance.cs
- ProfileSettingsCollection.cs
- RuntimeConfigLKG.cs
- HtmlHead.cs
- SqlTopReducer.cs
- _PooledStream.cs
- MultipartContentParser.cs
- XmlBinaryReaderSession.cs
- WindowsListViewItem.cs
- DocumentApplicationJournalEntry.cs
- XmlTextReaderImplHelpers.cs
- TTSEngineTypes.cs
- ErrorHandler.cs
- Light.cs
- HttpListenerRequest.cs
- ImportCatalogPart.cs
- InvalidateEvent.cs
- ExpressionNormalizer.cs
- BaseServiceProvider.cs
- XmlReflectionMember.cs
- PostBackOptions.cs
- SessionStateUtil.cs
- XmlSerializerAssemblyAttribute.cs
- XsdBuilder.cs
- MasterPage.cs
- XmlDataSourceView.cs
- ArrayExtension.cs