Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HwndSource.cs
- ActivityPreviewDesigner.cs
- Compress.cs
- RequestDescription.cs
- GCHandleCookieTable.cs
- GridViewEditEventArgs.cs
- ButtonFlatAdapter.cs
- BooleanFunctions.cs
- PenThreadPool.cs
- DotAtomReader.cs
- HtmlHistory.cs
- ComplexTypeEmitter.cs
- GeometryHitTestResult.cs
- ColorTransformHelper.cs
- MetabaseServerConfig.cs
- OSEnvironmentHelper.cs
- StringDictionary.cs
- DataPagerField.cs
- PropertyChangedEventManager.cs
- CodeEventReferenceExpression.cs
- SiteMapHierarchicalDataSourceView.cs
- StructuralType.cs
- ClonableStack.cs
- CodeSnippetTypeMember.cs
- ZoneButton.cs
- PlainXmlDeserializer.cs
- xmlsaver.cs
- EnumerableRowCollection.cs
- DesignTimeVisibleAttribute.cs
- XmlQueryStaticData.cs
- SmtpTransport.cs
- serverconfig.cs
- XamlReader.cs
- CustomValidator.cs
- SerializationInfoEnumerator.cs
- OracleDataAdapter.cs
- CodeArgumentReferenceExpression.cs
- StyleModeStack.cs
- HttpListenerResponse.cs
- CaseInsensitiveComparer.cs
- AsyncResult.cs
- DataMisalignedException.cs
- WebPartDisplayMode.cs
- ImageMap.cs
- Renderer.cs
- SqlClientMetaDataCollectionNames.cs
- NavigationProgressEventArgs.cs
- EventDescriptor.cs
- BasicHttpMessageSecurityElement.cs
- ListViewDeleteEventArgs.cs
- HtmlInputImage.cs
- BuildProviderCollection.cs
- MobileContainerDesigner.cs
- Monitor.cs
- EventMappingSettings.cs
- PolicyAssertionCollection.cs
- EdmEntityTypeAttribute.cs
- SynchronizationContext.cs
- HostExecutionContextManager.cs
- ProgramPublisher.cs
- XMLDiffLoader.cs
- FieldAccessException.cs
- TransformPatternIdentifiers.cs
- ItemsPresenter.cs
- DropDownList.cs
- UrlPropertyAttribute.cs
- OracleCommandBuilder.cs
- NameValueFileSectionHandler.cs
- BooleanFunctions.cs
- MasterPage.cs
- UrlPath.cs
- BinaryParser.cs
- KeyGesture.cs
- OneOfConst.cs
- Ppl.cs
- SimpleHandlerBuildProvider.cs
- ObjectViewQueryResultData.cs
- Types.cs
- EntityUtil.cs
- AndCondition.cs
- CustomAttribute.cs
- AttachInfo.cs
- WrapperEqualityComparer.cs
- WindowsListViewGroupHelper.cs
- GetWinFXPath.cs
- ConfigUtil.cs
- LinqDataSourceView.cs
- FontFamilyConverter.cs
- ConnectionManagementElementCollection.cs
- AuthorizationSection.cs
- MoveSizeWinEventHandler.cs
- ChildTable.cs
- ApplyTemplatesAction.cs
- ScrollEventArgs.cs
- XmlWriter.cs
- ParallelTimeline.cs
- WizardForm.cs
- DataGridCommandEventArgs.cs
- WindowsGraphics2.cs
- updateconfighost.cs