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
- WebAdminConfigurationHelper.cs
- TemplateKeyConverter.cs
- RuntimeWrappedException.cs
- ScriptingWebServicesSectionGroup.cs
- ObjectListCommandCollection.cs
- FontCollection.cs
- CompModHelpers.cs
- MarginCollapsingState.cs
- NativeCppClassAttribute.cs
- x509store.cs
- SspiWrapper.cs
- RotationValidation.cs
- Span.cs
- RtfToXamlReader.cs
- HandleValueEditor.cs
- SafeCoTaskMem.cs
- GridViewSortEventArgs.cs
- BitmapEffectGroup.cs
- AudioFormatConverter.cs
- MDIWindowDialog.cs
- JulianCalendar.cs
- StringOutput.cs
- UidManager.cs
- MappedMetaModel.cs
- ListControl.cs
- PropertyPath.cs
- Currency.cs
- SchemaElementDecl.cs
- ReachPageContentSerializer.cs
- SortedList.cs
- DataGridViewCellValueEventArgs.cs
- List.cs
- MultiView.cs
- Vector3DConverter.cs
- HelloOperationAsyncResult.cs
- MultiPropertyDescriptorGridEntry.cs
- ListMarkerSourceInfo.cs
- HttpResponse.cs
- SpinWait.cs
- ExtenderProvidedPropertyAttribute.cs
- SHA512Cng.cs
- XmlSchemaSequence.cs
- SqlCacheDependencySection.cs
- WindowsImpersonationContext.cs
- XmlDictionaryReaderQuotas.cs
- TextParaLineResult.cs
- SmtpCommands.cs
- TreeViewCancelEvent.cs
- IdentityElement.cs
- RootAction.cs
- WindowsListViewGroup.cs
- RegexNode.cs
- infer.cs
- FormViewInsertEventArgs.cs
- VirtualDirectoryMappingCollection.cs
- GridViewCellAutomationPeer.cs
- ExpressionEditorSheet.cs
- WmlCommandAdapter.cs
- DetailsViewRowCollection.cs
- Size3D.cs
- GeneratedContractType.cs
- ProcessHostServerConfig.cs
- EventArgs.cs
- IdnMapping.cs
- MessageSmuggler.cs
- WebSysDisplayNameAttribute.cs
- ScriptModule.cs
- SqlAliaser.cs
- ZipPackage.cs
- WorkflowRuntime.cs
- FixedSOMTableCell.cs
- InfoCardMasterKey.cs
- ConditionalDesigner.cs
- SerialPort.cs
- OlePropertyStructs.cs
- TextServicesContext.cs
- StringSource.cs
- ChameleonKey.cs
- StorageConditionPropertyMapping.cs
- SHA512.cs
- SplitterPanelDesigner.cs
- TextureBrush.cs
- PropertyGridDesigner.cs
- SafeMILHandle.cs
- TableCell.cs
- ExtendedProtectionPolicyTypeConverter.cs
- Stylus.cs
- Fonts.cs
- FormatterServices.cs
- MessageProtectionOrder.cs
- StandardBindingReliableSessionElement.cs
- AssemblyGen.cs
- NavigationEventArgs.cs
- TemplateControl.cs
- SponsorHelper.cs
- SerializationHelper.cs
- ISSmlParser.cs
- Component.cs
- SinglePageViewer.cs
- mactripleDES.cs