Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- NameValueConfigurationElement.cs
- FaultPropagationQuery.cs
- MediaEntryAttribute.cs
- DataKey.cs
- StoreItemCollection.cs
- CheckedPointers.cs
- CipherData.cs
- AutomationPropertyChangedEventArgs.cs
- SqlUtil.cs
- IsolatedStorageSecurityState.cs
- TreeIterators.cs
- ReadOnlyCollectionBase.cs
- SqlStream.cs
- ChannelManager.cs
- ItemCheckEvent.cs
- TypeGenericEnumerableViewSchema.cs
- RIPEMD160.cs
- basemetadatamappingvisitor.cs
- ObjectDataSourceEventArgs.cs
- ModelVisual3D.cs
- FixedSOMImage.cs
- Substitution.cs
- StateMachineTimers.cs
- SchemaImporterExtensionElement.cs
- EncodingTable.cs
- AtlasWeb.Designer.cs
- DivideByZeroException.cs
- Binding.cs
- CheckStoreFileValidityRequest.cs
- CategoryAttribute.cs
- AppendHelper.cs
- ErrorWrapper.cs
- TitleStyle.cs
- TrackingMemoryStream.cs
- DialogResultConverter.cs
- FacetDescriptionElement.cs
- TypeBuilder.cs
- DynamicRendererThreadManager.cs
- TdsEnums.cs
- RuntimeEnvironment.cs
- DbSourceCommand.cs
- EditorZone.cs
- HelpProvider.cs
- CompareInfo.cs
- HttpsHostedTransportConfiguration.cs
- PixelFormatConverter.cs
- OrderedHashRepartitionEnumerator.cs
- StartUpEventArgs.cs
- WindowsSpinner.cs
- WebAdminConfigurationHelper.cs
- SelectionPatternIdentifiers.cs
- DecimalStorage.cs
- StylusEventArgs.cs
- ThumbAutomationPeer.cs
- MaterializeFromAtom.cs
- RenderContext.cs
- GeometryCollection.cs
- Trigger.cs
- OrderedDictionary.cs
- CssStyleCollection.cs
- CachingHintValidation.cs
- Utils.cs
- StyleBamlRecordReader.cs
- MetaColumn.cs
- XamlFigureLengthSerializer.cs
- XmlStringTable.cs
- AssociationTypeEmitter.cs
- TimeoutException.cs
- LoadedOrUnloadedOperation.cs
- DataGridViewAutoSizeModeEventArgs.cs
- MonthCalendar.cs
- WeakReference.cs
- HandleDictionary.cs
- TagMapCollection.cs
- ValidatingReaderNodeData.cs
- PersonalizableTypeEntry.cs
- SystemColors.cs
- RelatedEnd.cs
- XMLSchema.cs
- SplitterCancelEvent.cs
- ExpressionVisitor.cs
- PointValueSerializer.cs
- ModelServiceImpl.cs
- Visual.cs
- ValueConversionAttribute.cs
- WindowsListViewItemStartMenu.cs
- XhtmlConformanceSection.cs
- WorkflowServiceOperationListItem.cs
- X509CertificateTokenFactoryCredential.cs
- MsmqOutputSessionChannel.cs
- BindingList.cs
- TreeNodeClickEventArgs.cs
- ViewEvent.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- SqlUserDefinedTypeAttribute.cs
- SequentialUshortCollection.cs
- TitleStyle.cs
- NativeRecognizer.cs
- ReadOnlyCollectionBase.cs
- ComponentChangingEvent.cs