Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Base / System / Collections / ObjectModel / ReadOnlyObservableCollection.cs / 2 / ReadOnlyObservableCollection.cs
//---------------------------------------------------------------------------- // //// Copyright (C) 2003 by Microsoft Corporation. All rights reserved. // // // // Description: Read-only wrapper around an ObservableCollection. // // See spec at http://avalon/connecteddata/Specs/Collection%20Interfaces.mht // //--------------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; namespace System.Collections.ObjectModel { ////// Read-only wrapper around an ObservableCollection. /// [Serializable()] public class ReadOnlyObservableCollection: ReadOnlyCollection , INotifyCollectionChanged, INotifyPropertyChanged { #region Constructors //----------------------------------------------------- // // Constructors // //----------------------------------------------------- /// /// Initializes a new instance of ReadOnlyObservableCollection that /// wraps the given ObservableCollection. /// public ReadOnlyObservableCollection(ObservableCollectionlist) : base(list) { ((INotifyCollectionChanged)Items).CollectionChanged += new NotifyCollectionChangedEventHandler(HandleCollectionChanged); ((INotifyPropertyChanged)Items).PropertyChanged += new PropertyChangedEventHandler(HandlePropertyChanged); } #endregion Constructors #region Interfaces //------------------------------------------------------ // // Interfaces // //----------------------------------------------------- #region INotifyCollectionChanged /// /// CollectionChanged event (per event NotifyCollectionChangedEventHandler INotifyCollectionChanged.CollectionChanged { add { CollectionChanged += value; } remove { CollectionChanged -= value; } } ///). /// /// Occurs when the collection changes, either by adding or removing an item. /// ////// see [field:NonSerializedAttribute()] protected virtual event NotifyCollectionChangedEventHandler CollectionChanged; ////// /// raise CollectionChanged event to any listeners /// protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs args) { if (CollectionChanged != null) { CollectionChanged(this, args); } } #endregion INotifyCollectionChanged #region INotifyPropertyChanged ////// PropertyChanged event (per event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged { add { PropertyChanged += value; } remove { PropertyChanged -= value; } } ///). /// /// Occurs when a property changes. /// ////// see [field:NonSerializedAttribute()] protected virtual event PropertyChangedEventHandler PropertyChanged; ////// /// raise PropertyChanged event to any listeners /// protected virtual void OnPropertyChanged(PropertyChangedEventArgs args) { if (PropertyChanged != null) { PropertyChanged(this, args); } } #endregion INotifyPropertyChanged #endregion Interfaces #region Private Methods //------------------------------------------------------ // // Private Methods // //------------------------------------------------------ // forward CollectionChanged events from the base list to our listeners void HandleCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { OnCollectionChanged(e); } // forward PropertyChanged events from the base list to our listeners void HandlePropertyChanged(object sender, PropertyChangedEventArgs e) { OnPropertyChanged(e); } #endregion Private Methods #region Private Fields //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ #endregion Private Fields } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // //// Copyright (C) 2003 by Microsoft Corporation. All rights reserved. // // // // Description: Read-only wrapper around an ObservableCollection. // // See spec at http://avalon/connecteddata/Specs/Collection%20Interfaces.mht // //--------------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; namespace System.Collections.ObjectModel { ////// Read-only wrapper around an ObservableCollection. /// [Serializable()] public class ReadOnlyObservableCollection: ReadOnlyCollection , INotifyCollectionChanged, INotifyPropertyChanged { #region Constructors //----------------------------------------------------- // // Constructors // //----------------------------------------------------- /// /// Initializes a new instance of ReadOnlyObservableCollection that /// wraps the given ObservableCollection. /// public ReadOnlyObservableCollection(ObservableCollectionlist) : base(list) { ((INotifyCollectionChanged)Items).CollectionChanged += new NotifyCollectionChangedEventHandler(HandleCollectionChanged); ((INotifyPropertyChanged)Items).PropertyChanged += new PropertyChangedEventHandler(HandlePropertyChanged); } #endregion Constructors #region Interfaces //------------------------------------------------------ // // Interfaces // //----------------------------------------------------- #region INotifyCollectionChanged /// /// CollectionChanged event (per event NotifyCollectionChangedEventHandler INotifyCollectionChanged.CollectionChanged { add { CollectionChanged += value; } remove { CollectionChanged -= value; } } ///). /// /// Occurs when the collection changes, either by adding or removing an item. /// ////// see [field:NonSerializedAttribute()] protected virtual event NotifyCollectionChangedEventHandler CollectionChanged; ////// /// raise CollectionChanged event to any listeners /// protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs args) { if (CollectionChanged != null) { CollectionChanged(this, args); } } #endregion INotifyCollectionChanged #region INotifyPropertyChanged ////// PropertyChanged event (per event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged { add { PropertyChanged += value; } remove { PropertyChanged -= value; } } ///). /// /// Occurs when a property changes. /// ////// see [field:NonSerializedAttribute()] protected virtual event PropertyChangedEventHandler PropertyChanged; ////// /// raise PropertyChanged event to any listeners /// protected virtual void OnPropertyChanged(PropertyChangedEventArgs args) { if (PropertyChanged != null) { PropertyChanged(this, args); } } #endregion INotifyPropertyChanged #endregion Interfaces #region Private Methods //------------------------------------------------------ // // Private Methods // //------------------------------------------------------ // forward CollectionChanged events from the base list to our listeners void HandleCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { OnCollectionChanged(e); } // forward PropertyChanged events from the base list to our listeners void HandlePropertyChanged(object sender, PropertyChangedEventArgs e) { OnPropertyChanged(e); } #endregion Private Methods #region Private Fields //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ #endregion Private Fields } } // 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
- DayRenderEvent.cs
- VisualBasic.cs
- TreeNodeCollection.cs
- PersonalizationStateInfoCollection.cs
- EventListenerClientSide.cs
- DispatchWrapper.cs
- IntegrationExceptionEventArgs.cs
- MsmqIntegrationInputChannel.cs
- WorkflowQueuingService.cs
- WebPartDisplayModeCollection.cs
- __Filters.cs
- ClientFormsIdentity.cs
- initElementDictionary.cs
- DataGridViewCellStyleChangedEventArgs.cs
- DeploymentSectionCache.cs
- SqlDataSourceView.cs
- TabletDevice.cs
- _AutoWebProxyScriptWrapper.cs
- SortQuery.cs
- MultiTrigger.cs
- EntityType.cs
- _RequestCacheProtocol.cs
- NativeMethods.cs
- ToolBarButtonClickEvent.cs
- AccessorTable.cs
- RequiredAttributeAttribute.cs
- Win32.cs
- WebPartEditorApplyVerb.cs
- TransportSecurityBindingElement.cs
- SerialReceived.cs
- PrintPreviewControl.cs
- _SSPISessionCache.cs
- HTTPNotFoundHandler.cs
- Slider.cs
- BoundsDrawingContextWalker.cs
- validationstate.cs
- Emitter.cs
- _SslSessionsCache.cs
- SessionEndedEventArgs.cs
- System.Data_BID.cs
- SelectionItemPattern.cs
- AnnotationResourceChangedEventArgs.cs
- AttachedAnnotationChangedEventArgs.cs
- ValidateNames.cs
- ResourceDisplayNameAttribute.cs
- MenuCommand.cs
- WinInetCache.cs
- DuplicateDetector.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- Win32SafeHandles.cs
- SiteOfOriginPart.cs
- TypeContext.cs
- cryptoapiTransform.cs
- IpcClientChannel.cs
- SQLRoleProvider.cs
- ConsumerConnectionPointCollection.cs
- CatalogZoneBase.cs
- Int32KeyFrameCollection.cs
- Run.cs
- CompilerCollection.cs
- DrawingContextDrawingContextWalker.cs
- AsyncResult.cs
- GenericParameterDataContract.cs
- BadImageFormatException.cs
- LineServicesCallbacks.cs
- X509Certificate2.cs
- MetadataWorkspace.cs
- TextFormatterHost.cs
- CodeIterationStatement.cs
- ImpersonationContext.cs
- CryptoApi.cs
- ProfilePropertySettings.cs
- NeutralResourcesLanguageAttribute.cs
- XPathDescendantIterator.cs
- MembershipValidatePasswordEventArgs.cs
- DataContractSerializerFaultFormatter.cs
- Journal.cs
- SocketCache.cs
- MulticastIPAddressInformationCollection.cs
- Vertex.cs
- CodeExporter.cs
- Rotation3DAnimationBase.cs
- Misc.cs
- WebPartDisplayMode.cs
- RawStylusInputReport.cs
- RectAnimationClockResource.cs
- DataStreams.cs
- BindingContext.cs
- X509CertificateStore.cs
- UnsafeNativeMethodsTablet.cs
- FixedDocument.cs
- BooleanFunctions.cs
- AxHost.cs
- DBConcurrencyException.cs
- Splitter.cs
- SqlCommandBuilder.cs
- BitmapInitialize.cs
- XmlNamespaceManager.cs
- IEnumerable.cs
- ImageDrawing.cs