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
- ConnectionProviderAttribute.cs
- DataGridViewCellFormattingEventArgs.cs
- RichTextBoxConstants.cs
- Line.cs
- DrawListViewSubItemEventArgs.cs
- SimpleTypeResolver.cs
- DecoderNLS.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- CreationContext.cs
- PointConverter.cs
- COM2TypeInfoProcessor.cs
- SHA384Managed.cs
- SingleObjectCollection.cs
- MarkupCompilePass1.cs
- BufferedStream.cs
- ButtonAutomationPeer.cs
- ChannelFactory.cs
- AuthenticatedStream.cs
- ConsoleTraceListener.cs
- RemoveStoryboard.cs
- CommandTreeTypeHelper.cs
- UIntPtr.cs
- ListView.cs
- StylusButtonEventArgs.cs
- StateDesigner.cs
- DtrList.cs
- TextEncodedRawTextWriter.cs
- Assembly.cs
- XPathScanner.cs
- WindowsMenu.cs
- DataBoundControlActionList.cs
- VideoDrawing.cs
- TdsParserSessionPool.cs
- IgnoreSectionHandler.cs
- SafeCoTaskMem.cs
- XmlRawWriterWrapper.cs
- XmlnsCache.cs
- ProfileService.cs
- CookieProtection.cs
- TextElementCollectionHelper.cs
- InstancePersistence.cs
- StrokeSerializer.cs
- _ScatterGatherBuffers.cs
- XamlFigureLengthSerializer.cs
- ViewManagerAttribute.cs
- ByteStorage.cs
- BoundColumn.cs
- ProtectedConfigurationSection.cs
- OpCopier.cs
- SelectingProviderEventArgs.cs
- StreamInfo.cs
- HtmlTernaryTree.cs
- QilReplaceVisitor.cs
- XamlTypeMapper.cs
- RegistryPermission.cs
- LinqDataSourceStatusEventArgs.cs
- NameValueConfigurationElement.cs
- CommonProperties.cs
- FontInfo.cs
- Vector3D.cs
- DbgUtil.cs
- DbProviderSpecificTypePropertyAttribute.cs
- GetPageNumberCompletedEventArgs.cs
- BindingOperations.cs
- TreeNodeEventArgs.cs
- XmlBindingWorker.cs
- FormDesigner.cs
- XmlAttributeHolder.cs
- EntityException.cs
- InstanceCreationEditor.cs
- BitmapEffectRenderDataResource.cs
- AxHost.cs
- ClientData.cs
- DefaultEventAttribute.cs
- SmiRequestExecutor.cs
- EntityDataSourceContextCreatingEventArgs.cs
- SqlProvider.cs
- ScriptBehaviorDescriptor.cs
- NameTable.cs
- SendMailErrorEventArgs.cs
- FlowNode.cs
- DbConnectionHelper.cs
- PasswordTextContainer.cs
- InternalBufferOverflowException.cs
- CodeIdentifiers.cs
- XmlSchemaSimpleTypeList.cs
- TextStore.cs
- TypedLocationWrapper.cs
- SkewTransform.cs
- DataGridDesigner.cs
- ImplicitInputBrush.cs
- ListViewItemSelectionChangedEvent.cs
- diagnosticsswitches.cs
- DataGridViewLayoutData.cs
- SqlCommandBuilder.cs
- ExpressionNormalizer.cs
- AssemblyAttributes.cs
- JsonEnumDataContract.cs
- TracePayload.cs
- ISO2022Encoding.cs