Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Framework / System / Windows / AttachedPropertyBrowsableForChildrenAttribute.cs / 1 / AttachedPropertyBrowsableForChildrenAttribute.cs
namespace System.Windows { using System; ////// This attribute declares that a property is visible when the /// property owner is a parent of another element. For example, /// Canvas.Left is only useful on elements parented within the /// canvas. The class supports two types of tree walks: a shallow /// walk, the default which requires that the immediate parent be the /// owner type of the property, and a deep walk, declared by setting /// IncludeDescendants to true and requires that the owner type be /// somewhere in the parenting hierarchy. /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public sealed class AttachedPropertyBrowsableForChildrenAttribute : AttachedPropertyBrowsableAttribute { //------------------------------------------------------ // // Constructors // //----------------------------------------------------- ////// Creates a new AttachedPropertyBrowsableForChildrenAttribute. /// public AttachedPropertyBrowsableForChildrenAttribute() { } //----------------------------------------------------- // // Public Properties // //----------------------------------------------------- ////// Gets or sets if the property should be browsable for just the /// immediate children (false) or all children (true). /// public bool IncludeDescendants { get { return _includeDescendants; } set { _includeDescendants = value; } } //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- ////// Overrides Object.Equals to implement correct equality semantics for this /// attribute. /// public override bool Equals(object obj) { AttachedPropertyBrowsableForChildrenAttribute other = obj as AttachedPropertyBrowsableForChildrenAttribute; if (other == null) return false; return _includeDescendants == other._includeDescendants; } ////// Overrides Object.GetHashCode to implement correct hashing semantics. /// public override int GetHashCode() { return _includeDescendants.GetHashCode(); } //------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ ////// Returns true if the object provided is the immediate logical /// child (if IncludeDescendants is false) or any logical child /// (if IncludeDescendants is true). /// internal override bool IsBrowsable(DependencyObject d, DependencyProperty dp) { if (d == null) throw new ArgumentNullException("d"); if (dp == null) throw new ArgumentNullException("dp"); DependencyObject walk = d; Type ownerType = dp.OwnerType; do { walk = FrameworkElement.GetFrameworkParent(walk); if (walk != null && ownerType.IsInstanceOfType(walk)) { return true; } } while (_includeDescendants && walk != null); return false; } //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ private bool _includeDescendants; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. namespace System.Windows { using System; ////// This attribute declares that a property is visible when the /// property owner is a parent of another element. For example, /// Canvas.Left is only useful on elements parented within the /// canvas. The class supports two types of tree walks: a shallow /// walk, the default which requires that the immediate parent be the /// owner type of the property, and a deep walk, declared by setting /// IncludeDescendants to true and requires that the owner type be /// somewhere in the parenting hierarchy. /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public sealed class AttachedPropertyBrowsableForChildrenAttribute : AttachedPropertyBrowsableAttribute { //------------------------------------------------------ // // Constructors // //----------------------------------------------------- ////// Creates a new AttachedPropertyBrowsableForChildrenAttribute. /// public AttachedPropertyBrowsableForChildrenAttribute() { } //----------------------------------------------------- // // Public Properties // //----------------------------------------------------- ////// Gets or sets if the property should be browsable for just the /// immediate children (false) or all children (true). /// public bool IncludeDescendants { get { return _includeDescendants; } set { _includeDescendants = value; } } //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- ////// Overrides Object.Equals to implement correct equality semantics for this /// attribute. /// public override bool Equals(object obj) { AttachedPropertyBrowsableForChildrenAttribute other = obj as AttachedPropertyBrowsableForChildrenAttribute; if (other == null) return false; return _includeDescendants == other._includeDescendants; } ////// Overrides Object.GetHashCode to implement correct hashing semantics. /// public override int GetHashCode() { return _includeDescendants.GetHashCode(); } //------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ ////// Returns true if the object provided is the immediate logical /// child (if IncludeDescendants is false) or any logical child /// (if IncludeDescendants is true). /// internal override bool IsBrowsable(DependencyObject d, DependencyProperty dp) { if (d == null) throw new ArgumentNullException("d"); if (dp == null) throw new ArgumentNullException("dp"); DependencyObject walk = d; Type ownerType = dp.OwnerType; do { walk = FrameworkElement.GetFrameworkParent(walk); if (walk != null && ownerType.IsInstanceOfType(walk)) { return true; } } while (_includeDescendants && walk != null); return false; } //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ private bool _includeDescendants; } } // 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
- WebCategoryAttribute.cs
- nulltextnavigator.cs
- IMembershipProvider.cs
- IPAddressCollection.cs
- OptionalColumn.cs
- RequestResizeEvent.cs
- WebHeaderCollection.cs
- WebPartMovingEventArgs.cs
- ThemeInfoAttribute.cs
- DrawingAttributes.cs
- WorkflowWebHostingModule.cs
- CssTextWriter.cs
- WebPartPersonalization.cs
- InternalConfigHost.cs
- BinaryUtilClasses.cs
- PenLineJoinValidation.cs
- LongSumAggregationOperator.cs
- NameValueConfigurationElement.cs
- CategoryGridEntry.cs
- Misc.cs
- DeferredRunTextReference.cs
- SqlFlattener.cs
- WebPartEditorApplyVerb.cs
- Token.cs
- ReadWriteObjectLock.cs
- AdCreatedEventArgs.cs
- XmlSchemaComplexContent.cs
- TriggerAction.cs
- RuntimeConfigLKG.cs
- UrlPath.cs
- cryptoapiTransform.cs
- WebPartDisplayModeCancelEventArgs.cs
- ProfileParameter.cs
- TerminatingOperationBehavior.cs
- DataListItemCollection.cs
- RtfFormatStack.cs
- FontEmbeddingManager.cs
- IdentitySection.cs
- KerberosSecurityTokenProvider.cs
- SqlDataSourceView.cs
- FrameworkRichTextComposition.cs
- CodeTypeReference.cs
- TableItemProviderWrapper.cs
- Material.cs
- DiscardableAttribute.cs
- StrongTypingException.cs
- SqlDataSourceCommandEventArgs.cs
- TreeViewItem.cs
- Transform3D.cs
- OpenFileDialog.cs
- KnownTypesHelper.cs
- CodeCastExpression.cs
- FileDialog_Vista.cs
- SmtpClient.cs
- DesignerCatalogPartChrome.cs
- DtrList.cs
- categoryentry.cs
- RequestCacheValidator.cs
- Stopwatch.cs
- ImpersonateTokenRef.cs
- SwitchElementsCollection.cs
- SimpleLine.cs
- MetadataItemEmitter.cs
- AppDomainShutdownMonitor.cs
- ChangeConflicts.cs
- AppSettingsReader.cs
- CharacterHit.cs
- ToolStripGripRenderEventArgs.cs
- BCryptHashAlgorithm.cs
- PeerCredentialElement.cs
- Module.cs
- QueueAccessMode.cs
- SelectionProcessor.cs
- Publisher.cs
- Variant.cs
- OleStrCAMarshaler.cs
- ViewStateModeByIdAttribute.cs
- SystemIPv4InterfaceProperties.cs
- MergablePropertyAttribute.cs
- TextPatternIdentifiers.cs
- PageOutputColor.cs
- TextDecoration.cs
- ListChunk.cs
- CellConstantDomain.cs
- ClientFormsAuthenticationMembershipProvider.cs
- RegexParser.cs
- KoreanCalendar.cs
- InheritanceContextHelper.cs
- MulticastDelegate.cs
- ObjectStateManager.cs
- TransformerConfigurationWizardBase.cs
- CircleHotSpot.cs
- Vector3DCollection.cs
- COM2FontConverter.cs
- ConfigurationElementProperty.cs
- DataGridLengthConverter.cs
- Hash.cs
- DataFormats.cs
- Style.cs
- ToolboxItemFilterAttribute.cs