Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- InvalidAsynchronousStateException.cs
- SymmetricAlgorithm.cs
- BooleanKeyFrameCollection.cs
- ConstantSlot.cs
- Themes.cs
- ProviderConnectionPointCollection.cs
- RuleSettingsCollection.cs
- BeginEvent.cs
- Compiler.cs
- ExpressionBinding.cs
- HTTPNotFoundHandler.cs
- EventOpcode.cs
- ContainerVisual.cs
- TextDecorationCollection.cs
- BlurBitmapEffect.cs
- ButtonBaseAdapter.cs
- ModelVisual3D.cs
- DebugInfoExpression.cs
- XmlElementAttributes.cs
- XsdValidatingReader.cs
- XmlDataCollection.cs
- TemplatedWizardStep.cs
- SynthesizerStateChangedEventArgs.cs
- UniformGrid.cs
- FormatException.cs
- FactoryGenerator.cs
- ExtentCqlBlock.cs
- LoginView.cs
- RadioButton.cs
- ipaddressinformationcollection.cs
- XmlSignatureManifest.cs
- NativeMethods.cs
- PriorityRange.cs
- EventItfInfo.cs
- HashCodeCombiner.cs
- InvokeProviderWrapper.cs
- NamespaceListProperty.cs
- TranslateTransform3D.cs
- Comparer.cs
- DbQueryCommandTree.cs
- StructuredTypeEmitter.cs
- AvTraceDetails.cs
- CodeLabeledStatement.cs
- ReaderContextStackData.cs
- IgnoreSection.cs
- DbTypeMap.cs
- OutputCache.cs
- EventLog.cs
- LocalizationComments.cs
- ReadOnlyHierarchicalDataSource.cs
- HtmlShimManager.cs
- StorageModelBuildProvider.cs
- MapPathBasedVirtualPathProvider.cs
- WebPartEventArgs.cs
- ProfileGroupSettingsCollection.cs
- AssociatedControlConverter.cs
- PackageStore.cs
- XPathBuilder.cs
- CircleHotSpot.cs
- ScopedKnownTypes.cs
- KeyGestureValueSerializer.cs
- ListSourceHelper.cs
- CodeTypeDeclaration.cs
- ClientTarget.cs
- BooleanAnimationBase.cs
- Route.cs
- BamlTreeUpdater.cs
- MultiByteCodec.cs
- prefixendpointaddressmessagefilter.cs
- PopupRootAutomationPeer.cs
- StackBuilderSink.cs
- MarkedHighlightComponent.cs
- QueryTreeBuilder.cs
- ToolboxBitmapAttribute.cs
- ReturnValue.cs
- VersionConverter.cs
- safelink.cs
- xmlNames.cs
- ObjectAssociationEndMapping.cs
- DataFieldCollectionEditor.cs
- SRGSCompiler.cs
- PreviewKeyDownEventArgs.cs
- OrderedHashRepartitionStream.cs
- WebColorConverter.cs
- WebColorConverter.cs
- EntitySqlQueryBuilder.cs
- ListParaClient.cs
- CuspData.cs
- XmlSerializationGeneratedCode.cs
- SiteMapNodeItemEventArgs.cs
- ISessionStateStore.cs
- SafeViewOfFileHandle.cs
- ReadContentAsBinaryHelper.cs
- RuleSettings.cs
- MetabaseServerConfig.cs
- ToolStripDropDownClosedEventArgs.cs
- MetafileHeader.cs
- BindingManagerDataErrorEventArgs.cs
- RestHandler.cs
- SymmetricKeyWrap.cs