Code:
/ 4.0 / 4.0 / 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.
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
- RightNameExpirationInfoPair.cs
- StateWorkerRequest.cs
- XmlSchemaSimpleTypeList.cs
- DbConnectionClosed.cs
- RegistryKey.cs
- CollectionConverter.cs
- PropertyGeneratedEventArgs.cs
- FontStyles.cs
- StateRuntime.cs
- CapabilitiesPattern.cs
- BaseDataBoundControlDesigner.cs
- QueryCacheEntry.cs
- EntityDataSourceEntityTypeFilterConverter.cs
- GenericXmlSecurityTokenAuthenticator.cs
- Int64KeyFrameCollection.cs
- mediaeventargs.cs
- Transform3D.cs
- TransactionTable.cs
- ManagementNamedValueCollection.cs
- PathFigureCollection.cs
- RequestCachePolicy.cs
- RedirectionProxy.cs
- ApplicationId.cs
- PropertyToken.cs
- SecurityHeaderLayout.cs
- RelationshipFixer.cs
- ConnectionInterfaceCollection.cs
- cryptoapiTransform.cs
- WindowsScrollBarBits.cs
- ResourceDefaultValueAttribute.cs
- WebServicesDescriptionAttribute.cs
- SelectionPatternIdentifiers.cs
- HMACSHA256.cs
- Predicate.cs
- JulianCalendar.cs
- ReflectionTypeLoadException.cs
- CodeVariableReferenceExpression.cs
- listitem.cs
- XmlSchemaGroupRef.cs
- FrameDimension.cs
- StylusPointProperty.cs
- FragmentQuery.cs
- ProcessProtocolHandler.cs
- XamlHostingSection.cs
- RuntimeEnvironment.cs
- TagMapInfo.cs
- Nodes.cs
- DataGridViewRowsAddedEventArgs.cs
- SendOperation.cs
- BoundingRectTracker.cs
- FeatureSupport.cs
- HtmlEncodedRawTextWriter.cs
- SqlConnectionString.cs
- EmptyQuery.cs
- WebConfigurationManager.cs
- OracleColumn.cs
- StateValidator.cs
- ParentUndoUnit.cs
- String.cs
- AxParameterData.cs
- TraceListener.cs
- LinkGrep.cs
- Control.cs
- EdmScalarPropertyAttribute.cs
- DataSet.cs
- OrderByQueryOptionExpression.cs
- WebEventTraceProvider.cs
- SRDisplayNameAttribute.cs
- ViewKeyConstraint.cs
- ListControlDesigner.cs
- HtmlFormAdapter.cs
- AnnotationComponentManager.cs
- ListViewDataItem.cs
- UIElementParagraph.cs
- AccessibilityHelperForVista.cs
- FamilyTypeface.cs
- WebConfigurationFileMap.cs
- Point3DAnimation.cs
- ViewSimplifier.cs
- DefaultObjectMappingItemCollection.cs
- DomainUpDown.cs
- MemberRestriction.cs
- GeneralTransform3D.cs
- Span.cs
- DataPagerFieldCollection.cs
- IIS7WorkerRequest.cs
- MenuStrip.cs
- WeakRefEnumerator.cs
- CodeMethodInvokeExpression.cs
- Positioning.cs
- DbParameterCollection.cs
- ListChangedEventArgs.cs
- ListViewItem.cs
- CompatibleComparer.cs
- ButtonFieldBase.cs
- ExponentialEase.cs
- VisualBrush.cs
- CompatibleIComparer.cs
- CqlGenerator.cs
- LoginName.cs