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
- PerformanceCounterLib.cs
- ObjectConverter.cs
- BookmarkScopeHandle.cs
- DefaultTextStoreTextComposition.cs
- FtpWebResponse.cs
- OdbcConnectionPoolProviderInfo.cs
- Win32Exception.cs
- DBCSCodePageEncoding.cs
- ServiceKnownTypeAttribute.cs
- DeferredReference.cs
- BooleanToSelectiveScrollingOrientationConverter.cs
- PropertyFilterAttribute.cs
- XmlProcessingInstruction.cs
- ToolStripTextBox.cs
- SqlInternalConnectionSmi.cs
- CommandPlan.cs
- ValueQuery.cs
- KeyPullup.cs
- MulticastOption.cs
- DoneReceivingAsyncResult.cs
- TreeNodeEventArgs.cs
- DataGridClipboardHelper.cs
- ObjectDataSourceSelectingEventArgs.cs
- CallbackTimeoutsElement.cs
- TranslateTransform3D.cs
- SHA512Managed.cs
- DynamicDataResources.Designer.cs
- Formatter.cs
- TextModifierScope.cs
- DescendantBaseQuery.cs
- DataError.cs
- SchemaImporterExtensionElement.cs
- SmiConnection.cs
- XPathAncestorQuery.cs
- FileUpload.cs
- CurrencyManager.cs
- VirtualPathData.cs
- FunctionDefinition.cs
- ClientBuildManagerCallback.cs
- DataKeyArray.cs
- ComponentChangingEvent.cs
- WebServiceEndpoint.cs
- DataGridHelper.cs
- RequestReplyCorrelator.cs
- OutputCacheEntry.cs
- XmlSchemaObjectCollection.cs
- FloaterBaseParagraph.cs
- StructuralType.cs
- DirectoryLocalQuery.cs
- CodeVariableDeclarationStatement.cs
- XmlHelper.cs
- RoleService.cs
- CodeBinaryOperatorExpression.cs
- Itemizer.cs
- ResourceAssociationType.cs
- KernelTypeValidation.cs
- ReplacementText.cs
- DataGridRowClipboardEventArgs.cs
- ButtonRenderer.cs
- ExplicitDiscriminatorMap.cs
- NullableDecimalAverageAggregationOperator.cs
- ServerValidateEventArgs.cs
- TreeNodeBindingDepthConverter.cs
- MailBnfHelper.cs
- TypeForwardedToAttribute.cs
- NativeMethodsOther.cs
- FileStream.cs
- Camera.cs
- TextEditorDragDrop.cs
- ToggleButton.cs
- GeometryModel3D.cs
- LinqDataSourceContextData.cs
- FontStretchConverter.cs
- SplitterPanel.cs
- ObjectSecurity.cs
- relpropertyhelper.cs
- HtmlInputCheckBox.cs
- XmlSchemaAny.cs
- ObjectManager.cs
- WindowsGrip.cs
- SqlCachedBuffer.cs
- HostedBindingBehavior.cs
- PlaceHolder.cs
- TemplateField.cs
- ValidationHelper.cs
- PeerApplicationLaunchInfo.cs
- SelectorAutomationPeer.cs
- arc.cs
- ResolveMatchesMessageCD1.cs
- AutomationPatternInfo.cs
- ViewgenContext.cs
- ListView.cs
- BroadcastEventHelper.cs
- Utils.cs
- UserPreferenceChangedEventArgs.cs
- AppDomain.cs
- TreeViewDesigner.cs
- ProfilePropertySettingsCollection.cs
- StringUtil.cs
- securestring.cs