Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Base / MS / Internal / InheritanceContextChangedEventManager.cs / 1 / InheritanceContextChangedEventManager.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: Manager for the InheritanceContextChanged event in the "weak event listener" // pattern. See WeakEventTable.cs for an overview. // //--------------------------------------------------------------------------- using System; using System.Diagnostics; using System.Windows; // WeakEventManager using MS.Internal.WindowsBase; // [FriendAccessAllowed] namespace MS.Internal { ////// Manager for the DependencyObject.InheritanceContextChanged event. /// [FriendAccessAllowed] internal class InheritanceContextChangedEventManager : WeakEventManager { #region Constructors // // Constructors // private InheritanceContextChangedEventManager() { } #endregion Constructors #region Public Methods // // Public Methods // ////// Add a listener to the given source's event. /// public static void AddListener(DependencyObject source, IWeakEventListener listener) { // Freezable.Freeze() relies on the assumption that a frozen Freezable // has no listeners. This is because Freeze() fails if the Freezable // has any Expressions on it, and only Expressions ever listen // to the InheritanceContextChanged event. Debug.Assert(listener is Expression); CurrentManager.ProtectedAddListener(source, listener); } ////// Remove a listener to the given source's event. /// public static void RemoveListener(DependencyObject source, IWeakEventListener listener) { CurrentManager.ProtectedRemoveListener(source, listener); } #endregion Public Methods #region Protected Methods // // Protected Methods // ////// Listen to the given source for the event. /// protected override void StartListening(object source) { DependencyObject typedSource = (DependencyObject)source; typedSource.InheritanceContextChanged += new EventHandler(OnInheritanceContextChanged); } ////// Stop listening to the given source for the event. /// protected override void StopListening(object source) { DependencyObject typedSource = (DependencyObject)source; typedSource.InheritanceContextChanged -= new EventHandler(OnInheritanceContextChanged); } #endregion Protected Methods #region Private Properties // // Private Properties // // get the event manager for the current thread private static InheritanceContextChangedEventManager CurrentManager { get { Type managerType = typeof(InheritanceContextChangedEventManager); InheritanceContextChangedEventManager manager = (InheritanceContextChangedEventManager)GetCurrentManager(managerType); // at first use, create and register a new manager if (manager == null) { manager = new InheritanceContextChangedEventManager(); SetCurrentManager(managerType, manager); } return manager; } } #endregion Private Properties #region Private Methods // // Private Methods // // event handler for InheritanceContextChanged event private void OnInheritanceContextChanged(object sender, EventArgs args) { DeliverEvent(sender, args); } #endregion Private Methods } } // 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
- DynamicRendererThreadManager.cs
- VideoDrawing.cs
- UnsafeNativeMethods.cs
- SafeThreadHandle.cs
- DateTimeParse.cs
- XPathDocument.cs
- InkPresenterAutomationPeer.cs
- FileDialog_Vista_Interop.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- RawStylusInputCustomData.cs
- PersistenceException.cs
- HeaderedItemsControl.cs
- EventMappingSettingsCollection.cs
- SByteStorage.cs
- XamlPathDataSerializer.cs
- SqlProcedureAttribute.cs
- Filter.cs
- XmlImplementation.cs
- ForeignConstraint.cs
- XmlMapping.cs
- TableAdapterManagerGenerator.cs
- ElementAtQueryOperator.cs
- ComponentResourceKey.cs
- CatalogPartCollection.cs
- GenericUriParser.cs
- SimpleRecyclingCache.cs
- PrivilegedConfigurationManager.cs
- _SafeNetHandles.cs
- OdbcEnvironment.cs
- ViewPort3D.cs
- WriteFileContext.cs
- Nullable.cs
- WhitespaceSignificantCollectionAttribute.cs
- OciLobLocator.cs
- ChtmlFormAdapter.cs
- ArrayList.cs
- BamlLocalizationDictionary.cs
- XmlNamespaceManager.cs
- ControlCollection.cs
- CryptographicAttribute.cs
- AuthorizationRuleCollection.cs
- DataGridViewCellCollection.cs
- Thickness.cs
- UniqueSet.cs
- PrivateFontCollection.cs
- DrawListViewColumnHeaderEventArgs.cs
- IdentitySection.cs
- DropTarget.cs
- XmlArrayItemAttribute.cs
- ButtonRenderer.cs
- FormViewDeleteEventArgs.cs
- Accessors.cs
- XDRSchema.cs
- PeerValidationBehavior.cs
- QueryCacheEntry.cs
- SafePointer.cs
- HtmlContainerControl.cs
- ValidationSummaryDesigner.cs
- CaseInsensitiveComparer.cs
- DocumentPageView.cs
- prompt.cs
- METAHEADER.cs
- BinaryCommonClasses.cs
- PrePrepareMethodAttribute.cs
- RoleService.cs
- SqlConnectionHelper.cs
- ProxyRpc.cs
- PackWebRequest.cs
- XPathDocumentNavigator.cs
- SingleKeyFrameCollection.cs
- DbTransaction.cs
- XmlJsonWriter.cs
- MouseGestureValueSerializer.cs
- AssemblyNameProxy.cs
- DurationConverter.cs
- HierarchicalDataSourceControl.cs
- CategoryNameCollection.cs
- UnaryOperationBinder.cs
- _AutoWebProxyScriptHelper.cs
- XmlWrappingReader.cs
- RootProjectionNode.cs
- TableItemPattern.cs
- SparseMemoryStream.cs
- PartitionResolver.cs
- StringStorage.cs
- AutoResetEvent.cs
- DataGridViewCellStateChangedEventArgs.cs
- XmlSerializationGeneratedCode.cs
- SqlTriggerContext.cs
- WindowsSolidBrush.cs
- StrongNameMembershipCondition.cs
- SqlNotificationRequest.cs
- DataGridViewAccessibleObject.cs
- PenThread.cs
- InvalidPrinterException.cs
- LongValidator.cs
- HiddenField.cs
- OrCondition.cs
- DiagnosticEventProvider.cs
- PropertyIDSet.cs