Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Base / System / ComponentModel / PropertyFilterAttribute.cs / 1 / PropertyFilterAttribute.cs
namespace System.ComponentModel { using System; using System.Diagnostics.CodeAnalysis; ////// This attribute is a "query" attribute. It is /// an attribute that causes the type description provider /// to narrow the scope of returned properties. It differs /// from normal attributes in that it cannot actually be /// placed on a class as metadata and that the filter mechanism /// is code rather than static metadata. /// [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] public sealed class PropertyFilterAttribute : Attribute { //------------------------------------------------------ // // Constructors // //----------------------------------------------------- #region Constructors ////// Creates a new attribute. /// public PropertyFilterAttribute(PropertyFilterOptions filter) { _filter = filter; } #endregion Constructors //----------------------------------------------------- // // Public Methods // //----------------------------------------------------- #region Public Methods ////// Override of Object.Equals that returns true if the filters /// contained in both attributes match. /// public override bool Equals(object value) { PropertyFilterAttribute a = value as PropertyFilterAttribute; if (a != null && a._filter.Equals(_filter)) { return true; } return false; } ////// Override of Object.GetHashCode. /// public override int GetHashCode() { return _filter.GetHashCode(); } ////// Match determines if one attribute "matches" another. For /// attributes that store flags, a match may be different from /// an equals. For example, a filter of SetValid matches a /// filter of All, because All is a merge of all filter values. /// public override bool Match(object value) { PropertyFilterAttribute a = value as PropertyFilterAttribute; if (a == null) return false; return ((_filter & a._filter) == _filter); } #endregion Public Methods //------------------------------------------------------ // // Public Operators // //----------------------------------------------------- //------------------------------------------------------ // // Public Properties // //------------------------------------------------------ #region Public Properties ////// The filter value passed into the constructor. /// public PropertyFilterOptions Filter { get { return _filter; } } #endregion Public Properties //----------------------------------------------------- // // Public Events // //------------------------------------------------------ //----------------------------------------------------- // // Public Fields // //----------------------------------------------------- #region Public Fields ////// Attributes may declare a Default field that indicates /// what should be done if the attribute is not defined. /// Our default is to return all properties. /// [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] public static readonly PropertyFilterAttribute Default = new PropertyFilterAttribute(PropertyFilterOptions.All); #endregion Public Fields //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ #region Private Fields private PropertyFilterOptions _filter; #endregion Private Fields } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. namespace System.ComponentModel { using System; using System.Diagnostics.CodeAnalysis; ////// This attribute is a "query" attribute. It is /// an attribute that causes the type description provider /// to narrow the scope of returned properties. It differs /// from normal attributes in that it cannot actually be /// placed on a class as metadata and that the filter mechanism /// is code rather than static metadata. /// [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] public sealed class PropertyFilterAttribute : Attribute { //------------------------------------------------------ // // Constructors // //----------------------------------------------------- #region Constructors ////// Creates a new attribute. /// public PropertyFilterAttribute(PropertyFilterOptions filter) { _filter = filter; } #endregion Constructors //----------------------------------------------------- // // Public Methods // //----------------------------------------------------- #region Public Methods ////// Override of Object.Equals that returns true if the filters /// contained in both attributes match. /// public override bool Equals(object value) { PropertyFilterAttribute a = value as PropertyFilterAttribute; if (a != null && a._filter.Equals(_filter)) { return true; } return false; } ////// Override of Object.GetHashCode. /// public override int GetHashCode() { return _filter.GetHashCode(); } ////// Match determines if one attribute "matches" another. For /// attributes that store flags, a match may be different from /// an equals. For example, a filter of SetValid matches a /// filter of All, because All is a merge of all filter values. /// public override bool Match(object value) { PropertyFilterAttribute a = value as PropertyFilterAttribute; if (a == null) return false; return ((_filter & a._filter) == _filter); } #endregion Public Methods //------------------------------------------------------ // // Public Operators // //----------------------------------------------------- //------------------------------------------------------ // // Public Properties // //------------------------------------------------------ #region Public Properties ////// The filter value passed into the constructor. /// public PropertyFilterOptions Filter { get { return _filter; } } #endregion Public Properties //----------------------------------------------------- // // Public Events // //------------------------------------------------------ //----------------------------------------------------- // // Public Fields // //----------------------------------------------------- #region Public Fields ////// Attributes may declare a Default field that indicates /// what should be done if the attribute is not defined. /// Our default is to return all properties. /// [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] public static readonly PropertyFilterAttribute Default = new PropertyFilterAttribute(PropertyFilterOptions.All); #endregion Public Fields //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ #region Private Fields private PropertyFilterOptions _filter; #endregion Private Fields } } // 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
- CellParagraph.cs
- OperatorExpressions.cs
- ObjectConverter.cs
- DbConnectionOptions.cs
- ToolStripItemEventArgs.cs
- DataGridDetailsPresenterAutomationPeer.cs
- IndexedEnumerable.cs
- Guid.cs
- OrderToken.cs
- XmlEncodedRawTextWriter.cs
- QilInvokeLateBound.cs
- Events.cs
- Paragraph.cs
- AdornerDecorator.cs
- RetrieveVirtualItemEventArgs.cs
- ResourceManager.cs
- FileIOPermission.cs
- ArgumentNullException.cs
- SafeFileMappingHandle.cs
- Inline.cs
- Mutex.cs
- RefreshEventArgs.cs
- PhonemeConverter.cs
- FormatConvertedBitmap.cs
- xdrvalidator.cs
- DependencyObjectCodeDomSerializer.cs
- HashCodeCombiner.cs
- ToolStripPanelRow.cs
- Animatable.cs
- DataGridViewAccessibleObject.cs
- ColorTransformHelper.cs
- JsonReader.cs
- CodeArrayCreateExpression.cs
- Crypto.cs
- EnumerableRowCollection.cs
- TableCellAutomationPeer.cs
- Axis.cs
- SimpleWorkerRequest.cs
- CombinedGeometry.cs
- OdbcConnectionFactory.cs
- TableDetailsRow.cs
- CapabilitiesPattern.cs
- EntityDataSourceWrapperPropertyDescriptor.cs
- ToolboxCategory.cs
- XmlAnyAttributeAttribute.cs
- ViewBox.cs
- HwndMouseInputProvider.cs
- ISO2022Encoding.cs
- SiteOfOriginPart.cs
- TextEditorSelection.cs
- MediaCommands.cs
- SortableBindingList.cs
- TextModifierScope.cs
- StatusInfoItem.cs
- ModelVisual3D.cs
- TrackingCondition.cs
- ScriptManagerProxy.cs
- PropertyToken.cs
- PolyQuadraticBezierSegment.cs
- SelectionHighlightInfo.cs
- MarshalByRefObject.cs
- SerializationException.cs
- WsatAdminException.cs
- SchemaEntity.cs
- OdbcInfoMessageEvent.cs
- IOThreadScheduler.cs
- PackageDigitalSignature.cs
- AppDomainCompilerProxy.cs
- AssertHelper.cs
- Vector3DCollection.cs
- OleDbDataAdapter.cs
- CredentialCache.cs
- JoinTreeSlot.cs
- RichTextBoxConstants.cs
- SerializationUtilities.cs
- DbConnectionPoolGroupProviderInfo.cs
- HandleRef.cs
- SchemaMapping.cs
- WebAdminConfigurationHelper.cs
- EnterpriseServicesHelper.cs
- PrintingPermission.cs
- ImageCodecInfo.cs
- AssemblyGen.cs
- SoapIgnoreAttribute.cs
- OdbcParameter.cs
- SimpleTextLine.cs
- NetCodeGroup.cs
- ImpersonateTokenRef.cs
- CookieProtection.cs
- ScrollProviderWrapper.cs
- EncryptedPackageFilter.cs
- ObjectListFieldCollection.cs
- RegexMatch.cs
- MimeTypeMapper.cs
- IsolatedStorageException.cs
- RequestCacheValidator.cs
- WhiteSpaceTrimStringConverter.cs
- documentsequencetextview.cs
- NamespaceQuery.cs
- ReadOnlyKeyedCollection.cs