Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Base / System / Collections / ObjectModel / ReadOnlyObservableCollection.cs / 1 / 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
- FilterElement.cs
- InputScope.cs
- MissingManifestResourceException.cs
- unsafeIndexingFilterStream.cs
- SecurityKeyIdentifier.cs
- XmlQualifiedName.cs
- XmlAttributeCollection.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- DbParameterHelper.cs
- BamlLocalizableResourceKey.cs
- ImageMapEventArgs.cs
- DisposableCollectionWrapper.cs
- UInt32.cs
- ToolTip.cs
- BindingOperations.cs
- XD.cs
- SortableBindingList.cs
- AdPostCacheSubstitution.cs
- Brush.cs
- DataGridViewLinkCell.cs
- GeneratedView.cs
- XmlSchemaDatatype.cs
- DataGridViewImageColumn.cs
- WebConfigManager.cs
- FormattedTextSymbols.cs
- DetailsViewRowCollection.cs
- AutomationElement.cs
- HtmlToClrEventProxy.cs
- RightsManagementEncryptedStream.cs
- PrintPageEvent.cs
- DataGridViewTopLeftHeaderCell.cs
- ConstraintConverter.cs
- Rfc2898DeriveBytes.cs
- XmlSchemaObjectCollection.cs
- InvalidTimeZoneException.cs
- HostedHttpContext.cs
- ClearTypeHintValidation.cs
- XmlBindingWorker.cs
- LocatorPart.cs
- XmlAttributeAttribute.cs
- OpCodes.cs
- MarkupCompilePass1.cs
- Logging.cs
- SessionPageStateSection.cs
- UnsafePeerToPeerMethods.cs
- PromptBuilder.cs
- UnknownBitmapDecoder.cs
- WmlValidatorAdapter.cs
- XmlSignatureManifest.cs
- TextEditor.cs
- Deflater.cs
- SessionKeyExpiredException.cs
- CodeTypeMemberCollection.cs
- Vector3D.cs
- ObjectCacheSettings.cs
- StrokeDescriptor.cs
- OpenTypeMethods.cs
- CurrentChangingEventManager.cs
- Int16.cs
- SegmentInfo.cs
- WebServicesDescriptionAttribute.cs
- AttributeUsageAttribute.cs
- loginstatus.cs
- SizeConverter.cs
- PropertyDescriptor.cs
- CodeObject.cs
- BuildProviderAppliesToAttribute.cs
- Button.cs
- DesignerVerb.cs
- StateRuntime.cs
- BitmapDecoder.cs
- TrustLevel.cs
- StorageMappingItemCollection.cs
- ExpressionPrinter.cs
- XmlSchemaSimpleTypeUnion.cs
- CharacterMetrics.cs
- XPathNodePointer.cs
- BrowserCapabilitiesCodeGenerator.cs
- ManipulationInertiaStartingEventArgs.cs
- IndicCharClassifier.cs
- SettingsProperty.cs
- TemplateParser.cs
- Int32EqualityComparer.cs
- CqlQuery.cs
- XmlAnyElementAttribute.cs
- InvalidEnumArgumentException.cs
- XmlAggregates.cs
- InternalTypeHelper.cs
- ComplexTypeEmitter.cs
- SqlFileStream.cs
- DataGridViewIntLinkedList.cs
- AttributeQuery.cs
- ToolStripScrollButton.cs
- RadioButtonRenderer.cs
- ProfileService.cs
- TraceShell.cs
- DockAndAnchorLayout.cs
- EncoderFallback.cs
- TdsParserSafeHandles.cs
- DesignerView.cs