Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- GridViewRowCollection.cs
- ValidationErrorCollection.cs
- DrawingContext.cs
- FixedSOMTextRun.cs
- BindingGroup.cs
- DataGridParentRows.cs
- InstanceView.cs
- SystemThemeKey.cs
- XmlSchemaDocumentation.cs
- ControlTemplate.cs
- DataRecordObjectView.cs
- MessageQueuePermissionEntryCollection.cs
- GridViewAutomationPeer.cs
- XmlILStorageConverter.cs
- ProfileSettings.cs
- EntityTransaction.cs
- ReferenceConverter.cs
- SafeRegistryHandle.cs
- WindowsTokenRoleProvider.cs
- X509CertificateClaimSet.cs
- Comparer.cs
- ObjectTag.cs
- StylusDownEventArgs.cs
- controlskin.cs
- EventToken.cs
- WebPartConnectionsDisconnectVerb.cs
- FontUnit.cs
- SeekableReadStream.cs
- FrameworkContextData.cs
- SoapExtension.cs
- LogAppendAsyncResult.cs
- AnnotationStore.cs
- safex509handles.cs
- ScriptMethodAttribute.cs
- Script.cs
- BitmapData.cs
- cookie.cs
- IWorkflowDebuggerService.cs
- NonClientArea.cs
- Expr.cs
- Matrix3D.cs
- DiscoveryInnerClientManaged11.cs
- LambdaCompiler.Unary.cs
- Win32.cs
- SecurityKeyUsage.cs
- WebHttpBindingElement.cs
- Rijndael.cs
- PostBackOptions.cs
- XmlDocumentFragment.cs
- BitmapEffectInput.cs
- ContentElement.cs
- RuntimeWrappedException.cs
- DbXmlEnabledProviderManifest.cs
- DecoderFallbackWithFailureFlag.cs
- KerberosSecurityTokenAuthenticator.cs
- PrivateUnsafeNativeCompoundFileMethods.cs
- clipboard.cs
- DrawingBrush.cs
- OwnerDrawPropertyBag.cs
- SubpageParagraph.cs
- LambdaExpression.cs
- SettingsPropertyValue.cs
- EntityDataSource.cs
- MetaColumn.cs
- ObjectNavigationPropertyMapping.cs
- VisualTreeHelper.cs
- SQlBooleanStorage.cs
- Options.cs
- SmtpAuthenticationManager.cs
- SamlSecurityTokenAuthenticator.cs
- PanelStyle.cs
- altserialization.cs
- SrgsNameValueTag.cs
- HttpApplicationFactory.cs
- IntegrationExceptionEventArgs.cs
- ChannelManager.cs
- ArgumentNullException.cs
- Mappings.cs
- OleDbEnumerator.cs
- Math.cs
- ToolStripLabel.cs
- _SafeNetHandles.cs
- FontCacheLogic.cs
- OracleConnection.cs
- SchemaSetCompiler.cs
- MediaEntryAttribute.cs
- CompilerCollection.cs
- OperatingSystemVersionCheck.cs
- DataServiceOperationContext.cs
- fixedPageContentExtractor.cs
- WebResponse.cs
- Cloud.cs
- DataGridViewSelectedCellCollection.cs
- CriticalHandle.cs
- GenericAuthenticationEventArgs.cs
- SuppressMergeCheckAttribute.cs
- HttpConfigurationSystem.cs
- RuntimeHandles.cs
- ProfilePropertyMetadata.cs
- Property.cs