Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Base / System / ComponentModel / CurrentChangedEventManager.cs / 1 / CurrentChangedEventManager.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: Manager for the CurrentChanged event in the "weak event listener" // pattern. See WeakEventTable.cs for an overview. // //--------------------------------------------------------------------------- using System; using System.Windows; // WeakEventManager namespace System.ComponentModel { ////// Manager for the ICollectionView.CurrentChanged event. /// public class CurrentChangedEventManager : WeakEventManager { #region Constructors // // Constructors // private CurrentChangedEventManager() { } #endregion Constructors #region Public Methods // // Public Methods // ////// Add a listener to the given source's event. /// public static void AddListener(ICollectionView source, IWeakEventListener listener) { CurrentManager.ProtectedAddListener(source, listener); } ////// Remove a listener to the given source's event. /// public static void RemoveListener(ICollectionView 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) { ICollectionView typedSource = (ICollectionView)source; typedSource.CurrentChanged += new EventHandler(OnCurrentChanged); } ////// Stop listening to the given source for the event. /// protected override void StopListening(object source) { ICollectionView typedSource = (ICollectionView)source; typedSource.CurrentChanged -= new EventHandler(OnCurrentChanged); } #endregion Protected Methods #region Private Properties // // Private Properties // // get the event manager for the current thread private static CurrentChangedEventManager CurrentManager { get { Type managerType = typeof(CurrentChangedEventManager); CurrentChangedEventManager manager = (CurrentChangedEventManager)GetCurrentManager(managerType); // at first use, create and register a new manager if (manager == null) { manager = new CurrentChangedEventManager(); SetCurrentManager(managerType, manager); } return manager; } } #endregion Private Properties #region Private Methods // // Private Methods // // event handler for CurrentChanged event private void OnCurrentChanged(object sender, EventArgs 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 CurrentChanged event in the "weak event listener" // pattern. See WeakEventTable.cs for an overview. // //--------------------------------------------------------------------------- using System; using System.Windows; // WeakEventManager namespace System.ComponentModel { ////// Manager for the ICollectionView.CurrentChanged event. /// public class CurrentChangedEventManager : WeakEventManager { #region Constructors // // Constructors // private CurrentChangedEventManager() { } #endregion Constructors #region Public Methods // // Public Methods // ////// Add a listener to the given source's event. /// public static void AddListener(ICollectionView source, IWeakEventListener listener) { CurrentManager.ProtectedAddListener(source, listener); } ////// Remove a listener to the given source's event. /// public static void RemoveListener(ICollectionView 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) { ICollectionView typedSource = (ICollectionView)source; typedSource.CurrentChanged += new EventHandler(OnCurrentChanged); } ////// Stop listening to the given source for the event. /// protected override void StopListening(object source) { ICollectionView typedSource = (ICollectionView)source; typedSource.CurrentChanged -= new EventHandler(OnCurrentChanged); } #endregion Protected Methods #region Private Properties // // Private Properties // // get the event manager for the current thread private static CurrentChangedEventManager CurrentManager { get { Type managerType = typeof(CurrentChangedEventManager); CurrentChangedEventManager manager = (CurrentChangedEventManager)GetCurrentManager(managerType); // at first use, create and register a new manager if (manager == null) { manager = new CurrentChangedEventManager(); SetCurrentManager(managerType, manager); } return manager; } } #endregion Private Properties #region Private Methods // // Private Methods // // event handler for CurrentChanged event private void OnCurrentChanged(object sender, EventArgs 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
- SystemIPInterfaceProperties.cs
- TreeNodeStyleCollection.cs
- Stopwatch.cs
- WebPartMenuStyle.cs
- DataKeyCollection.cs
- IOException.cs
- Icon.cs
- AuthenticationManager.cs
- DeclarativeConditionsCollection.cs
- SchemaManager.cs
- CompositeDataBoundControl.cs
- HtmlString.cs
- RegisteredDisposeScript.cs
- ValidatedControlConverter.cs
- XmlMembersMapping.cs
- CodeThrowExceptionStatement.cs
- RoutingExtensionElement.cs
- StandardBindingElement.cs
- WebPartZoneBase.cs
- Models.cs
- EndpointInfo.cs
- ToolStripSplitButton.cs
- QilScopedVisitor.cs
- _HeaderInfo.cs
- PathStreamGeometryContext.cs
- _CommandStream.cs
- CompilerState.cs
- ServiceCredentialsSecurityTokenManager.cs
- TextTreeExtractElementUndoUnit.cs
- ImportDesigner.xaml.cs
- MergeExecutor.cs
- IsolatedStorageFileStream.cs
- FrameworkElement.cs
- SystemIPAddressInformation.cs
- ArrayEditor.cs
- Mapping.cs
- XslVisitor.cs
- HttpInputStream.cs
- TextTreeExtractElementUndoUnit.cs
- OutputWindow.cs
- NavigationWindowAutomationPeer.cs
- TextTreeTextNode.cs
- WebScriptServiceHostFactory.cs
- WorkflowRuntimeEndpoint.cs
- Form.cs
- WindowsGraphics2.cs
- StatusBar.cs
- DynamicILGenerator.cs
- DocumentSchemaValidator.cs
- QueryActivatableWorkflowsCommand.cs
- CultureSpecificCharacterBufferRange.cs
- HelloOperationAsyncResult.cs
- Preprocessor.cs
- IResourceProvider.cs
- Atom10FormatterFactory.cs
- BinaryFormatterWriter.cs
- DesignerView.cs
- Sentence.cs
- XmlILTrace.cs
- CodeAssignStatement.cs
- TraceSwitch.cs
- OutputCacheSection.cs
- PackageFilter.cs
- MetabaseSettings.cs
- _AutoWebProxyScriptHelper.cs
- UnaryOperationBinder.cs
- TextServicesContext.cs
- LogicalExpr.cs
- XmlDictionary.cs
- HotSpot.cs
- X509Certificate2Collection.cs
- WCFBuildProvider.cs
- Msec.cs
- metadatamappinghashervisitor.cs
- NetworkInformationException.cs
- DbMetaDataFactory.cs
- InkSerializer.cs
- ConsoleTraceListener.cs
- BigInt.cs
- GenericIdentity.cs
- URL.cs
- ToolboxItemFilterAttribute.cs
- _emptywebproxy.cs
- InputProcessorProfilesLoader.cs
- WindowsListViewSubItem.cs
- SqlDataSourceCache.cs
- SecuritySessionClientSettings.cs
- BlurBitmapEffect.cs
- Grid.cs
- DriveNotFoundException.cs
- List.cs
- querybuilder.cs
- PrivilegeNotHeldException.cs
- EditCommandColumn.cs
- TypefaceCollection.cs
- ADMembershipProvider.cs
- CollectionDataContract.cs
- DescendentsWalkerBase.cs
- SQLDouble.cs
- DirectoryLocalQuery.cs