Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Base / MS / Internal / InheritanceContextChangedEventManager.cs / 1305600 / 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) { if (source == null) throw new ArgumentNullException("source"); if (listener == null) throw new ArgumentNullException("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) { if (source == null) throw new ArgumentNullException("source"); if (listener == null) throw new ArgumentNullException("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
- BulletDecorator.cs
- DataGridPagerStyle.cs
- DataGridViewCellStyleEditor.cs
- VirtualizedItemPattern.cs
- SafeSecurityHelper.cs
- XmlSchemaGroupRef.cs
- DoubleUtil.cs
- ManagedIStream.cs
- XmlDesigner.cs
- AttachedPropertyMethodSelector.cs
- DispatcherExceptionEventArgs.cs
- RangeValidator.cs
- DynamicEndpointElement.cs
- TransactionInformation.cs
- BlurBitmapEffect.cs
- NetworkInterface.cs
- UIHelper.cs
- RequestCacheValidator.cs
- NamedElement.cs
- OpenCollectionAsyncResult.cs
- ProxyGenerator.cs
- CounterCreationDataCollection.cs
- EtwTrace.cs
- SizeAnimation.cs
- LicFileLicenseProvider.cs
- MULTI_QI.cs
- GlobalId.cs
- HtmlInputFile.cs
- SmiEventStream.cs
- XamlTypeMapper.cs
- _ConnectStream.cs
- LOSFormatter.cs
- ImageDrawing.cs
- TextEditorThreadLocalStore.cs
- PerfCounterSection.cs
- XmlSchemaSimpleContent.cs
- DuplicateWaitObjectException.cs
- MessagePropertyDescription.cs
- CancellationHandlerDesigner.cs
- MemberAccessException.cs
- EntityDataSourceColumn.cs
- Table.cs
- HttpConfigurationSystem.cs
- ImageFormatConverter.cs
- GridViewCellAutomationPeer.cs
- DispatcherTimer.cs
- WebPartConnectionsConfigureVerb.cs
- CoTaskMemSafeHandle.cs
- sqlser.cs
- TargetException.cs
- QueryExpression.cs
- ColorPalette.cs
- ButtonChrome.cs
- ButtonChrome.cs
- DbConnectionPoolOptions.cs
- ValidationRule.cs
- DataRowExtensions.cs
- MappedMetaModel.cs
- QueryAccessibilityHelpEvent.cs
- AtomParser.cs
- rsa.cs
- TableHeaderCell.cs
- ITreeGenerator.cs
- RtfControlWordInfo.cs
- WorkflowMessageEventArgs.cs
- ToolStripSplitButton.cs
- CachedCompositeFamily.cs
- Clipboard.cs
- ArrangedElementCollection.cs
- GridErrorDlg.cs
- MorphHelper.cs
- Rfc4050KeyFormatter.cs
- Aes.cs
- ChooseAction.cs
- SelectionRangeConverter.cs
- ClientSession.cs
- ThrowHelper.cs
- IncrementalCompileAnalyzer.cs
- GacUtil.cs
- RotateTransform.cs
- ContractMethodInfo.cs
- ControllableStoryboardAction.cs
- SourceChangedEventArgs.cs
- NamedPipeConnectionPoolSettings.cs
- TouchDevice.cs
- WinFormsComponentEditor.cs
- CheckBox.cs
- UserControl.cs
- DeclaredTypeElementCollection.cs
- ArraySortHelper.cs
- TextElementCollectionHelper.cs
- IdentityHolder.cs
- CollectionChangedEventManager.cs
- Instrumentation.cs
- SourceItem.cs
- XPathParser.cs
- HyperlinkAutomationPeer.cs
- SafeRightsManagementPubHandle.cs
- ErasingStroke.cs
- Query.cs