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
- SystemIPGlobalProperties.cs
- UdpTransportSettingsElement.cs
- PartialTrustValidationBehavior.cs
- PathGeometry.cs
- ProviderConnectionPointCollection.cs
- TypeProvider.cs
- AxHostDesigner.cs
- ColorTransformHelper.cs
- NodeLabelEditEvent.cs
- StreamGeometry.cs
- AvTraceDetails.cs
- GuidTagList.cs
- SafeLibraryHandle.cs
- XmlSchemaAnnotation.cs
- TextShapeableCharacters.cs
- ButtonBase.cs
- TypeEnumerableViewSchema.cs
- __Error.cs
- ArgumentOutOfRangeException.cs
- CompModSwitches.cs
- DbParameterCollectionHelper.cs
- wgx_sdk_version.cs
- ActivityDesignerHighlighter.cs
- AdRotator.cs
- ScriptResourceInfo.cs
- sqlcontext.cs
- SecurityRuntime.cs
- DataTableNewRowEvent.cs
- WebEventCodes.cs
- FormatException.cs
- BitConverter.cs
- ReflectionTypeLoadException.cs
- StateMachineWorkflowDesigner.cs
- DataGridViewElement.cs
- SystemPens.cs
- ClientSession.cs
- SqlVisitor.cs
- ContextStack.cs
- AsynchronousChannel.cs
- HandleCollector.cs
- DrawingImage.cs
- RestClientProxyHandler.cs
- FixedFlowMap.cs
- WSSecureConversationDec2005.cs
- ErrorTableItemStyle.cs
- LineServicesCallbacks.cs
- AudioException.cs
- ConfigurationStrings.cs
- FlagsAttribute.cs
- ArglessEventHandlerProxy.cs
- Expr.cs
- LostFocusEventManager.cs
- ManagedWndProcTracker.cs
- PageParser.cs
- SqlDataSourceConfigureFilterForm.cs
- FormView.cs
- UIAgentMonitorHandle.cs
- NotFiniteNumberException.cs
- WebServiceErrorEvent.cs
- EventLogTraceListener.cs
- NativeRecognizer.cs
- CaseInsensitiveOrdinalStringComparer.cs
- ZeroOpNode.cs
- ArgumentOutOfRangeException.cs
- PublisherMembershipCondition.cs
- StringConverter.cs
- DictionarySectionHandler.cs
- HandleExceptionArgs.cs
- DataGridDetailsPresenterAutomationPeer.cs
- EnumType.cs
- GeneralTransformGroup.cs
- DelegateArgumentReference.cs
- LayoutEditorPart.cs
- elementinformation.cs
- CustomAttributeSerializer.cs
- WebPartEditVerb.cs
- Journaling.cs
- VisualBrush.cs
- Size3D.cs
- MenuAdapter.cs
- SplineQuaternionKeyFrame.cs
- CachedBitmap.cs
- StateRuntime.cs
- DecoderReplacementFallback.cs
- WebPartDeleteVerb.cs
- DynamicPropertyHolder.cs
- AccessDataSourceView.cs
- AccessibleObject.cs
- OneWayBindingElementImporter.cs
- Update.cs
- ExpandSegment.cs
- TextRenderingModeValidation.cs
- ConsoleKeyInfo.cs
- FlowDocumentScrollViewer.cs
- MailHeaderInfo.cs
- Tuple.cs
- EmptyElement.cs
- XPathDocumentNavigator.cs
- SafeReversePInvokeHandle.cs
- WorkflowOperationErrorHandler.cs