Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Base / System / ComponentModel / PropertyFilterAttribute.cs / 1305600 / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RequestTimeoutManager.cs
- WinEventHandler.cs
- ExpressionsCollectionConverter.cs
- ExtenderProvidedPropertyAttribute.cs
- TdsParserSafeHandles.cs
- ExtendedPropertyInfo.cs
- StringExpressionSet.cs
- TokenizerHelper.cs
- TypeSource.cs
- HtmlInputButton.cs
- Rules.cs
- TraceSwitch.cs
- TemplatedWizardStep.cs
- FollowerQueueCreator.cs
- IisTraceWebEventProvider.cs
- TdsParserSessionPool.cs
- HandlerBase.cs
- Int64.cs
- BaseCodeDomTreeGenerator.cs
- ColorEditor.cs
- SqlDataSourceCustomCommandEditor.cs
- DataComponentNameHandler.cs
- LineVisual.cs
- CoreSwitches.cs
- XNodeNavigator.cs
- MouseGesture.cs
- OdbcConnectionPoolProviderInfo.cs
- WindowsStartMenu.cs
- MILUtilities.cs
- FilterEventArgs.cs
- BulletedListEventArgs.cs
- Slider.cs
- PeerName.cs
- WorkflowDataContext.cs
- XmlUrlEditor.cs
- Convert.cs
- PopupRootAutomationPeer.cs
- QueryOperationResponseOfT.cs
- Bits.cs
- EditorPartChrome.cs
- PolicyUnit.cs
- PropertyGridView.cs
- FontFamilyValueSerializer.cs
- SizeLimitedCache.cs
- Regex.cs
- ComNativeDescriptor.cs
- RegisteredDisposeScript.cs
- RawStylusInput.cs
- HeaderedItemsControl.cs
- TemplateManager.cs
- ProfilePropertySettingsCollection.cs
- Interlocked.cs
- PointUtil.cs
- TokenFactoryBase.cs
- SafeBitVector32.cs
- ByteStorage.cs
- ScalarOps.cs
- Parameter.cs
- SingleResultAttribute.cs
- BaseParaClient.cs
- X509Certificate2Collection.cs
- PasswordTextContainer.cs
- DbDataRecord.cs
- HttpResponseBase.cs
- WebPart.cs
- WindowsIdentity.cs
- SkipQueryOptionExpression.cs
- OperatorExpressions.cs
- XsltContext.cs
- EncoderFallback.cs
- WindowsSecurityToken.cs
- DocumentXmlWriter.cs
- MarkupWriter.cs
- OrderedDictionary.cs
- DataGridHelper.cs
- HttpApplicationFactory.cs
- XmlUrlResolver.cs
- TextComposition.cs
- MailDefinition.cs
- ToolBarPanel.cs
- EntityWithChangeTrackerStrategy.cs
- ObjectParameter.cs
- MemberAssignment.cs
- WorkflowRuntimeService.cs
- BridgeDataReader.cs
- ZipIOCentralDirectoryFileHeader.cs
- MasterPage.cs
- entityreference_tresulttype.cs
- ClickablePoint.cs
- AdRotator.cs
- XamlInterfaces.cs
- NullToBooleanConverter.cs
- DataGridViewRowEventArgs.cs
- TracedNativeMethods.cs
- FixedSOMTextRun.cs
- COM2PropertyBuilderUITypeEditor.cs
- GifBitmapDecoder.cs
- ListenerConfig.cs
- TTSEvent.cs
- SafeSecurityHandles.cs