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
- JsonEnumDataContract.cs
- LinearQuaternionKeyFrame.cs
- RequestCachePolicyConverter.cs
- StreamHelper.cs
- ArrayTypeMismatchException.cs
- WindowPattern.cs
- AtlasWeb.Designer.cs
- CommandCollectionEditor.cs
- MachineSettingsSection.cs
- PasswordRecoveryAutoFormat.cs
- TraceLog.cs
- RectConverter.cs
- _SSPISessionCache.cs
- TablePatternIdentifiers.cs
- CodeNamespaceImportCollection.cs
- BaseTemplateParser.cs
- Style.cs
- NegatedCellConstant.cs
- InvalidFilterCriteriaException.cs
- SmiXetterAccessMap.cs
- FlowDocumentReader.cs
- DataObject.cs
- TreeViewImageIndexConverter.cs
- Version.cs
- CSharpCodeProvider.cs
- Authorization.cs
- SerializerDescriptor.cs
- FtpCachePolicyElement.cs
- CodeTypeMember.cs
- DataGridViewColumnStateChangedEventArgs.cs
- CommandExpr.cs
- ObjectTag.cs
- StdValidatorsAndConverters.cs
- RawStylusInput.cs
- ExtensionDataObject.cs
- GeneratedCodeAttribute.cs
- StateRuntime.cs
- HashMembershipCondition.cs
- PasswordPropertyTextAttribute.cs
- TrustManagerPromptUI.cs
- MetadataSource.cs
- EncoderParameters.cs
- SizeConverter.cs
- BuildProviderCollection.cs
- BamlLocalizabilityResolver.cs
- Type.cs
- Thread.cs
- ReadWriteSpinLock.cs
- SqlCommandSet.cs
- DataTableReader.cs
- ServiceDocument.cs
- SerializationEventsCache.cs
- SqlConnectionStringBuilder.cs
- IdentifierCreationService.cs
- ObjectSet.cs
- XPathNodeHelper.cs
- DataTableNewRowEvent.cs
- ValidationManager.cs
- WeakReferenceList.cs
- SqlDependencyUtils.cs
- PageCache.cs
- ToolBarButton.cs
- SqlAliaser.cs
- BaseParser.cs
- BamlStream.cs
- EdmFunction.cs
- ReferentialConstraint.cs
- ElementNotEnabledException.cs
- SqlResolver.cs
- FastPropertyAccessor.cs
- SiteMapNodeCollection.cs
- WebServiceMethodData.cs
- XhtmlBasicCalendarAdapter.cs
- RedBlackList.cs
- StackOverflowException.cs
- PenCursorManager.cs
- ResourcePermissionBase.cs
- QilCloneVisitor.cs
- PolicyLevel.cs
- AxHost.cs
- ShutDownListener.cs
- XmlDataProvider.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- PageParser.cs
- COM2ExtendedBrowsingHandler.cs
- MouseButton.cs
- SplayTreeNode.cs
- DesignerActionTextItem.cs
- WpfMemberInvoker.cs
- DataProtection.cs
- TemplateBamlRecordReader.cs
- LinqDataSourceDisposeEventArgs.cs
- WaitHandleCannotBeOpenedException.cs
- ExpressionLink.cs
- RadioButtonRenderer.cs
- EditorPartCollection.cs
- NonSerializedAttribute.cs
- _PooledStream.cs
- latinshape.cs
- EventListenerClientSide.cs