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
- InstanceNormalEvent.cs
- WizardPanel.cs
- TextServicesProperty.cs
- TreeBuilderBamlTranslator.cs
- Thickness.cs
- NullReferenceException.cs
- Int64.cs
- CombinedGeometry.cs
- GridViewEditEventArgs.cs
- PageCodeDomTreeGenerator.cs
- DataTable.cs
- ResourceContainer.cs
- SmiEventSink.cs
- ServerValidateEventArgs.cs
- ParserHooks.cs
- _SingleItemRequestCache.cs
- SpecularMaterial.cs
- FileUtil.cs
- SubMenuStyleCollection.cs
- DbUpdateCommandTree.cs
- SchemaAttDef.cs
- EmbossBitmapEffect.cs
- TagMapCollection.cs
- ExecutionEngineException.cs
- UnsafeNativeMethods.cs
- LayoutDump.cs
- SqlBooleanizer.cs
- EntityDataSourceContextDisposingEventArgs.cs
- InternalTypeHelper.cs
- DbException.cs
- GlobalEventManager.cs
- SoapSchemaExporter.cs
- X509ChainElement.cs
- StringPropertyBuilder.cs
- HMACRIPEMD160.cs
- ContentTypeSettingClientMessageFormatter.cs
- WebRequestModuleElementCollection.cs
- Imaging.cs
- RC2CryptoServiceProvider.cs
- LifetimeMonitor.cs
- CryptoSession.cs
- UnmanagedMemoryStreamWrapper.cs
- Point3DConverter.cs
- TypeUtils.cs
- WebPartConnectVerb.cs
- TextAnchor.cs
- RectangleGeometry.cs
- AffineTransform3D.cs
- HttpFormatExtensions.cs
- ClientSponsor.cs
- DateRangeEvent.cs
- SettingsPropertyValue.cs
- PtsPage.cs
- ParameterCollectionEditorForm.cs
- DispatcherOperation.cs
- Attributes.cs
- XPathPatternParser.cs
- EmptyStringExpandableObjectConverter.cs
- RedirectionProxy.cs
- XmlAttributes.cs
- InstanceLockException.cs
- IntSecurity.cs
- PropertyDescriptorComparer.cs
- NativeMethods.cs
- contentDescriptor.cs
- RadialGradientBrush.cs
- CrossContextChannel.cs
- TypedReference.cs
- PixelFormat.cs
- ExitEventArgs.cs
- GridViewColumnHeaderAutomationPeer.cs
- Win32Exception.cs
- ScriptModule.cs
- SiteMapProvider.cs
- EditorPartCollection.cs
- CryptoHandle.cs
- SecurityRuntime.cs
- SqlAggregateChecker.cs
- NumericUpDown.cs
- DataGridHeaderBorder.cs
- OutputCacheSettingsSection.cs
- Parser.cs
- FormsAuthenticationCredentials.cs
- baseaxisquery.cs
- ISAPIApplicationHost.cs
- ConversionHelper.cs
- IndexingContentUnit.cs
- XmlSchemaIdentityConstraint.cs
- GridSplitter.cs
- RuleSettings.cs
- HttpRequest.cs
- SeekStoryboard.cs
- HyperLink.cs
- CodeNamespaceImport.cs
- CategoryGridEntry.cs
- WorkflowTransactionService.cs
- HandleExceptionArgs.cs
- OpCopier.cs
- _BasicClient.cs
- ChildDocumentBlock.cs