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
- QilStrConcat.cs
- ResXDataNode.cs
- ISCIIEncoding.cs
- WmpBitmapEncoder.cs
- SqlRemoveConstantOrderBy.cs
- HMACSHA256.cs
- BindingExpressionUncommonField.cs
- HostingEnvironmentWrapper.cs
- OutputCacheSettings.cs
- SqlCachedBuffer.cs
- PlatformCulture.cs
- OracleCommand.cs
- DependencyObjectType.cs
- Size.cs
- X509SecurityTokenProvider.cs
- RepeaterDesigner.cs
- AsymmetricSecurityProtocol.cs
- PersonalizationStateInfo.cs
- SecureUICommand.cs
- ResourceType.cs
- GACMembershipCondition.cs
- PhysicalOps.cs
- PolicyVersion.cs
- BitmapDecoder.cs
- Win32.cs
- MediaElementAutomationPeer.cs
- WasEndpointConfigContainer.cs
- DbCommandDefinition.cs
- FrugalMap.cs
- LoginCancelEventArgs.cs
- SqlEnums.cs
- ConfigXmlSignificantWhitespace.cs
- ProcessHostConfigUtils.cs
- TemplateControlCodeDomTreeGenerator.cs
- BaseDataList.cs
- MultiSelectRootGridEntry.cs
- EntityDataSourceUtil.cs
- Renderer.cs
- EntityDesignPluralizationHandler.cs
- ClientRolePrincipal.cs
- AnalyzedTree.cs
- SqlConnection.cs
- ValidationEventArgs.cs
- BaseCodePageEncoding.cs
- DataControlFieldCell.cs
- DataKeyCollection.cs
- Command.cs
- DocComment.cs
- dataprotectionpermissionattribute.cs
- ColumnMapProcessor.cs
- DateTimePicker.cs
- XmlSchemas.cs
- TypeElement.cs
- SerializationEventsCache.cs
- EqualityComparer.cs
- Ops.cs
- PreviewPrintController.cs
- GraphicsContainer.cs
- GeometryDrawing.cs
- PrintPreviewDialog.cs
- HTMLTagNameToTypeMapper.cs
- InstanceLockedException.cs
- OperatingSystem.cs
- TriState.cs
- FixedSOMContainer.cs
- BaseResourcesBuildProvider.cs
- XsdValidatingReader.cs
- WsdlInspector.cs
- PackageRelationship.cs
- SelectionProcessor.cs
- SchemaDeclBase.cs
- HttpGetProtocolReflector.cs
- InvalidComObjectException.cs
- BufferedConnection.cs
- SharedRuntimeState.cs
- SiteIdentityPermission.cs
- sortedlist.cs
- OleDbWrapper.cs
- ArrayElementGridEntry.cs
- ScriptingSectionGroup.cs
- StandardMenuStripVerb.cs
- ErrorProvider.cs
- WindowsFormsHelpers.cs
- AssemblyNameProxy.cs
- DocumentGridPage.cs
- XmlSchemaProviderAttribute.cs
- ISAPIApplicationHost.cs
- SafeFileMapViewHandle.cs
- WeakReferenceKey.cs
- RectAnimation.cs
- Event.cs
- RoleService.cs
- StaticTextPointer.cs
- PointLightBase.cs
- CodeTypeDeclaration.cs
- LocalIdKeyIdentifierClause.cs
- SafeSerializationManager.cs
- RemoteWebConfigurationHostStream.cs
- EditorZoneBase.cs
- uribuilder.cs