Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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. // //----------------------------------------------------------------------------- /* */ 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- X509UI.cs
- TableSectionStyle.cs
- OracleParameter.cs
- TextBoxBaseDesigner.cs
- SapiRecoContext.cs
- TypefaceMap.cs
- ItemCollection.cs
- XmlAttributes.cs
- XmlDataImplementation.cs
- StateWorkerRequest.cs
- BaseParser.cs
- _AutoWebProxyScriptHelper.cs
- UnsafePeerToPeerMethods.cs
- Model3D.cs
- xmlsaver.cs
- ToolStripDropDownClosedEventArgs.cs
- CodeObjectCreateExpression.cs
- PathNode.cs
- CharEntityEncoderFallback.cs
- OletxTransactionFormatter.cs
- ReadOnlyDictionary.cs
- SafePointer.cs
- RuleValidation.cs
- ISO2022Encoding.cs
- ComPlusTypeLoader.cs
- CompiledXpathExpr.cs
- DataGridViewTopLeftHeaderCell.cs
- ReferencedAssemblyResolver.cs
- Serializer.cs
- PropertyTabChangedEvent.cs
- BindingExpressionUncommonField.cs
- WebPartConnectionsConnectVerb.cs
- StronglyTypedResourceBuilder.cs
- OleDbFactory.cs
- ConditionCollection.cs
- Point.cs
- IdleTimeoutMonitor.cs
- IndexedString.cs
- AdvancedBindingPropertyDescriptor.cs
- FolderBrowserDialog.cs
- LambdaCompiler.Generated.cs
- WindowsScroll.cs
- Command.cs
- M3DUtil.cs
- LayoutEngine.cs
- ModelTypeConverter.cs
- EditorPartCollection.cs
- AssociatedControlConverter.cs
- PublishLicense.cs
- DataGridViewCellParsingEventArgs.cs
- SignedXml.cs
- XPathQilFactory.cs
- CheckoutException.cs
- HttpModuleAction.cs
- BindingBase.cs
- HWStack.cs
- SettingsPropertyValue.cs
- CompilerError.cs
- ConsoleTraceListener.cs
- BitStack.cs
- LocatorPart.cs
- SqlHelper.cs
- ObjectDataSourceStatusEventArgs.cs
- StylusSystemGestureEventArgs.cs
- SrgsElementFactory.cs
- PageAdapter.cs
- EdmPropertyAttribute.cs
- HtmlGenericControl.cs
- QueryCursorEventArgs.cs
- PermissionRequestEvidence.cs
- LinearKeyFrames.cs
- ExpressionNode.cs
- URL.cs
- Point.cs
- ListDictionary.cs
- KeyPullup.cs
- AssemblyCache.cs
- RC2.cs
- X509AsymmetricSecurityKey.cs
- ParentQuery.cs
- HtmlInputPassword.cs
- GenericRootAutomationPeer.cs
- QueryInterceptorAttribute.cs
- ItemMap.cs
- AnonymousIdentificationSection.cs
- DbUpdateCommandTree.cs
- columnmapkeybuilder.cs
- EventLogEntry.cs
- XmlSchemaAny.cs
- HebrewNumber.cs
- EastAsianLunisolarCalendar.cs
- TraceContextEventArgs.cs
- WebPartCatalogAddVerb.cs
- Brush.cs
- Interlocked.cs
- OutputBuffer.cs
- WsatServiceCertificate.cs
- HtmlTableCell.cs
- Oid.cs
- XmlTypeAttribute.cs