Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- OutputCacheProviderCollection.cs
- SqlWebEventProvider.cs
- WinEventWrap.cs
- UrlMappingCollection.cs
- DataSourceConverter.cs
- MouseEvent.cs
- GorillaCodec.cs
- RegexCharClass.cs
- EntityUtil.cs
- ByteAnimation.cs
- UmAlQuraCalendar.cs
- RectKeyFrameCollection.cs
- ProfileManager.cs
- GroupItemAutomationPeer.cs
- designeractionbehavior.cs
- TypeUnloadedException.cs
- ReadOnlyHierarchicalDataSourceView.cs
- SafePEFileHandle.cs
- InputQueue.cs
- FlowDocumentFormatter.cs
- NativeMethods.cs
- TransactionTable.cs
- EntityContainerEmitter.cs
- ScrollBarAutomationPeer.cs
- DataBoundControlHelper.cs
- xmlfixedPageInfo.cs
- CommonObjectSecurity.cs
- TabItemAutomationPeer.cs
- GenericXmlSecurityToken.cs
- BitmapEffectInputData.cs
- ChtmlPageAdapter.cs
- EnumerableCollectionView.cs
- DetailsViewDeleteEventArgs.cs
- ScriptingSectionGroup.cs
- Dictionary.cs
- ShapeTypeface.cs
- ParameterElement.cs
- StorageSetMapping.cs
- SqlConnectionFactory.cs
- TabControlAutomationPeer.cs
- DbConnectionStringBuilder.cs
- ModelPropertyImpl.cs
- SerializationSectionGroup.cs
- WebReferenceOptions.cs
- SerializationEventsCache.cs
- DockProviderWrapper.cs
- InProcStateClientManager.cs
- ResXResourceReader.cs
- documentation.cs
- AttributeUsageAttribute.cs
- PopupRootAutomationPeer.cs
- COM2FontConverter.cs
- ThemeDirectoryCompiler.cs
- OverflowException.cs
- Activation.cs
- WorkflowDurableInstance.cs
- GlyphRunDrawing.cs
- CompositionDesigner.cs
- InternalControlCollection.cs
- MdImport.cs
- FilterQueryOptionExpression.cs
- LazyTextWriterCreator.cs
- XpsResource.cs
- LinkLabel.cs
- ThreadStaticAttribute.cs
- HttpModulesSection.cs
- FormViewUpdateEventArgs.cs
- ImageListImage.cs
- FormsAuthenticationUser.cs
- XmlException.cs
- OAVariantLib.cs
- ProxyManager.cs
- RequiredFieldValidator.cs
- XPathMultyIterator.cs
- ReadOnlyObservableCollection.cs
- GeneralTransform2DTo3DTo2D.cs
- AstTree.cs
- QilBinary.cs
- ScaleTransform.cs
- Assembly.cs
- MetadataCollection.cs
- Attributes.cs
- COSERVERINFO.cs
- HttpHandlerActionCollection.cs
- DateTimePickerDesigner.cs
- ElementAction.cs
- ToolStripItemEventArgs.cs
- ComplexPropertyEntry.cs
- FieldCollectionEditor.cs
- NamespaceEmitter.cs
- MimeImporter.cs
- Base64Decoder.cs
- MetabaseSettingsIis7.cs
- X509CertificateRecipientServiceCredential.cs
- XmlParserContext.cs
- SerializerDescriptor.cs
- Point3D.cs
- MulticastOption.cs
- SharedConnectionWorkflowTransactionService.cs
- MultipartContentParser.cs