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
- OptionalColumn.cs
- DropDownList.cs
- WebBrowser.cs
- SubpageParagraph.cs
- BinaryFormatterWriter.cs
- EncoderBestFitFallback.cs
- ComponentDispatcherThread.cs
- XmlSchemaAnnotated.cs
- SQLInt16.cs
- QilDataSource.cs
- BoundField.cs
- UserControlDocumentDesigner.cs
- DiscriminatorMap.cs
- ChangeProcessor.cs
- ToolStripGripRenderEventArgs.cs
- StackBuilderSink.cs
- codemethodreferenceexpression.cs
- MarkupProperty.cs
- RotateTransform.cs
- CachedPathData.cs
- SystemTcpStatistics.cs
- TemplatePagerField.cs
- WpfPayload.cs
- Rect3DValueSerializer.cs
- ObjectItemAttributeAssemblyLoader.cs
- PeerCollaborationPermission.cs
- Vector3D.cs
- _AutoWebProxyScriptEngine.cs
- OdbcErrorCollection.cs
- UnSafeCharBuffer.cs
- Membership.cs
- Column.cs
- NameTable.cs
- WebProxyScriptElement.cs
- ButtonPopupAdapter.cs
- SynchronizedDispatch.cs
- PrePostDescendentsWalker.cs
- PointAnimationUsingPath.cs
- RowTypePropertyElement.cs
- MatrixKeyFrameCollection.cs
- DesignObjectWrapper.cs
- ThreadPool.cs
- DesignerProperties.cs
- ClosableStream.cs
- WebPartConnectVerb.cs
- UInt64Converter.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- ConditionCollection.cs
- MediaEntryAttribute.cs
- OracleRowUpdatedEventArgs.cs
- EntityDataReader.cs
- XPathParser.cs
- FontWeights.cs
- InvalidWMPVersionException.cs
- DispatchOperation.cs
- Console.cs
- RegularExpressionValidator.cs
- SwitchElementsCollection.cs
- FormViewPagerRow.cs
- ScrollProperties.cs
- FlowSwitchLink.cs
- InputLanguageSource.cs
- NegationPusher.cs
- BookmarkWorkItem.cs
- HttpCapabilitiesEvaluator.cs
- SettingsSavedEventArgs.cs
- BooleanKeyFrameCollection.cs
- LabelEditEvent.cs
- DebuggerAttributes.cs
- DataGridRowHeader.cs
- FixedDocumentSequencePaginator.cs
- CustomCredentialPolicy.cs
- VisualStates.cs
- NativeMethodsCLR.cs
- ItemPager.cs
- ImpersonationContext.cs
- ByteRangeDownloader.cs
- IntranetCredentialPolicy.cs
- Scene3D.cs
- ProfileBuildProvider.cs
- TargetException.cs
- DateTimeFormat.cs
- LinearGradientBrush.cs
- RoleGroup.cs
- ApplicationSecurityManager.cs
- DeclaredTypeElement.cs
- TextServicesProperty.cs
- UnaryNode.cs
- sqlmetadatafactory.cs
- SqlDelegatedTransaction.cs
- SoapEnvelopeProcessingElement.cs
- SqlClientPermission.cs
- ImplicitInputBrush.cs
- TextPointerBase.cs
- CopyAttributesAction.cs
- WindowsStatic.cs
- SmiRecordBuffer.cs
- GridViewUpdatedEventArgs.cs
- MembershipPasswordException.cs
- HttpHeaderCollection.cs