Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / 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. //---------------------------------------------------------------------------- // //// 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
- OutputScopeManager.cs
- ScriptingWebServicesSectionGroup.cs
- StoreContentChangedEventArgs.cs
- SelectionPatternIdentifiers.cs
- CheckBoxRenderer.cs
- PersonalizationAdministration.cs
- SectionUpdates.cs
- ImpersonateTokenRef.cs
- DbProviderConfigurationHandler.cs
- SerializationAttributes.cs
- SettingsPropertyWrongTypeException.cs
- ScriptControl.cs
- WindowsRebar.cs
- HashJoinQueryOperatorEnumerator.cs
- OracleParameterCollection.cs
- SurrogateSelector.cs
- FileIOPermission.cs
- WindowsFormsDesignerOptionService.cs
- SQLSingle.cs
- SharedPerformanceCounter.cs
- EmptyEnumerable.cs
- XPathAncestorQuery.cs
- Object.cs
- RegistryDataKey.cs
- Label.cs
- WriteableBitmap.cs
- MessageTransmitTraceRecord.cs
- CssStyleCollection.cs
- filewebrequest.cs
- UnionExpr.cs
- MapPathBasedVirtualPathProvider.cs
- AnnotationHelper.cs
- TableLayoutCellPaintEventArgs.cs
- InternalDispatchObject.cs
- ToolStripPanelRow.cs
- UTF32Encoding.cs
- CoTaskMemHandle.cs
- TextRange.cs
- ErrorProvider.cs
- RootNamespaceAttribute.cs
- TreeNodeBindingCollection.cs
- WorkflowMarkupSerializationManager.cs
- FormParameter.cs
- WebPageTraceListener.cs
- Int16Animation.cs
- OperatorExpressions.cs
- RectAnimation.cs
- DataGridViewSelectedRowCollection.cs
- TraceHandlerErrorFormatter.cs
- Compiler.cs
- XPathAncestorQuery.cs
- UInt32Storage.cs
- XmlSequenceWriter.cs
- Point3DAnimationBase.cs
- ReceiveSecurityHeader.cs
- SmiGettersStream.cs
- OperationParameterInfoCollection.cs
- DesignerEditorPartChrome.cs
- MultiDataTrigger.cs
- CodeExpressionStatement.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- OleDbFactory.cs
- PointHitTestParameters.cs
- UnmanagedMarshal.cs
- CharConverter.cs
- DBNull.cs
- ToggleButtonAutomationPeer.cs
- ObjectConverter.cs
- HitTestFilterBehavior.cs
- PageEventArgs.cs
- MenuItem.cs
- SchemaCollectionCompiler.cs
- SafeNativeMethods.cs
- TokenBasedSet.cs
- RecognizedAudio.cs
- XmlRawWriter.cs
- HealthMonitoringSection.cs
- ZeroOpNode.cs
- DataGridViewSelectedCellCollection.cs
- List.cs
- TimeStampChecker.cs
- DocumentationServerProtocol.cs
- DocumentPageViewAutomationPeer.cs
- DefaultBinder.cs
- DataRecordInfo.cs
- SByteStorage.cs
- WorkflowTransactionOptions.cs
- ToolboxItemCollection.cs
- Translator.cs
- RoutedEventValueSerializer.cs
- TextClipboardData.cs
- ClientType.cs
- ToolStripLocationCancelEventArgs.cs
- XmlEntity.cs
- RegistryExceptionHelper.cs
- SymmetricKeyWrap.cs
- EntityDataSourceState.cs
- SchemaElementDecl.cs
- GlyphRunDrawing.cs
- DataGridViewCellConverter.cs