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
- WebReferencesBuildProvider.cs
- SystemResourceKey.cs
- FormsAuthenticationTicket.cs
- WebPartDescriptionCollection.cs
- AssemblyInfo.cs
- ContextBase.cs
- AssemblyAttributesGoHere.cs
- ReferenceConverter.cs
- FeedUtils.cs
- autovalidator.cs
- PrePrepareMethodAttribute.cs
- Resources.Designer.cs
- AsymmetricSignatureDeformatter.cs
- PrintPreviewDialog.cs
- ECDiffieHellman.cs
- ImageListUtils.cs
- ToolStripItem.cs
- DataPagerFieldCollection.cs
- DataGridColumnsPage.cs
- PagesSection.cs
- ConnectionPoint.cs
- SqlFunctionAttribute.cs
- StorageModelBuildProvider.cs
- PermissionSet.cs
- CharConverter.cs
- CustomServiceCredentials.cs
- XmlDeclaration.cs
- SequentialActivityDesigner.cs
- ListViewAutomationPeer.cs
- ThicknessConverter.cs
- Base64Encoder.cs
- TextElementEnumerator.cs
- XmlSchemas.cs
- XmlSchemaProviderAttribute.cs
- NumericPagerField.cs
- DateTimeOffsetConverter.cs
- CompilerGeneratedAttribute.cs
- XmlSchemaGroupRef.cs
- SplitterPanel.cs
- mediaclock.cs
- DecoderExceptionFallback.cs
- LoginUtil.cs
- GenericIdentity.cs
- NamedElement.cs
- UndirectedGraph.cs
- TreeNodeSelectionProcessor.cs
- MapPathBasedVirtualPathProvider.cs
- HMACSHA384.cs
- AutomationElementCollection.cs
- MemoryRecordBuffer.cs
- DelegatingTypeDescriptionProvider.cs
- InputGestureCollection.cs
- BindingSource.cs
- UserControl.cs
- StatementContext.cs
- XXXOnTypeBuilderInstantiation.cs
- UTF32Encoding.cs
- SqlCachedBuffer.cs
- TextTreeInsertElementUndoUnit.cs
- IndexedEnumerable.cs
- ButtonBase.cs
- SelectionPattern.cs
- ArcSegment.cs
- Int16Converter.cs
- sqlnorm.cs
- PageSettings.cs
- ProfileModule.cs
- OracleException.cs
- SafeNativeMethodsMilCoreApi.cs
- MultiBinding.cs
- CursorInteropHelper.cs
- Geometry.cs
- ReliableChannelListener.cs
- recordstatefactory.cs
- SchemaExporter.cs
- WorkItem.cs
- ExtenderControl.cs
- PrintDialog.cs
- DataGridViewTextBoxCell.cs
- WpfWebRequestHelper.cs
- AttributeXamlType.cs
- FrameworkContextData.cs
- PeerCollaborationPermission.cs
- RouteUrlExpressionBuilder.cs
- XmlSchemaSimpleTypeList.cs
- StreamResourceInfo.cs
- TransferRequestHandler.cs
- TemplateManager.cs
- HostProtectionPermission.cs
- AggregateNode.cs
- Floater.cs
- HandledMouseEvent.cs
- NotImplementedException.cs
- Menu.cs
- XmlConvert.cs
- SoapFault.cs
- PrimitiveRenderer.cs
- RequiredAttributeAttribute.cs
- LabelDesigner.cs
- RewritingPass.cs