Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Base / System / Collections / Specialized / CollectionChangedEventManager.cs / 1 / CollectionChangedEventManager.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: Manager for the CollectionChanged event in the "weak event listener" // pattern. See WeakEventTable.cs for an overview. // //--------------------------------------------------------------------------- using System; using System.Windows; // WeakEventManager namespace System.Collections.Specialized { ////// Manager for the INotifyCollectionChanged.CollectionChanged event. /// public class CollectionChangedEventManager : WeakEventManager { #region Constructors // // Constructors // private CollectionChangedEventManager() { } #endregion Constructors #region Public Methods // // Public Methods // ////// Add a listener to the given source's event. /// public static void AddListener(INotifyCollectionChanged source, IWeakEventListener listener) { CurrentManager.ProtectedAddListener(source, listener); } ////// Remove a listener to the given source's event. /// public static void RemoveListener(INotifyCollectionChanged 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) { INotifyCollectionChanged typedSource = (INotifyCollectionChanged)source; typedSource.CollectionChanged += new NotifyCollectionChangedEventHandler(OnCollectionChanged); } ////// Stop listening to the given source for the event. /// protected override void StopListening(object source) { INotifyCollectionChanged typedSource = (INotifyCollectionChanged)source; typedSource.CollectionChanged -= new NotifyCollectionChangedEventHandler(OnCollectionChanged); } #endregion Protected Methods #region Private Properties // // Private Properties // // get the event manager for the current thread private static CollectionChangedEventManager CurrentManager { get { Type managerType = typeof(CollectionChangedEventManager); CollectionChangedEventManager manager = (CollectionChangedEventManager)GetCurrentManager(managerType); // at first use, create and register a new manager if (manager == null) { manager = new CollectionChangedEventManager(); SetCurrentManager(managerType, manager); } return manager; } } #endregion Private Properties #region Private Methods // // Private Methods // // event handler for CollectionChanged event private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs 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
- NativeRecognizer.cs
- RegexCharClass.cs
- fixedPageContentExtractor.cs
- BaseValidator.cs
- Separator.cs
- FrameworkContextData.cs
- DirectionalLight.cs
- SchemaNamespaceManager.cs
- KeyEvent.cs
- CommunicationObjectManager.cs
- GridView.cs
- ScriptHandlerFactory.cs
- ScriptManager.cs
- ToolStripComboBox.cs
- CodeGotoStatement.cs
- MatrixConverter.cs
- DataBoundLiteralControl.cs
- ColorMap.cs
- TrackingStringDictionary.cs
- DependencyObjectProvider.cs
- Array.cs
- invalidudtexception.cs
- CfgSemanticTag.cs
- SessionIDManager.cs
- SkewTransform.cs
- TreeViewHitTestInfo.cs
- GenericEnumerator.cs
- ConnectionPointCookie.cs
- VirtualizingStackPanel.cs
- VerbConverter.cs
- MailAddressCollection.cs
- TraceHandler.cs
- SEHException.cs
- InstanceDescriptor.cs
- wgx_exports.cs
- TransformationRules.cs
- AssemblyResourceLoader.cs
- BinaryCommonClasses.cs
- oledbconnectionstring.cs
- WebPart.cs
- HttpListener.cs
- SplineKeyFrames.cs
- DataGridViewDataConnection.cs
- EngineSiteSapi.cs
- _LocalDataStore.cs
- LayoutDump.cs
- GlyphRun.cs
- BooleanExpr.cs
- NativeCompoundFileAPIs.cs
- NoClickablePointException.cs
- DescendantQuery.cs
- ResolvedKeyFrameEntry.cs
- SchemaHelper.cs
- FtpWebRequest.cs
- InputLanguageEventArgs.cs
- EntityObject.cs
- UriExt.cs
- TCEAdapterGenerator.cs
- HttpSessionStateWrapper.cs
- HttpListenerResponse.cs
- ServerValidateEventArgs.cs
- FormattedText.cs
- DesignUtil.cs
- SafeNativeMethods.cs
- DNS.cs
- RPIdentityRequirement.cs
- VirtualPathProvider.cs
- TextureBrush.cs
- WindowShowOrOpenTracker.cs
- ArgumentNullException.cs
- TiffBitmapDecoder.cs
- AutomationIdentifierGuids.cs
- RoutedEventArgs.cs
- FreezableCollection.cs
- BitStack.cs
- DESCryptoServiceProvider.cs
- HttpAsyncResult.cs
- ReadWriteObjectLock.cs
- EventLogPermissionEntryCollection.cs
- DtdParser.cs
- ProtectedConfiguration.cs
- ConfigurationSettings.cs
- ProxyWebPartConnectionCollection.cs
- LambdaCompiler.cs
- GeometryModel3D.cs
- WaitHandleCannotBeOpenedException.cs
- SqlDeflator.cs
- ApplicationGesture.cs
- PropertyManager.cs
- EventHandlers.cs
- AdornedElementPlaceholder.cs
- LineServicesRun.cs
- UpdateRecord.cs
- SystemUnicastIPAddressInformation.cs
- SrgsRulesCollection.cs
- PathFigure.cs
- SEHException.cs
- _CookieModule.cs
- GridItemProviderWrapper.cs
- ParameterToken.cs