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
- SamlAssertion.cs
- HtmlInputSubmit.cs
- PackWebResponse.cs
- WorkflowValidationFailedException.cs
- DuplicateWaitObjectException.cs
- BitmapEffectGroup.cs
- ImageSourceConverter.cs
- SafeCryptoHandles.cs
- DataGridViewColumnCollection.cs
- ClientOptions.cs
- NameTable.cs
- CustomAttributeBuilder.cs
- baseaxisquery.cs
- followingquery.cs
- TreeNodeEventArgs.cs
- XhtmlBasicImageAdapter.cs
- TrackingProfileManager.cs
- NetNamedPipeSecurityElement.cs
- CompiledRegexRunnerFactory.cs
- parserscommon.cs
- XmlSchemaGroup.cs
- ToolStripDropDown.cs
- PrintEvent.cs
- KeyNotFoundException.cs
- HttpInputStream.cs
- TransactedBatchContext.cs
- ListViewEditEventArgs.cs
- ScalarConstant.cs
- SimpleWebHandlerParser.cs
- __ConsoleStream.cs
- BeginGetFileNameFromUserRequest.cs
- PreservationFileWriter.cs
- DataGridSortCommandEventArgs.cs
- HttpVersion.cs
- HoistedLocals.cs
- TableColumn.cs
- MatrixConverter.cs
- WebPartUserCapability.cs
- SqlRowUpdatedEvent.cs
- CompositionTarget.cs
- SqlDataSourceView.cs
- ValueUnavailableException.cs
- AlphabeticalEnumConverter.cs
- MetadataWorkspace.cs
- WarningException.cs
- EmptyStringExpandableObjectConverter.cs
- QueryOperationResponseOfT.cs
- ThreadAttributes.cs
- GlobalEventManager.cs
- DefaultDiscoveryServiceExtension.cs
- ISFClipboardData.cs
- ObjectSecurity.cs
- TransactionManagerProxy.cs
- DesignerCapabilities.cs
- XmlSchemaException.cs
- WindowsUserNameCachingSecurityTokenAuthenticator.cs
- MenuBase.cs
- DiscoveryEndpointValidator.cs
- DataFieldCollectionEditor.cs
- XmlTypeAttribute.cs
- LiteralSubsegment.cs
- DoubleAnimationUsingPath.cs
- _TransmitFileOverlappedAsyncResult.cs
- DataErrorValidationRule.cs
- ResourceBinder.cs
- SqlParameterCollection.cs
- AssertFilter.cs
- IntPtr.cs
- FileLoadException.cs
- WriteFileContext.cs
- EncoderExceptionFallback.cs
- DiscoveryClientBindingElement.cs
- Marshal.cs
- KeyEvent.cs
- CodeFieldReferenceExpression.cs
- OleDbSchemaGuid.cs
- TextTreeUndoUnit.cs
- XmlCharCheckingReader.cs
- ClientTargetCollection.cs
- XmlSchemaType.cs
- EFColumnProvider.cs
- ScrollChrome.cs
- IndentedWriter.cs
- XmlSerializationWriter.cs
- oledbconnectionstring.cs
- HWStack.cs
- SmtpClient.cs
- StateInitializationDesigner.cs
- WindowsFormsSectionHandler.cs
- CommentGlyph.cs
- Blend.cs
- SchemaAttDef.cs
- OdbcConnectionHandle.cs
- NamedPipeProcessProtocolHandler.cs
- WindowsEditBox.cs
- UnmanagedMemoryStreamWrapper.cs
- DataGridViewHitTestInfo.cs
- CopyOnWriteList.cs
- SubMenuStyleCollection.cs
- Serializer.cs