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
- SharedTcpTransportManager.cs
- SqlRecordBuffer.cs
- DependencyPropertyAttribute.cs
- DocumentGridPage.cs
- WindowsFormsHostPropertyMap.cs
- TextDocumentView.cs
- ObjectHelper.cs
- ReceiveDesigner.xaml.cs
- XPathSelfQuery.cs
- DateTimeConverter.cs
- UmAlQuraCalendar.cs
- EvidenceTypeDescriptor.cs
- InstancePersistence.cs
- WorkflowTimerService.cs
- Tile.cs
- CatalogPartChrome.cs
- StateBag.cs
- CompositeControl.cs
- ISAPIRuntime.cs
- XmlDocumentSerializer.cs
- CodeIterationStatement.cs
- CatalogPart.cs
- DataViewSettingCollection.cs
- WinHttpWebProxyFinder.cs
- ToolStripItemImageRenderEventArgs.cs
- LinqDataSourceDeleteEventArgs.cs
- path.cs
- InfoCardRSAPKCS1SignatureDeformatter.cs
- ChildrenQuery.cs
- TextParagraphProperties.cs
- MulticastIPAddressInformationCollection.cs
- ShapingWorkspace.cs
- ColorConverter.cs
- ConnectionManagementSection.cs
- TriggerActionCollection.cs
- ToolboxComponentsCreatingEventArgs.cs
- CodeDelegateInvokeExpression.cs
- SamlSecurityToken.cs
- MergeFilterQuery.cs
- CommentAction.cs
- ShaderEffect.cs
- DataGridViewComboBoxColumn.cs
- ContainerControl.cs
- EdmMember.cs
- SiteMap.cs
- ReadOnlyCollectionBuilder.cs
- WebPartDescription.cs
- TableProviderWrapper.cs
- DataTemplateSelector.cs
- Native.cs
- NameValueConfigurationElement.cs
- NeutralResourcesLanguageAttribute.cs
- PngBitmapEncoder.cs
- SortedList.cs
- SqlBooleanMismatchVisitor.cs
- HttpContextBase.cs
- GenericEnumerator.cs
- DataPointer.cs
- ModuleConfigurationInfo.cs
- QuaternionAnimation.cs
- InvokeSchedule.cs
- SqlProvider.cs
- GifBitmapEncoder.cs
- PropertyPathConverter.cs
- FontCacheUtil.cs
- Graphics.cs
- DataListItemCollection.cs
- FormViewDeletedEventArgs.cs
- DataGridViewTopLeftHeaderCell.cs
- UntypedNullExpression.cs
- TypeBrowserDialog.cs
- SystemGatewayIPAddressInformation.cs
- NodeFunctions.cs
- GeometryModel3D.cs
- SchemaCollectionPreprocessor.cs
- DataGridViewComboBoxCell.cs
- TypeUsage.cs
- ProtocolsConfigurationHandler.cs
- TableAdapterManagerMethodGenerator.cs
- ListMarkerLine.cs
- RtfNavigator.cs
- ListViewInsertionMark.cs
- ThreadStaticAttribute.cs
- GradientStop.cs
- Menu.cs
- TemplateControlCodeDomTreeGenerator.cs
- PersianCalendar.cs
- IxmlLineInfo.cs
- GetImportedCardRequest.cs
- HyperLinkDesigner.cs
- isolationinterop.cs
- BindingBase.cs
- CroppedBitmap.cs
- WebPartConnectionsCancelEventArgs.cs
- MemoryStream.cs
- AnchoredBlock.cs
- DataObjectFieldAttribute.cs
- InkCanvasSelection.cs
- BitmapEffect.cs
- ListViewItemEventArgs.cs