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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PermissionRequestEvidence.cs
- SqlTopReducer.cs
- TdsParserHelperClasses.cs
- RequestCacheValidator.cs
- ListMarkerLine.cs
- XmlCharCheckingReader.cs
- DataList.cs
- EnumUnknown.cs
- FeatureSupport.cs
- TextEndOfLine.cs
- DynamicResourceExtension.cs
- ISO2022Encoding.cs
- LambdaCompiler.Binary.cs
- DataKeyArray.cs
- RoleManagerSection.cs
- URIFormatException.cs
- MessageSmuggler.cs
- PathStreamGeometryContext.cs
- BindingEntityInfo.cs
- ToolBarPanel.cs
- SocketManager.cs
- FieldMetadata.cs
- GeometryValueSerializer.cs
- DataSourceNameHandler.cs
- NativeMethodsCLR.cs
- TypeConvertions.cs
- CompilerParameters.cs
- FrameworkObject.cs
- ObjectKeyFrameCollection.cs
- GenericTypeParameterConverter.cs
- SubpageParagraph.cs
- LinkClickEvent.cs
- EntitySetBase.cs
- Crc32.cs
- Authorization.cs
- ButtonColumn.cs
- MasterPage.cs
- KnownIds.cs
- DelegateInArgument.cs
- TransformerInfoCollection.cs
- DecodeHelper.cs
- BitConverter.cs
- Int32EqualityComparer.cs
- ActivityDesigner.cs
- XmlSchemaCompilationSettings.cs
- ThicknessKeyFrameCollection.cs
- RuntimeIdentifierPropertyAttribute.cs
- WebPartConnectVerb.cs
- HtmlInputReset.cs
- ConfigXmlText.cs
- DataControlFieldCell.cs
- WindowsListViewItemCheckBox.cs
- FormViewCommandEventArgs.cs
- ArrayExtension.cs
- RSAPKCS1SignatureFormatter.cs
- XmlUtf8RawTextWriter.cs
- UnsafeNativeMethods.cs
- Frame.cs
- SessionChannels.cs
- DbDeleteCommandTree.cs
- CompositeActivityValidator.cs
- ScrollBarAutomationPeer.cs
- DataReaderContainer.cs
- Odbc32.cs
- util.cs
- SafeUserTokenHandle.cs
- TabControlEvent.cs
- AnnotationResourceChangedEventArgs.cs
- ServiceModelInstallComponent.cs
- SQLDouble.cs
- figurelength.cs
- externdll.cs
- MailWebEventProvider.cs
- ToolboxItemAttribute.cs
- SynchronizationContext.cs
- DoneReceivingAsyncResult.cs
- SQLMembershipProvider.cs
- DynamicRouteExpression.cs
- EntityStoreSchemaFilterEntry.cs
- NativeMethods.cs
- ScriptMethodAttribute.cs
- ListItemsCollectionEditor.cs
- SynchronizationFilter.cs
- RectangleF.cs
- FileDialog_Vista.cs
- Variable.cs
- FlagsAttribute.cs
- ConcatQueryOperator.cs
- Dispatcher.cs
- Queue.cs
- StateItem.cs
- CodeGeneratorOptions.cs
- TextRunCacheImp.cs
- MemberDescriptor.cs
- SymbolUsageManager.cs
- PublisherMembershipCondition.cs
- ValueProviderWrapper.cs
- Int16.cs
- DBAsyncResult.cs
- TreeViewItemAutomationPeer.cs