Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Base / MS / Internal / InheritanceContextHelper.cs / 1305600 / 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
- FtpWebResponse.cs
- UdpConstants.cs
- CursorEditor.cs
- TimeSpanHelper.cs
- Processor.cs
- SynchronizedRandom.cs
- BaseCAMarshaler.cs
- ConstantSlot.cs
- ServerIdentity.cs
- CurrencyManager.cs
- xml.cs
- SqlCacheDependency.cs
- VerificationException.cs
- SqlNamer.cs
- PermissionAttributes.cs
- NetCodeGroup.cs
- NegatedConstant.cs
- XPathArrayIterator.cs
- WebEvents.cs
- ClrPerspective.cs
- WebServiceEnumData.cs
- BitmapEffectDrawing.cs
- ContainerParagraph.cs
- Normalization.cs
- IDispatchConstantAttribute.cs
- SerTrace.cs
- DbException.cs
- BaseProcessor.cs
- MasterPageCodeDomTreeGenerator.cs
- DbConnectionPool.cs
- EUCJPEncoding.cs
- PropertyBuilder.cs
- UriScheme.cs
- View.cs
- PerformanceCounterLib.cs
- AdapterDictionary.cs
- EntityParameter.cs
- Span.cs
- MachineSettingsSection.cs
- DataMisalignedException.cs
- HandlerElementCollection.cs
- Win32.cs
- PagesChangedEventArgs.cs
- UpdateProgress.cs
- BatchStream.cs
- BypassElementCollection.cs
- WrappedIUnknown.cs
- Ops.cs
- EditorZoneBase.cs
- BindingNavigator.cs
- SpotLight.cs
- ZipPackage.cs
- DataRow.cs
- WebScriptServiceHost.cs
- _DisconnectOverlappedAsyncResult.cs
- AssociationType.cs
- FigureHelper.cs
- MetricEntry.cs
- QueryAsyncResult.cs
- InfoCardBaseException.cs
- CodeMethodInvokeExpression.cs
- TextPatternIdentifiers.cs
- TypeSystemHelpers.cs
- MD5Cng.cs
- StaticExtensionConverter.cs
- ObjectIDGenerator.cs
- OutputCacheSettingsSection.cs
- ApplicationDirectoryMembershipCondition.cs
- CryptoConfig.cs
- DataControlReference.cs
- DocumentPageView.cs
- StylusButtonEventArgs.cs
- WaitHandle.cs
- Identity.cs
- SmtpCommands.cs
- DateTimeOffsetConverter.cs
- TextAdaptor.cs
- InstancePersistenceContext.cs
- DeploymentSection.cs
- DataServiceEntityAttribute.cs
- CharAnimationBase.cs
- EventMappingSettings.cs
- CommentEmitter.cs
- SynchronizedKeyedCollection.cs
- GridViewRowPresenterBase.cs
- FixedSOMSemanticBox.cs
- ProgressBar.cs
- NetworkInformationPermission.cs
- EncodingFallbackAwareXmlTextWriter.cs
- OdbcException.cs
- DbTransaction.cs
- localization.cs
- EntityDataSourceWizardForm.cs
- Panel.cs
- DesignerCalendarAdapter.cs
- Int16KeyFrameCollection.cs
- ScriptingJsonSerializationSection.cs
- ChannelToken.cs
- DefaultPropertyAttribute.cs
- PropertyChangeTracker.cs