Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- FontResourceCache.cs
- ClientScriptManagerWrapper.cs
- LocalizationComments.cs
- NullableDecimalAverageAggregationOperator.cs
- RequestCacheEntry.cs
- RTLAwareMessageBox.cs
- ECDsa.cs
- Options.cs
- PersianCalendar.cs
- Rectangle.cs
- CodeTypeConstructor.cs
- ServiceOperationHelpers.cs
- SequenceQuery.cs
- SqlParameter.cs
- ToolStripButton.cs
- SQLSingleStorage.cs
- BehaviorEditorPart.cs
- WaitHandle.cs
- DbConnectionPoolGroup.cs
- WebBaseEventKeyComparer.cs
- SubpageParaClient.cs
- ToolStripItemGlyph.cs
- DirectoryInfo.cs
- EqualityComparer.cs
- HttpCapabilitiesSectionHandler.cs
- XPathNodeList.cs
- SystemUnicastIPAddressInformation.cs
- PhysicalOps.cs
- SafeCoTaskMem.cs
- TemplateBuilder.cs
- DbConnectionStringBuilder.cs
- TokenBasedSetEnumerator.cs
- SchemaNames.cs
- ProtocolsConfiguration.cs
- DBSqlParserColumnCollection.cs
- DataBoundControlHelper.cs
- PointCollectionConverter.cs
- PocoPropertyAccessorStrategy.cs
- RepeaterItem.cs
- EventRouteFactory.cs
- DataControlImageButton.cs
- RelationshipWrapper.cs
- RegistryDataKey.cs
- InfoCardRSAOAEPKeyExchangeDeformatter.cs
- ToolConsole.cs
- ErrorTolerantObjectWriter.cs
- IssuedTokenServiceElement.cs
- hebrewshape.cs
- View.cs
- basevalidator.cs
- NotSupportedException.cs
- Operator.cs
- ZipIOExtraFieldElement.cs
- ApplicationFileCodeDomTreeGenerator.cs
- ToolStripButton.cs
- HitTestWithGeometryDrawingContextWalker.cs
- WindowsGraphics2.cs
- LocalizedNameDescriptionPair.cs
- HtmlTable.cs
- DummyDataSource.cs
- CultureInfoConverter.cs
- PreloadedPackages.cs
- BoundsDrawingContextWalker.cs
- CategoryAttribute.cs
- BamlRecordHelper.cs
- ExportException.cs
- TrackBarRenderer.cs
- KeyGestureValueSerializer.cs
- View.cs
- FieldBuilder.cs
- SpecialNameAttribute.cs
- SettingsAttributes.cs
- ObjectDataSourceDisposingEventArgs.cs
- DebugView.cs
- IndexedString.cs
- HttpFileCollection.cs
- AsyncStreamReader.cs
- DefaultWorkflowTransactionService.cs
- CheckBoxRenderer.cs
- DataViewSetting.cs
- ImageCollectionCodeDomSerializer.cs
- ReferenceEqualityComparer.cs
- WhiteSpaceTrimStringConverter.cs
- CollaborationHelperFunctions.cs
- MimeTypeMapper.cs
- ControlPropertyNameConverter.cs
- ServiceParser.cs
- CalendarDay.cs
- FramingEncoders.cs
- CredentialCache.cs
- WebBrowsableAttribute.cs
- CreateSequenceResponse.cs
- WindowsToolbarItemAsMenuItem.cs
- DocumentViewerConstants.cs
- CodeCastExpression.cs
- WebConfigurationHost.cs
- WebPartCancelEventArgs.cs
- XmlSchemaSimpleTypeUnion.cs
- BCryptSafeHandles.cs
- X509SecurityTokenAuthenticator.cs