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
- PrintingPermissionAttribute.cs
- UnionQueryOperator.cs
- TypeUnloadedException.cs
- BackStopAuthenticationModule.cs
- AccessedThroughPropertyAttribute.cs
- FixedPageStructure.cs
- TableLayoutCellPaintEventArgs.cs
- HttpListenerElement.cs
- GacUtil.cs
- ExtendedPropertiesHandler.cs
- HeaderedContentControl.cs
- TimeoutValidationAttribute.cs
- ProfileGroupSettingsCollection.cs
- FacetValueContainer.cs
- ObjectDataProvider.cs
- ResourceKey.cs
- ListDictionaryInternal.cs
- ManagedIStream.cs
- TemplateField.cs
- CustomCategoryAttribute.cs
- DeferrableContent.cs
- SQLBytes.cs
- HtmlWindow.cs
- ExceptionValidationRule.cs
- TranslateTransform.cs
- JavaScriptObjectDeserializer.cs
- XmlDomTextWriter.cs
- BuildProvider.cs
- GridView.cs
- SessionSwitchEventArgs.cs
- listviewsubitemcollectioneditor.cs
- ExpressionBuilder.cs
- InternalSafeNativeMethods.cs
- Size.cs
- WebBrowserProgressChangedEventHandler.cs
- AxParameterData.cs
- DPCustomTypeDescriptor.cs
- DataStreamFromComStream.cs
- ProviderBase.cs
- PathFigureCollectionConverter.cs
- GcSettings.cs
- AppearanceEditorPart.cs
- UpdateException.cs
- RequestQueue.cs
- PersistChildrenAttribute.cs
- PersistencePipeline.cs
- CollectionViewGroupRoot.cs
- SchemaElementDecl.cs
- DataBindingList.cs
- ScrollItemPatternIdentifiers.cs
- XPathDocument.cs
- EmitterCache.cs
- DBBindings.cs
- LayoutSettings.cs
- OracleDataReader.cs
- ManagementClass.cs
- ImageDrawing.cs
- DataColumnMapping.cs
- ResourceExpression.cs
- SizeAnimationUsingKeyFrames.cs
- CopyCodeAction.cs
- NamespaceDecl.cs
- Binding.cs
- CustomUserNameSecurityTokenAuthenticator.cs
- Util.cs
- WpfGeneratedKnownTypes.cs
- safePerfProviderHandle.cs
- _PooledStream.cs
- WebServiceBindingAttribute.cs
- LicFileLicenseProvider.cs
- ExpressionValueEditor.cs
- EventDescriptorCollection.cs
- TextHidden.cs
- securestring.cs
- CommandConverter.cs
- ManualResetEvent.cs
- SoapTypeAttribute.cs
- CompoundFileStreamReference.cs
- RequestNavigateEventArgs.cs
- ElementHostPropertyMap.cs
- ControlParameter.cs
- counter.cs
- WindowsToolbar.cs
- WindowsNonControl.cs
- BoolExpr.cs
- LicenseManager.cs
- XmlSchemaComplexContent.cs
- Quaternion.cs
- FileInfo.cs
- Transform3DGroup.cs
- Cursors.cs
- ValidatorUtils.cs
- ExtensionCollection.cs
- EllipseGeometry.cs
- MenuItemBinding.cs
- CommaDelimitedStringAttributeCollectionConverter.cs
- DefaultHttpHandler.cs
- NativeCppClassAttribute.cs
- TemplateColumn.cs
- FormsAuthentication.cs