Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / System / Collections / ObjectModel / ReadOnlyObservableCollection.cs / 1305376 / 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; using System.Runtime.CompilerServices; namespace System.Collections.ObjectModel { ////// Read-only wrapper around an ObservableCollection. /// [Serializable()] [TypeForwardedFrom("WindowsBase, Version=3.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")] 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; using System.Runtime.CompilerServices; namespace System.Collections.ObjectModel { ////// Read-only wrapper around an ObservableCollection. /// [Serializable()] [TypeForwardedFrom("WindowsBase, Version=3.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")] 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
- BindingGraph.cs
- SoapInteropTypes.cs
- InstanceCreationEditor.cs
- FileDetails.cs
- DmlSqlGenerator.cs
- WebResponse.cs
- PropertyBuilder.cs
- BitmapEffectvisualstate.cs
- LogicalExpr.cs
- SwitchLevelAttribute.cs
- JsonSerializer.cs
- InkCanvas.cs
- CroppedBitmap.cs
- BuildProvider.cs
- BaseComponentEditor.cs
- BrowserDefinition.cs
- DataSpaceManager.cs
- SqlDeflator.cs
- OdbcParameterCollection.cs
- URLMembershipCondition.cs
- InputScopeAttribute.cs
- StickyNote.cs
- PerformanceCounterCategory.cs
- WindowsPrincipal.cs
- InputDevice.cs
- VectorAnimation.cs
- PointConverter.cs
- Operator.cs
- XmlSchemaAnnotation.cs
- MouseWheelEventArgs.cs
- SafeNativeMethodsMilCoreApi.cs
- UnregisterInfo.cs
- ColorBuilder.cs
- PathParser.cs
- DataReaderContainer.cs
- PartitionResolver.cs
- SqlSelectStatement.cs
- ButtonStandardAdapter.cs
- SelectedDatesCollection.cs
- MyContact.cs
- SafeWaitHandle.cs
- FlowPosition.cs
- ToolStripLocationCancelEventArgs.cs
- CustomLineCap.cs
- LambdaCompiler.Binary.cs
- ToolStripProgressBar.cs
- XmlSchemaInferenceException.cs
- MessageDecoder.cs
- TableLayout.cs
- TextEditorCopyPaste.cs
- ReferenceConverter.cs
- CodeSpit.cs
- Cursors.cs
- SafeCryptContextHandle.cs
- DataGridViewRowHeaderCell.cs
- CharacterHit.cs
- LineServices.cs
- X509CertificateTokenFactoryCredential.cs
- DataGridViewButtonColumn.cs
- StructuredTypeEmitter.cs
- DisplayNameAttribute.cs
- ExternalDataExchangeClient.cs
- ToolBarButton.cs
- DomainConstraint.cs
- SvcFileManager.cs
- MenuBase.cs
- CompositeScriptReference.cs
- DataListItem.cs
- StylusButtonEventArgs.cs
- MasterPageParser.cs
- InvokeWebService.cs
- AppSettings.cs
- TrackingProfile.cs
- UpWmlPageAdapter.cs
- SqlExpressionNullability.cs
- ChangeBlockUndoRecord.cs
- HMACRIPEMD160.cs
- SafeRightsManagementQueryHandle.cs
- SessionStateUtil.cs
- LinkUtilities.cs
- SecurityToken.cs
- WorkflowViewStateService.cs
- followingsibling.cs
- UnknownBitmapEncoder.cs
- SmiXetterAccessMap.cs
- StateMachineWorkflow.cs
- HandledMouseEvent.cs
- WebScriptServiceHost.cs
- CompilerGlobalScopeAttribute.cs
- FormatConvertedBitmap.cs
- CellQuery.cs
- QueryCacheManager.cs
- CommandHelper.cs
- ConnectionManagementSection.cs
- TextCompositionManager.cs
- HMACRIPEMD160.cs
- ThreadAbortException.cs
- SecurityHelper.cs
- LockingPersistenceProvider.cs
- TCPListener.cs