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
- ProcessManager.cs
- LinkedList.cs
- MenuItemCollectionEditor.cs
- SamlSubjectStatement.cs
- ActivityScheduledQuery.cs
- DesignerLinkAdapter.cs
- DataGridCellInfo.cs
- XmlAttribute.cs
- TabControlEvent.cs
- ScaleTransform.cs
- JavascriptXmlWriterWrapper.cs
- TextSchema.cs
- CharUnicodeInfo.cs
- MetadataStore.cs
- DispatcherProcessingDisabled.cs
- TcpProcessProtocolHandler.cs
- HtmlContainerControl.cs
- ProfileEventArgs.cs
- RectangleF.cs
- DecodeHelper.cs
- Native.cs
- DataRowCollection.cs
- XmlLoader.cs
- TargetPerspective.cs
- Storyboard.cs
- userdatakeys.cs
- QilStrConcat.cs
- BamlTreeUpdater.cs
- baseaxisquery.cs
- ExitEventArgs.cs
- Context.cs
- HitTestWithPointDrawingContextWalker.cs
- DesignerFrame.cs
- QilFactory.cs
- IUnknownConstantAttribute.cs
- SqlBulkCopyColumnMapping.cs
- RelatedEnd.cs
- HotCommands.cs
- BitmapEffectInputConnector.cs
- ArrayConverter.cs
- GridEntry.cs
- BooleanConverter.cs
- Win32.cs
- DbConnectionInternal.cs
- CurrentChangingEventManager.cs
- FastEncoderWindow.cs
- NativeMethods.cs
- SQLGuidStorage.cs
- XhtmlBasicLabelAdapter.cs
- MetadataItemEmitter.cs
- dbenumerator.cs
- GlyphsSerializer.cs
- XmlLanguage.cs
- IteratorFilter.cs
- PeerName.cs
- SqlGenericUtil.cs
- Rect.cs
- AssociationProvider.cs
- PerspectiveCamera.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- TemplateNameScope.cs
- ServiceBusyException.cs
- InheritedPropertyChangedEventArgs.cs
- XsltFunctions.cs
- SettingsAttributeDictionary.cs
- StatusBar.cs
- SqlHelper.cs
- DebuggerAttributes.cs
- ProxyDataContractResolver.cs
- Regex.cs
- CodeCatchClause.cs
- ToolStripDropDownButton.cs
- DbConnectionPoolGroupProviderInfo.cs
- PageHandlerFactory.cs
- Inflater.cs
- NGCSerializationManager.cs
- WorkflowRuntimeService.cs
- AnonymousIdentificationSection.cs
- RegexTree.cs
- UniqueIdentifierService.cs
- DataGridViewEditingControlShowingEventArgs.cs
- UnsafeNativeMethodsTablet.cs
- ProviderSettings.cs
- ToolStripDropDownClosingEventArgs.cs
- SplitterDesigner.cs
- TextParagraph.cs
- DataGridItemCollection.cs
- ContractsBCL.cs
- EventLogPermissionAttribute.cs
- ClusterRegistryConfigurationProvider.cs
- ResourceContainer.cs
- HtmlProps.cs
- CodeParameterDeclarationExpressionCollection.cs
- WebBrowserHelper.cs
- DbConnectionClosed.cs
- ComNativeDescriptor.cs
- HyperLink.cs
- Crypto.cs
- HtmlTable.cs
- TreeNodeCollection.cs