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
- FileUpload.cs
- PartialTrustHelpers.cs
- UInt64Storage.cs
- GifBitmapEncoder.cs
- CryptographicAttribute.cs
- CompiledXpathExpr.cs
- EnumValAlphaComparer.cs
- securitycriticaldataformultiplegetandset.cs
- DataReaderContainer.cs
- UnmanagedMemoryAccessor.cs
- InlineObject.cs
- ProgressChangedEventArgs.cs
- HeaderUtility.cs
- SizeAnimationBase.cs
- StatusBarAutomationPeer.cs
- BitmapMetadataEnumerator.cs
- OutputWindow.cs
- VarRemapper.cs
- ExpressionParser.cs
- ThrowHelper.cs
- HttpModule.cs
- TextRangeProviderWrapper.cs
- SectionInformation.cs
- TextBox.cs
- ToolStripSettings.cs
- RelatedEnd.cs
- RuntimeTrackingProfile.cs
- TreeViewTemplateSelector.cs
- SineEase.cs
- FixedSOMTable.cs
- ProgressBarHighlightConverter.cs
- ConfigXmlSignificantWhitespace.cs
- TextCompositionManager.cs
- __Filters.cs
- DataViewManagerListItemTypeDescriptor.cs
- followingquery.cs
- GetPolicyDetailsRequest.cs
- XmlExpressionDumper.cs
- SelectionGlyph.cs
- PassportAuthenticationEventArgs.cs
- CompModSwitches.cs
- DesignerRegionMouseEventArgs.cs
- Automation.cs
- Selection.cs
- MenuAutoFormat.cs
- Ref.cs
- ValidatorCollection.cs
- XmlReflectionMember.cs
- WebPartConnectionsCancelEventArgs.cs
- SocketStream.cs
- FixedTextView.cs
- EdmConstants.cs
- OleAutBinder.cs
- SmiTypedGetterSetter.cs
- AnimationClock.cs
- ProfileSettingsCollection.cs
- cookieexception.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- SigningCredentials.cs
- DESCryptoServiceProvider.cs
- StringBuilder.cs
- XmlToDatasetMap.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- HyperLinkStyle.cs
- SelectionHighlightInfo.cs
- SmiMetaDataProperty.cs
- SharedConnectionWorkflowTransactionService.cs
- ManagedWndProcTracker.cs
- CompilerError.cs
- ObjectQuery_EntitySqlExtensions.cs
- AncestorChangedEventArgs.cs
- Image.cs
- Task.cs
- StringDictionary.cs
- TileBrush.cs
- DataGridViewRow.cs
- RequestSecurityTokenForGetBrowserToken.cs
- Track.cs
- TdsParser.cs
- DataGrid.cs
- CacheMode.cs
- SchemaDeclBase.cs
- PositiveTimeSpanValidator.cs
- TemplateApplicationHelper.cs
- BaseDataBoundControl.cs
- UInt64Storage.cs
- StringKeyFrameCollection.cs
- ThreadAttributes.cs
- SystemDiagnosticsSection.cs
- Cursor.cs
- ComponentSerializationService.cs
- PointHitTestResult.cs
- _Rfc2616CacheValidators.cs
- IISUnsafeMethods.cs
- TabControlEvent.cs
- HttpResponseInternalBase.cs
- XDRSchema.cs
- ButtonBaseAdapter.cs
- GridViewCancelEditEventArgs.cs
- DataSvcMapFileSerializer.cs