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
- IgnoreDeviceFilterElementCollection.cs
- ValidationSummaryDesigner.cs
- NegotiationTokenAuthenticator.cs
- TextBoxAutoCompleteSourceConverter.cs
- ListViewAutomationPeer.cs
- BindingGroup.cs
- XPathArrayIterator.cs
- TaskExtensions.cs
- Cursor.cs
- RectangleHotSpot.cs
- ISO2022Encoding.cs
- FormsAuthenticationUserCollection.cs
- LiteralControl.cs
- SharedStatics.cs
- SplineKeyFrames.cs
- Point.cs
- CodeNamespaceImport.cs
- AggregateNode.cs
- TextDecorations.cs
- Matrix.cs
- DataStorage.cs
- ProcessProtocolHandler.cs
- ToolStripRenderer.cs
- TemplateEditingVerb.cs
- VarRefManager.cs
- BuildManagerHost.cs
- WebPartUserCapability.cs
- XmlSchemaComplexContentExtension.cs
- HtmlShim.cs
- DataGridViewColumnCollection.cs
- DataGridAddNewRow.cs
- HyperLinkStyle.cs
- EventSinkHelperWriter.cs
- latinshape.cs
- Image.cs
- HtmlInputText.cs
- CanonicalXml.cs
- RenderOptions.cs
- HttpPostProtocolImporter.cs
- LocalBuilder.cs
- EpmContentSerializer.cs
- ArgumentException.cs
- WSFederationHttpSecurityMode.cs
- GifBitmapEncoder.cs
- TreeChangeInfo.cs
- DiscriminatorMap.cs
- UnicodeEncoding.cs
- Nullable.cs
- ExpressionEditorAttribute.cs
- SafeNativeMethodsOther.cs
- SmtpReplyReader.cs
- CacheDependency.cs
- XmlUtil.cs
- LogRecordSequence.cs
- LocalIdKeyIdentifierClause.cs
- ToolZone.cs
- RightsManagementEncryptionTransform.cs
- HostingEnvironmentSection.cs
- DragCompletedEventArgs.cs
- PhonemeEventArgs.cs
- BookmarkCallbackWrapper.cs
- ValidatedControlConverter.cs
- Membership.cs
- SemanticResultValue.cs
- ImageMetadata.cs
- PerfCounterSection.cs
- XMLUtil.cs
- PresentationAppDomainManager.cs
- XmlDownloadManager.cs
- OleDbTransaction.cs
- Image.cs
- PageThemeCodeDomTreeGenerator.cs
- BoundsDrawingContextWalker.cs
- TextBox.cs
- SymDocumentType.cs
- MsmqIntegrationBindingCollectionElement.cs
- ClientProtocol.cs
- ActiveDocumentEvent.cs
- UserControlCodeDomTreeGenerator.cs
- CustomAttribute.cs
- CoTaskMemHandle.cs
- DataServiceProviderMethods.cs
- XmlReturnReader.cs
- Byte.cs
- safelink.cs
- Calendar.cs
- OutputScopeManager.cs
- X509Utils.cs
- DataGridViewCellMouseEventArgs.cs
- xml.cs
- MatrixAnimationUsingKeyFrames.cs
- DataColumnPropertyDescriptor.cs
- FlagsAttribute.cs
- SystemSounds.cs
- ListenerSessionConnection.cs
- SignedXml.cs
- wgx_render.cs
- safelinkcollection.cs
- SimpleHandlerFactory.cs
- Ray3DHitTestResult.cs