Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- listitem.cs
- StateItem.cs
- DeploymentSection.cs
- IteratorFilter.cs
- ListViewItem.cs
- PropertyGeneratedEventArgs.cs
- DbModificationCommandTree.cs
- WebHttpSecurity.cs
- sqlinternaltransaction.cs
- HttpModulesSection.cs
- XmlStrings.cs
- IHttpResponseInternal.cs
- securitycriticaldataClass.cs
- GroupQuery.cs
- COM2ExtendedBrowsingHandler.cs
- MatrixStack.cs
- XmlUnspecifiedAttribute.cs
- XamlFrame.cs
- PointConverter.cs
- TextTreeRootTextBlock.cs
- ReadOnlyAttribute.cs
- ServerReliableChannelBinder.cs
- TreeNodeCollection.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- CapabilitiesUse.cs
- DbConnectionFactory.cs
- Validator.cs
- SrgsDocumentParser.cs
- ToolBar.cs
- CqlWriter.cs
- ObjectFullSpanRewriter.cs
- TransactionFlowAttribute.cs
- ToolboxDataAttribute.cs
- TransportContext.cs
- EventWaitHandleSecurity.cs
- ScriptingWebServicesSectionGroup.cs
- XPathNavigatorKeyComparer.cs
- InternalConfigRoot.cs
- HostProtectionPermission.cs
- XamlFxTrace.cs
- QuotedPrintableStream.cs
- AutoResetEvent.cs
- RuleDefinitions.cs
- EventToken.cs
- TaskFactory.cs
- DataComponentMethodGenerator.cs
- documentation.cs
- PrimitiveCodeDomSerializer.cs
- XsltLibrary.cs
- EntitySetDataBindingList.cs
- MissingManifestResourceException.cs
- FeatureSupport.cs
- HttpWebResponse.cs
- CaseCqlBlock.cs
- PersonalizationEntry.cs
- ClonableStack.cs
- MenuRenderer.cs
- CallContext.cs
- ScaleTransform.cs
- JapaneseLunisolarCalendar.cs
- ScrollViewerAutomationPeer.cs
- PortCache.cs
- DependencyPropertyDescriptor.cs
- HyperLinkColumn.cs
- DataGridCommandEventArgs.cs
- SamlSubject.cs
- OdbcStatementHandle.cs
- ListItemViewControl.cs
- MimeParameters.cs
- MouseOverProperty.cs
- HGlobalSafeHandle.cs
- OptimizerPatterns.cs
- GlobalizationSection.cs
- TripleDESCryptoServiceProvider.cs
- DayRenderEvent.cs
- PropertyChangeTracker.cs
- InputBuffer.cs
- MethodAccessException.cs
- LayoutEditorPart.cs
- ListenerSingletonConnectionReader.cs
- HttpDictionary.cs
- HwndSubclass.cs
- MessageSecurityOverHttpElement.cs
- ActivityFunc.cs
- OleDbEnumerator.cs
- TextCollapsingProperties.cs
- VariableQuery.cs
- ScaleTransform3D.cs
- QilList.cs
- OciEnlistContext.cs
- BamlLocalizer.cs
- SizeValueSerializer.cs
- RoutedCommand.cs
- ClrPerspective.cs
- CompilationAssemblyInstallComponent.cs
- GenericRootAutomationPeer.cs
- DependencyObjectValidator.cs
- TrackPointCollection.cs
- AuthenticationService.cs
- CryptoStream.cs