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
- InvalidWMPVersionException.cs
- EdgeProfileValidation.cs
- RectKeyFrameCollection.cs
- VisualProxy.cs
- XDeferredAxisSource.cs
- BinaryObjectReader.cs
- CodeTypeReferenceExpression.cs
- HeaderUtility.cs
- SimpleApplicationHost.cs
- Pair.cs
- ProxyManager.cs
- NamespaceMapping.cs
- StubHelpers.cs
- BaseParaClient.cs
- DBParameter.cs
- TreeViewEvent.cs
- ListItemCollection.cs
- EllipseGeometry.cs
- Interlocked.cs
- GetIndexBinder.cs
- DockPattern.cs
- ApplicationHost.cs
- KeyManager.cs
- OpCellTreeNode.cs
- PagedDataSource.cs
- Compiler.cs
- PageBuildProvider.cs
- DateTimeStorage.cs
- HtmlEncodedRawTextWriter.cs
- Double.cs
- ProcessHostFactoryHelper.cs
- ProbeDuplexAsyncResult.cs
- AnonymousIdentificationModule.cs
- TextClipboardData.cs
- TextRunCacheImp.cs
- MergePropertyDescriptor.cs
- HelpHtmlBuilder.cs
- WebScriptMetadataMessageEncoderFactory.cs
- DataGridPageChangedEventArgs.cs
- FixedSOMTableRow.cs
- MasterPageCodeDomTreeGenerator.cs
- WebInvokeAttribute.cs
- XpsResource.cs
- FontInfo.cs
- ActivityStatusChangeEventArgs.cs
- Label.cs
- Repeater.cs
- SoapSchemaMember.cs
- FlowNode.cs
- TemplatePartAttribute.cs
- XPathException.cs
- SmtpNtlmAuthenticationModule.cs
- DESCryptoServiceProvider.cs
- OleDbCommand.cs
- DependencyPropertyHelper.cs
- TextChange.cs
- ResourceDescriptionAttribute.cs
- TdsParserStaticMethods.cs
- ResourceExpressionBuilder.cs
- SaveFileDialog.cs
- DriveInfo.cs
- HttpRawResponse.cs
- CompensationParticipant.cs
- GACMembershipCondition.cs
- DateTimeFormat.cs
- ApplicationGesture.cs
- GridLengthConverter.cs
- Update.cs
- CriticalFileToken.cs
- Ray3DHitTestResult.cs
- AssertSection.cs
- basecomparevalidator.cs
- RepeatBehaviorConverter.cs
- DataSourceHelper.cs
- _UriSyntax.cs
- SweepDirectionValidation.cs
- TextEditorDragDrop.cs
- Sql8ExpressionRewriter.cs
- ISAPIRuntime.cs
- XmlDocumentSchema.cs
- EventWaitHandleSecurity.cs
- RegexTree.cs
- NodeCounter.cs
- PermissionSet.cs
- ConfigurationSchemaErrors.cs
- ListItemConverter.cs
- BoundField.cs
- Section.cs
- IndexOutOfRangeException.cs
- ButtonColumn.cs
- TextWriterTraceListener.cs
- _SslState.cs
- EntityProviderFactory.cs
- ClaimSet.cs
- WindowsToolbar.cs
- ImageCodecInfoPrivate.cs
- _ConnectionGroup.cs
- ClientApiGenerator.cs
- StaticFileHandler.cs
- EdmProviderManifest.cs