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
- ConfigDefinitionUpdates.cs
- SimpleColumnProvider.cs
- XmlWrappingReader.cs
- FileInfo.cs
- EventLogEntryCollection.cs
- ObjectSecurity.cs
- DocumentXmlWriter.cs
- EntityViewContainer.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- KeyFrames.cs
- ListenerElementsCollection.cs
- EntityDataSourceDesignerHelper.cs
- PageContent.cs
- _ListenerRequestStream.cs
- Helper.cs
- UnionExpr.cs
- CacheChildrenQuery.cs
- GenericsNotImplementedException.cs
- RSAOAEPKeyExchangeFormatter.cs
- AsymmetricSignatureDeformatter.cs
- TextEditorThreadLocalStore.cs
- WebPartTracker.cs
- SettingsProviderCollection.cs
- xmlsaver.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- ObjectQueryExecutionPlan.cs
- HtmlFormParameterWriter.cs
- ConfigurationPermission.cs
- ObjectQueryExecutionPlan.cs
- CultureTableRecord.cs
- handlecollector.cs
- RelatedImageListAttribute.cs
- HtmlTableCell.cs
- CompatibleComparer.cs
- dataobject.cs
- TextParentUndoUnit.cs
- BitmapEffectvisualstate.cs
- DataTableCollection.cs
- ViewGenerator.cs
- WriteTimeStream.cs
- HttpGetProtocolImporter.cs
- WebPartConnectionsConfigureVerb.cs
- BehaviorEditorPart.cs
- SecurityTokenInclusionMode.cs
- FilteredSchemaElementLookUpTable.cs
- ImpersonateTokenRef.cs
- Attributes.cs
- QueryStringParameter.cs
- ActivityXRefConverter.cs
- PortCache.cs
- ExecutionContext.cs
- TableRow.cs
- MatrixTransform3D.cs
- FileDialogPermission.cs
- ReadOnlyPropertyMetadata.cs
- TemplateControlParser.cs
- SingleAnimationUsingKeyFrames.cs
- PropertyBuilder.cs
- AtlasWeb.Designer.cs
- TextDecoration.cs
- ControlPropertyNameConverter.cs
- SingleAnimationBase.cs
- OleDbMetaDataFactory.cs
- SiteMapPath.cs
- ToolStripDropDownItem.cs
- XmlSchemaAppInfo.cs
- XmlSchemaInclude.cs
- DynamicHyperLink.cs
- ScriptingRoleServiceSection.cs
- ViewPort3D.cs
- FactoryId.cs
- prefixendpointaddressmessagefiltertable.cs
- Expander.cs
- Socket.cs
- ObjectItemNoOpAssemblyLoader.cs
- WebControlAdapter.cs
- MappingException.cs
- ActivationServices.cs
- DateTimeSerializationSection.cs
- GlyphInfoList.cs
- DesignerTransactionCloseEvent.cs
- RelationshipDetailsRow.cs
- InfoCardAsymmetricCrypto.cs
- InlinedAggregationOperator.cs
- LiteralTextParser.cs
- ListViewHitTestInfo.cs
- GridViewColumnCollection.cs
- PeerContact.cs
- RedirectionProxy.cs
- NamedPipeAppDomainProtocolHandler.cs
- CdpEqualityComparer.cs
- DataGridCaption.cs
- Win32.cs
- ImageCodecInfoPrivate.cs
- StyleTypedPropertyAttribute.cs
- UpdateProgress.cs
- SamlAttributeStatement.cs
- WebScriptClientGenerator.cs
- Dictionary.cs
- _AutoWebProxyScriptHelper.cs