Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Base / System / Windows / AttachedPropertyBrowsableWhenAttributePresentAttribute.cs / 1 / AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
namespace System.Windows
{
using System;
using System.ComponentModel;
///
/// This attribute declares that an attached property can only be attached
/// to an object that defines the given attribute on its class.
///
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class AttachedPropertyBrowsableWhenAttributePresentAttribute : AttachedPropertyBrowsableAttribute
{
//------------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
///
/// Creates a new AttachedPropertyBrowsableWhenAttributePresentAttribute. Provide
/// the type of attribute that, when present on a dependency object,
/// should make the property browsable.
///
public AttachedPropertyBrowsableWhenAttributePresentAttribute(Type attributeType)
{
if (attributeType == null) throw new ArgumentNullException("attributeType");
_attributeType = attributeType;
}
//-----------------------------------------------------
//
// Public Properties
//
//-----------------------------------------------------
///
/// Returns the attribute type passed into the constructor.
///
public Type AttributeType
{
get
{
return _attributeType;
}
}
//------------------------------------------------------
//
// Public Methods
//
//-----------------------------------------------------
///
/// Overrides Object.Equals to implement correct equality semantics for this
/// attribute.
///
public override bool Equals(object obj)
{
AttachedPropertyBrowsableWhenAttributePresentAttribute other = obj as AttachedPropertyBrowsableWhenAttributePresentAttribute;
if (other == null) return false;
return _attributeType == other._attributeType;
}
///
/// Overrides Object.GetHashCode to implement correct hashing semantics.
///
public override int GetHashCode()
{
return _attributeType.GetHashCode();
}
//------------------------------------------------------
//
// Internal Methods
//
//------------------------------------------------------
///
/// Returns true if the dependency object class defines an attribute
/// of the same type contained in this attribute. The attribute must
/// differ from the "default" state of the attribute.
///
internal override bool IsBrowsable(DependencyObject d, DependencyProperty dp)
{
if (d == null) throw new ArgumentNullException("d");
if (dp == null) throw new ArgumentNullException("dp");
Attribute a = TypeDescriptor.GetAttributes(d)[_attributeType];
return (a != null && !a.IsDefaultAttribute());
}
//-----------------------------------------------------
//
// Private Fields
//
//------------------------------------------------------
private Type _attributeType;
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
namespace System.Windows
{
using System;
using System.ComponentModel;
///
/// This attribute declares that an attached property can only be attached
/// to an object that defines the given attribute on its class.
///
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class AttachedPropertyBrowsableWhenAttributePresentAttribute : AttachedPropertyBrowsableAttribute
{
//------------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
///
/// Creates a new AttachedPropertyBrowsableWhenAttributePresentAttribute. Provide
/// the type of attribute that, when present on a dependency object,
/// should make the property browsable.
///
public AttachedPropertyBrowsableWhenAttributePresentAttribute(Type attributeType)
{
if (attributeType == null) throw new ArgumentNullException("attributeType");
_attributeType = attributeType;
}
//-----------------------------------------------------
//
// Public Properties
//
//-----------------------------------------------------
///
/// Returns the attribute type passed into the constructor.
///
public Type AttributeType
{
get
{
return _attributeType;
}
}
//------------------------------------------------------
//
// Public Methods
//
//-----------------------------------------------------
///
/// Overrides Object.Equals to implement correct equality semantics for this
/// attribute.
///
public override bool Equals(object obj)
{
AttachedPropertyBrowsableWhenAttributePresentAttribute other = obj as AttachedPropertyBrowsableWhenAttributePresentAttribute;
if (other == null) return false;
return _attributeType == other._attributeType;
}
///
/// Overrides Object.GetHashCode to implement correct hashing semantics.
///
public override int GetHashCode()
{
return _attributeType.GetHashCode();
}
//------------------------------------------------------
//
// Internal Methods
//
//------------------------------------------------------
///
/// Returns true if the dependency object class defines an attribute
/// of the same type contained in this attribute. The attribute must
/// differ from the "default" state of the attribute.
///
internal override bool IsBrowsable(DependencyObject d, DependencyProperty dp)
{
if (d == null) throw new ArgumentNullException("d");
if (dp == null) throw new ArgumentNullException("dp");
Attribute a = TypeDescriptor.GetAttributes(d)[_attributeType];
return (a != null && !a.IsDefaultAttribute());
}
//-----------------------------------------------------
//
// Private Fields
//
//------------------------------------------------------
private Type _attributeType;
}
}
// 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
- NumberSubstitution.cs
- X509WindowsSecurityToken.cs
- Parameter.cs
- ISFTagAndGuidCache.cs
- RayHitTestParameters.cs
- X509ScopedServiceCertificateElementCollection.cs
- CssClassPropertyAttribute.cs
- WindowsIdentity.cs
- GridItemPattern.cs
- Point4DValueSerializer.cs
- PointValueSerializer.cs
- IconEditor.cs
- BidirectionalDictionary.cs
- NameSpaceExtractor.cs
- IPEndPointCollection.cs
- DebuggerAttributes.cs
- ColumnCollectionEditor.cs
- Geometry.cs
- GenericWebPart.cs
- RotateTransform3D.cs
- SmiEventSink_Default.cs
- __ComObject.cs
- TextDataBindingHandler.cs
- RSAPKCS1KeyExchangeFormatter.cs
- DataContractJsonSerializer.cs
- QuestionEventArgs.cs
- ResolveCriteriaApril2005.cs
- TemplateControlCodeDomTreeGenerator.cs
- TableColumn.cs
- MediaEntryAttribute.cs
- FontWeight.cs
- ThicknessKeyFrameCollection.cs
- DeviceSpecificChoice.cs
- DataListItem.cs
- RoutedCommand.cs
- DbConnectionStringBuilder.cs
- ItemsPresenter.cs
- COM2Properties.cs
- DeferredSelectedIndexReference.cs
- TableLayoutSettings.cs
- Accessors.cs
- MissingMemberException.cs
- EventWaitHandle.cs
- DrawingContextDrawingContextWalker.cs
- ScriptingWebServicesSectionGroup.cs
- StylusTip.cs
- SoapExtension.cs
- ExpressionLexer.cs
- BamlRecordWriter.cs
- DataReceivedEventArgs.cs
- DataGridViewTextBoxEditingControl.cs
- AcceleratedTokenProvider.cs
- FullTrustAssembliesSection.cs
- DefaultSettingsSection.cs
- Help.cs
- ProtocolsConfiguration.cs
- KerberosSecurityTokenProvider.cs
- FontFamily.cs
- Logging.cs
- ThicknessAnimation.cs
- ListBase.cs
- FigureParagraph.cs
- ClientSettingsProvider.cs
- DataServiceEntityAttribute.cs
- WebConfigurationHost.cs
- ElapsedEventArgs.cs
- TabControlAutomationPeer.cs
- DiffuseMaterial.cs
- BaseComponentEditor.cs
- CharUnicodeInfo.cs
- Native.cs
- CodeSubDirectoriesCollection.cs
- TagPrefixCollection.cs
- ImpersonateTokenRef.cs
- AssemblyAttributesGoHere.cs
- HttpTransportElement.cs
- BigInt.cs
- ToolStripDesignerAvailabilityAttribute.cs
- ExtensionSimplifierMarkupObject.cs
- DriveNotFoundException.cs
- AbstractExpressions.cs
- ElementNotEnabledException.cs
- HttpResponse.cs
- XmlSchemaImport.cs
- XamlSerializer.cs
- RegisteredDisposeScript.cs
- ActivityCodeDomSerializer.cs
- AssemblyResourceLoader.cs
- NavigationFailedEventArgs.cs
- WebPartEditorApplyVerb.cs
- XPathSelfQuery.cs
- DnsPermission.cs
- TableRowGroupCollection.cs
- StickyNoteAnnotations.cs
- StatusBarItem.cs
- Panel.cs
- ProcessStartInfo.cs
- X509Utils.cs
- NamespaceCollection.cs
- BlurBitmapEffect.cs