Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Base / MS / Internal / InheritanceContextHelper.cs / 1 / InheritanceContextHelper.cs
/****************************************************************************\ * * File: InheritanceContextHelper.cs * * This file holds a helper class for DO subclasses that implement an * inheritance context. * * Copyright (C) by Microsoft Corporation. All rights reserved. * \***************************************************************************/ using System; using System.Windows; using MS.Internal.WindowsBase; namespace MS.Internal { internal static class InheritanceContextHelper { //------------------------------------------------------------------- // // ProvideContextForObject // // Tell a DO that it has a new inheritance context available. // //------------------------------------------------------------------- [FriendAccessAllowed] // Built into Core, also used by Framework. internal static void ProvideContextForObject( DependencyObject context, DependencyObject newValue ) { if (context != null) { context.ProvideSelfAsInheritanceContext(newValue, null); } } //------------------------------------------------------------------- // // RemoveContextFromObject // // Tell a DO that it has lost its inheritance context. // //-------------------------------------------------------------------- [FriendAccessAllowed] // Built into Base, also used by Framework. internal static void RemoveContextFromObject( DependencyObject context, DependencyObject oldValue ) { if (context != null && oldValue.InheritanceContext == context) { context.RemoveSelfAsInheritanceContext(oldValue, null); } } //------------------------------------------------------------------- // // AddInheritanceContext // // Implementation to receive a new inheritance context // //-------------------------------------------------------------------- [FriendAccessAllowed] // Built into Base, also used by Framework. internal static void AddInheritanceContext(DependencyObject newInheritanceContext, DependencyObject value, ref bool hasMultipleInheritanceContexts, ref DependencyObject inheritanceContext ) { // ignore the request when the new context is the same as the old, // or when there are already multiple contexts if (newInheritanceContext != inheritanceContext && !hasMultipleInheritanceContexts) { if (inheritanceContext == null || newInheritanceContext == null) { // Pick up the new context inheritanceContext = newInheritanceContext; } else { // We are now being referenced from multiple // places, clear the context hasMultipleInheritanceContexts = true; inheritanceContext = null; } value.OnInheritanceContextChanged(EventArgs.Empty); } } //-------------------------------------------------------------------- // // RemoveInheritanceContext // // Implementation to remove an old inheritance context // //------------------------------------------------------------------- [FriendAccessAllowed] // Built into Base, also used by Framework. internal static void RemoveInheritanceContext(DependencyObject oldInheritanceContext, DependencyObject value, ref bool hasMultipleInheritanceContexts, ref DependencyObject inheritanceContext ) { // ignore the request when the given context doesn't match the old one, // or when there are already multiple contexts if (oldInheritanceContext == inheritanceContext && !hasMultipleInheritanceContexts) { // clear the context inheritanceContext = null; value.OnInheritanceContextChanged(EventArgs.Empty); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. /****************************************************************************\ * * File: InheritanceContextHelper.cs * * This file holds a helper class for DO subclasses that implement an * inheritance context. * * Copyright (C) by Microsoft Corporation. All rights reserved. * \***************************************************************************/ using System; using System.Windows; using MS.Internal.WindowsBase; namespace MS.Internal { internal static class InheritanceContextHelper { //------------------------------------------------------------------- // // ProvideContextForObject // // Tell a DO that it has a new inheritance context available. // //------------------------------------------------------------------- [FriendAccessAllowed] // Built into Core, also used by Framework. internal static void ProvideContextForObject( DependencyObject context, DependencyObject newValue ) { if (context != null) { context.ProvideSelfAsInheritanceContext(newValue, null); } } //------------------------------------------------------------------- // // RemoveContextFromObject // // Tell a DO that it has lost its inheritance context. // //-------------------------------------------------------------------- [FriendAccessAllowed] // Built into Base, also used by Framework. internal static void RemoveContextFromObject( DependencyObject context, DependencyObject oldValue ) { if (context != null && oldValue.InheritanceContext == context) { context.RemoveSelfAsInheritanceContext(oldValue, null); } } //------------------------------------------------------------------- // // AddInheritanceContext // // Implementation to receive a new inheritance context // //-------------------------------------------------------------------- [FriendAccessAllowed] // Built into Base, also used by Framework. internal static void AddInheritanceContext(DependencyObject newInheritanceContext, DependencyObject value, ref bool hasMultipleInheritanceContexts, ref DependencyObject inheritanceContext ) { // ignore the request when the new context is the same as the old, // or when there are already multiple contexts if (newInheritanceContext != inheritanceContext && !hasMultipleInheritanceContexts) { if (inheritanceContext == null || newInheritanceContext == null) { // Pick up the new context inheritanceContext = newInheritanceContext; } else { // We are now being referenced from multiple // places, clear the context hasMultipleInheritanceContexts = true; inheritanceContext = null; } value.OnInheritanceContextChanged(EventArgs.Empty); } } //-------------------------------------------------------------------- // // RemoveInheritanceContext // // Implementation to remove an old inheritance context // //------------------------------------------------------------------- [FriendAccessAllowed] // Built into Base, also used by Framework. internal static void RemoveInheritanceContext(DependencyObject oldInheritanceContext, DependencyObject value, ref bool hasMultipleInheritanceContexts, ref DependencyObject inheritanceContext ) { // ignore the request when the given context doesn't match the old one, // or when there are already multiple contexts if (oldInheritanceContext == inheritanceContext && !hasMultipleInheritanceContexts) { // clear the context inheritanceContext = null; value.OnInheritanceContextChanged(EventArgs.Empty); } } } } // 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
- PermissionListSet.cs
- IdentityNotMappedException.cs
- ImageSourceConverter.cs
- VisualBasic.cs
- ToolstripProfessionalRenderer.cs
- AdornedElementPlaceholder.cs
- querybuilder.cs
- Int32CollectionConverter.cs
- DataControlImageButton.cs
- XmlSchemaAttribute.cs
- MultipleViewPattern.cs
- MailBnfHelper.cs
- ProxyGenerationError.cs
- FixedSOMFixedBlock.cs
- UnsafeNativeMethods.cs
- Message.cs
- CompiledQueryCacheEntry.cs
- WebServiceMethodData.cs
- XamlTypeMapper.cs
- ConfigurationProperty.cs
- ContactManager.cs
- MsmqIntegrationBindingElement.cs
- Queue.cs
- XXXInfos.cs
- mactripleDES.cs
- SelectionProcessor.cs
- Image.cs
- AnnotationResourceCollection.cs
- DeobfuscatingStream.cs
- Rect.cs
- MethodSignatureGenerator.cs
- SqlMethodAttribute.cs
- indexingfiltermarshaler.cs
- TemplateParser.cs
- LogConverter.cs
- SerializationStore.cs
- DrawToolTipEventArgs.cs
- PartitionResolver.cs
- CqlLexer.cs
- CodeGenerationManager.cs
- ServiceContractGenerator.cs
- DataGridItemAutomationPeer.cs
- datacache.cs
- WebPartConnectionCollection.cs
- PolyQuadraticBezierSegment.cs
- IpcServerChannel.cs
- Zone.cs
- XmlDocumentFragment.cs
- SiblingIterators.cs
- QilStrConcat.cs
- RichTextBoxConstants.cs
- RIPEMD160Managed.cs
- safelinkcollection.cs
- SynchronizationHandlesCodeDomSerializer.cs
- BooleanSwitch.cs
- FixedNode.cs
- MarkedHighlightComponent.cs
- HttpCachePolicy.cs
- UriWriter.cs
- Object.cs
- XpsFilter.cs
- Style.cs
- ContextBase.cs
- GenericWebPart.cs
- PauseStoryboard.cs
- IPipelineRuntime.cs
- ReadOnlyDictionary.cs
- OpenTypeLayout.cs
- CodeMethodReturnStatement.cs
- Native.cs
- BindingExpressionUncommonField.cs
- ScalarRestriction.cs
- LinqExpressionNormalizer.cs
- HtmlEmptyTagControlBuilder.cs
- PropertyCondition.cs
- LogSwitch.cs
- XNodeValidator.cs
- SystemColorTracker.cs
- PackageFilter.cs
- ReaderOutput.cs
- ScrollData.cs
- ObjectDisposedException.cs
- HostedTransportConfigurationManager.cs
- NonClientArea.cs
- BlockUIContainer.cs
- ApplicationSettingsBase.cs
- DataColumn.cs
- TrackBarRenderer.cs
- WindowsSecurityToken.cs
- NonPrimarySelectionGlyph.cs
- ActivityDesignerLayoutSerializers.cs
- ErrorEventArgs.cs
- PathSegmentCollection.cs
- SqlWriter.cs
- NamedPipeAppDomainProtocolHandler.cs
- hebrewshape.cs
- TrustLevel.cs
- AuthenticateEventArgs.cs
- MemberInitExpression.cs
- JsonServiceDocumentSerializer.cs