Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- UnmanagedMarshal.cs
- XmlValidatingReaderImpl.cs
- TextEndOfSegment.cs
- BaseDataListComponentEditor.cs
- XsdDuration.cs
- HttpProxyTransportBindingElement.cs
- EncoderBestFitFallback.cs
- AutomationElementIdentifiers.cs
- PageHandlerFactory.cs
- ServiceDesigner.xaml.cs
- LineMetrics.cs
- MemoryMappedViewAccessor.cs
- DiscoveryDocument.cs
- CmsInterop.cs
- COSERVERINFO.cs
- AnnotationAdorner.cs
- ExecutionTracker.cs
- RtfToXamlLexer.cs
- ListViewDeleteEventArgs.cs
- FileSecurity.cs
- NestPullup.cs
- Rect3D.cs
- CodeGenerator.cs
- DrawingContext.cs
- CodeNamespace.cs
- WSSecureConversationDec2005.cs
- XmlBoundElement.cs
- SimpleParser.cs
- EdmToObjectNamespaceMap.cs
- XhtmlBasicValidationSummaryAdapter.cs
- InteropBitmapSource.cs
- Attributes.cs
- SoapIgnoreAttribute.cs
- WindowProviderWrapper.cs
- InstallerTypeAttribute.cs
- QuadraticBezierSegment.cs
- ProfilePropertyNameValidator.cs
- DynamicValueConverter.cs
- XmlCharCheckingReader.cs
- DomainConstraint.cs
- MatrixIndependentAnimationStorage.cs
- UrlRoutingModule.cs
- ModelItemDictionaryImpl.cs
- TdsParserStaticMethods.cs
- XmlCompatibilityReader.cs
- SortDescription.cs
- QilPatternFactory.cs
- SymLanguageVendor.cs
- ToolStripTextBox.cs
- NamedElement.cs
- DataObjectFieldAttribute.cs
- XmlEncodedRawTextWriter.cs
- PropertyInformation.cs
- Soap12ProtocolReflector.cs
- TypeResolvingOptions.cs
- CodeTypeMemberCollection.cs
- ListDictionary.cs
- InfoCardAsymmetricCrypto.cs
- IPAddress.cs
- PageThemeBuildProvider.cs
- ConstrainedGroup.cs
- DataRelationPropertyDescriptor.cs
- PointConverter.cs
- ObservableCollectionDefaultValueFactory.cs
- TimeSpanOrInfiniteConverter.cs
- FontUnit.cs
- BooleanKeyFrameCollection.cs
- DefaultValidator.cs
- SqlFlattener.cs
- CharAnimationBase.cs
- StyleHelper.cs
- DriveNotFoundException.cs
- DiscoveryDocumentSerializer.cs
- ExtractCollection.cs
- DelegatingTypeDescriptionProvider.cs
- MatrixCamera.cs
- AbstractSvcMapFileLoader.cs
- SerialPinChanges.cs
- ConfigurationLoaderException.cs
- GradientBrush.cs
- InterleavedZipPartStream.cs
- ColorMatrix.cs
- SchemaImporterExtensionElementCollection.cs
- shaperfactoryquerycachekey.cs
- WriteLineDesigner.xaml.cs
- StaticFileHandler.cs
- XmlSchemaInferenceException.cs
- Menu.cs
- ToolStripArrowRenderEventArgs.cs
- ColorMatrix.cs
- StoragePropertyMapping.cs
- HatchBrush.cs
- XmlCompatibilityReader.cs
- XmlSchemaRedefine.cs
- DiagnosticStrings.cs
- TypeSource.cs
- WindowInteractionStateTracker.cs
- FlagsAttribute.cs
- ProfileSettingsCollection.cs
- StringSource.cs