Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / 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. //---------------------------------------------------------------------------- // //// 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
- LoadedOrUnloadedOperation.cs
- WindowsListViewGroup.cs
- ProfileParameter.cs
- XmlNamedNodeMap.cs
- List.cs
- FontWeights.cs
- XmlSchemaAppInfo.cs
- ChangeTracker.cs
- ListViewInsertEventArgs.cs
- ItemsControl.cs
- HtmlElementEventArgs.cs
- Input.cs
- ForceCopyBuildProvider.cs
- Utils.cs
- EntityDataSourceReferenceGroup.cs
- Group.cs
- ContextProperty.cs
- Int64Animation.cs
- FontFamilyIdentifier.cs
- CompilerResults.cs
- DataServices.cs
- AstTree.cs
- NaturalLanguageHyphenator.cs
- ResourceExpressionBuilder.cs
- LoginDesignerUtil.cs
- Pen.cs
- Utility.cs
- SchemaAttDef.cs
- ConstantProjectedSlot.cs
- DetailsViewInsertedEventArgs.cs
- XmlSchemaCollection.cs
- UnsafeNativeMethodsMilCoreApi.cs
- XmlSortKeyAccumulator.cs
- ListBoxItem.cs
- WorkflowOperationFault.cs
- _TLSstream.cs
- PathGeometry.cs
- SmiSettersStream.cs
- SamlEvidence.cs
- ReadOnlyHierarchicalDataSourceView.cs
- UnSafeCharBuffer.cs
- ImageField.cs
- RefType.cs
- MobileControlsSection.cs
- TextContainerChangeEventArgs.cs
- DrawListViewSubItemEventArgs.cs
- DuplexChannel.cs
- SchemaNotation.cs
- XmlSchemaType.cs
- SQLString.cs
- RegexCompiler.cs
- ImageSource.cs
- ISO2022Encoding.cs
- UriExt.cs
- MachineKey.cs
- _Connection.cs
- TextRange.cs
- ServiceBuildProvider.cs
- FontWeightConverter.cs
- StylusButton.cs
- WebHostUnsafeNativeMethods.cs
- UserUseLicenseDictionaryLoader.cs
- _StreamFramer.cs
- NativeRecognizer.cs
- PlainXmlSerializer.cs
- SmiContextFactory.cs
- AttributeConverter.cs
- DispatcherProcessingDisabled.cs
- SecurityUtils.cs
- ResXFileRef.cs
- XmlnsCache.cs
- TextProviderWrapper.cs
- StringSorter.cs
- MarshalDirectiveException.cs
- HttpModuleCollection.cs
- EntityClassGenerator.cs
- DelayedRegex.cs
- DbProviderFactories.cs
- GPRECT.cs
- ContainerUIElement3D.cs
- SafeRegistryHandle.cs
- PathParser.cs
- ZoneButton.cs
- KnownIds.cs
- keycontainerpermission.cs
- RefreshEventArgs.cs
- BitmapVisualManager.cs
- DateTimeHelper.cs
- DecoderExceptionFallback.cs
- RealizationDrawingContextWalker.cs
- StringUtil.cs
- StylusShape.cs
- SystemSounds.cs
- FileSecurity.cs
- BaseProcessor.cs
- Style.cs
- SecurityAccessDeniedException.cs
- SimpleBitVector32.cs
- IPCCacheManager.cs
- XXXInfos.cs