Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Core / CSharp / System / Windows / Media3D / Generated / Transform3DCollection.cs / 1 / Transform3DCollection.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // This file was generated, please do not edit it directly. // // Please see http://wiki/default.aspx/Microsoft.Projects.Avalon/MilCodeGen.html for more information. // //--------------------------------------------------------------------------- using MS.Internal; using MS.Internal.Collections; using MS.Internal.PresentationCore; using MS.Utility; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.InteropServices; using System.Text; using System.Windows.Markup; using System.Windows.Media.Media3D.Converters; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Composition; using System.Security; using System.Security.Permissions; using SR=MS.Internal.PresentationCore.SR; using SRID=MS.Internal.PresentationCore.SRID; using System.Windows.Media.Imaging; // These types are aliased to match the unamanaged names used in interop using BOOL = System.UInt32; using WORD = System.UInt16; using Float = System.Single; namespace System.Windows.Media.Media3D { ////// A collection of Transform3D objects. /// public sealed partial class Transform3DCollection : Animatable, IList, IList{ //----------------------------------------------------- // // Public Methods // //----------------------------------------------------- #region Public Methods /// /// Shadows inherited Clone() with a strongly typed /// version for convenience. /// public new Transform3DCollection Clone() { return (Transform3DCollection)base.Clone(); } ////// Shadows inherited CloneCurrentValue() with a strongly typed /// version for convenience. /// public new Transform3DCollection CloneCurrentValue() { return (Transform3DCollection)base.CloneCurrentValue(); } #endregion Public Methods //------------------------------------------------------ // // Public Properties // //----------------------------------------------------- #region IList/// /// Adds "value" to the list /// public void Add(Transform3D value) { AddHelper(value); } ////// Removes all elements from the list /// public void Clear() { WritePreamble(); // As part of Clear()'ing the collection, we will iterate it and call // OnFreezablePropertyChanged and OnRemove for each item. // However, OnRemove assumes that the item to be removed has already been // pulled from the underlying collection. To statisfy this condition, // we store the old collection and clear _collection before we call these methods. // As Clear() semantics do not include TrimToFit behavior, we create the new // collection storage at the same size as the previous. This is to provide // as close as possible the same perf characteristics as less complicated collections. FrugalStructListoldCollection = _collection; _collection = new FrugalStructList (_collection.Capacity); for (int i = oldCollection.Count - 1; i >= 0; i--) { OnFreezablePropertyChanged(/* oldValue = */ oldCollection[i], /* newValue = */ null); // Fire the OnRemove handlers for each item. We're not ensuring that // all OnRemove's get called if a resumable exception is thrown. // At this time, these call-outs are not public, so we do not handle exceptions. OnRemove( /* oldValue */ oldCollection[i]); } ++_version; WritePostscript(); } /// /// Determines if the list contains "value" /// public bool Contains(Transform3D value) { ReadPreamble(); return _collection.Contains(value); } ////// Returns the index of "value" in the list /// public int IndexOf(Transform3D value) { ReadPreamble(); return _collection.IndexOf(value); } ////// Inserts "value" into the list at the specified position /// public void Insert(int index, Transform3D value) { if (value == null) { throw new System.ArgumentException(SR.Get(SRID.Collection_NoNull)); } WritePreamble(); OnFreezablePropertyChanged(/* oldValue = */ null, /* newValue = */ value); _collection.Insert(index, value); OnInsert(value); ++_version; WritePostscript(); } ////// Removes "value" from the list /// public bool Remove(Transform3D value) { WritePreamble(); // By design collections "succeed silently" if you attempt to remove an item // not in the collection. Therefore we need to first verify the old value exists // before calling OnFreezablePropertyChanged. Since we already need to locate // the item in the collection we keep the index and use RemoveAt(...) to do // the work. (Windows OS #1016178) // We use the public IndexOf to guard our UIContext since OnFreezablePropertyChanged // is only called conditionally. IList.IndexOf returns -1 if the value is not found. int index = IndexOf(value); if (index >= 0) { Transform3D oldValue = _collection[index]; OnFreezablePropertyChanged(oldValue, null); _collection.RemoveAt(index); OnRemove(oldValue); ++_version; WritePostscript(); return true; } // Collection_Remove returns true, calls WritePostscript, // increments version, and does UpdateResource if it succeeds return false; } ////// Removes the element at the specified index /// public void RemoveAt(int index) { RemoveAtWithoutFiringPublicEvents(index); // RemoveAtWithoutFiringPublicEvents incremented the version WritePostscript(); } ////// Removes the element at the specified index without firing /// the public Changed event. /// The caller - typically a public method - is responsible for calling /// WritePostscript if appropriate. /// internal void RemoveAtWithoutFiringPublicEvents(int index) { WritePreamble(); Transform3D oldValue = _collection[ index ]; OnFreezablePropertyChanged(oldValue, null); _collection.RemoveAt(index); OnRemove(oldValue); ++_version; // No WritePostScript to avoid firing the Changed event. } ////// Indexer for the collection /// public Transform3D this[int index] { get { ReadPreamble(); return _collection[index]; } set { if (value == null) { throw new System.ArgumentException(SR.Get(SRID.Collection_NoNull)); } WritePreamble(); if (!Object.ReferenceEquals(_collection[ index ], value)) { Transform3D oldValue = _collection[ index ]; OnFreezablePropertyChanged(oldValue, value); _collection[ index ] = value; OnSet(oldValue, value); } ++_version; WritePostscript(); } } #endregion #region ICollection/// /// The number of elements contained in the collection. /// public int Count { get { ReadPreamble(); return _collection.Count; } } ////// Copies the elements of the collection into "array" starting at "index" /// public void CopyTo(Transform3D[] array, int index) { ReadPreamble(); if (array == null) { throw new ArgumentNullException("array"); } // This will not throw in the case that we are copying // from an empty collection. This is consistent with the // BCL Collection implementations. (Windows 1587365) if (index < 0 || (index + _collection.Count) > array.Length) { throw new ArgumentOutOfRangeException("index"); } _collection.CopyTo(array, index); } bool ICollection.IsReadOnly { get { ReadPreamble(); return IsFrozen; } } #endregion #region IEnumerable /// /// Returns an enumerator for the collection /// public Enumerator GetEnumerator() { ReadPreamble(); return new Enumerator(this); } IEnumeratorIEnumerable .GetEnumerator() { return this.GetEnumerator(); } #endregion #region IList bool IList.IsReadOnly { get { return ((ICollection )this).IsReadOnly; } } bool IList.IsFixedSize { get { ReadPreamble(); return IsFrozen; } } object IList.this[int index] { get { return this[index]; } set { // Forwards to typed implementation this[index] = Cast(value); } } int IList.Add(object value) { // Forward to typed helper return AddHelper(Cast(value)); } bool IList.Contains(object value) { return Contains(value as Transform3D); } int IList.IndexOf(object value) { return IndexOf(value as Transform3D); } void IList.Insert(int index, object value) { // Forward to IList Insert Insert(index, Cast(value)); } void IList.Remove(object value) { Remove(value as Transform3D); } #endregion #region ICollection void ICollection.CopyTo(Array array, int index) { ReadPreamble(); if (array == null) { throw new ArgumentNullException("array"); } // This will not throw in the case that we are copying // from an empty collection. This is consistent with the // BCL Collection implementations. (Windows 1587365) if (index < 0 || (index + _collection.Count) > array.Length) { throw new ArgumentOutOfRangeException("index"); } if (array.Rank != 1) { throw new ArgumentException(SR.Get(SRID.Collection_BadRank)); } // Elsewhere in the collection we throw an AE when the type is // bad so we do it here as well to be consistent try { int count = _collection.Count; for (int i = 0; i < count; i++) { array.SetValue(_collection[i], index + i); } } catch (InvalidCastException e) { throw new ArgumentException(SR.Get(SRID.Collection_BadDestArray, this.GetType().Name), e); } } bool ICollection.IsSynchronized { get { ReadPreamble(); return IsFrozen || Dispatcher != null; } } object ICollection.SyncRoot { get { ReadPreamble(); return this; } } #endregion #region IEnumerable IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); } #endregion #region Internal Helpers /// /// A frozen empty Transform3DCollection. /// internal static Transform3DCollection Empty { get { if (s_empty == null) { Transform3DCollection collection = new Transform3DCollection(); collection.Freeze(); s_empty = collection; } return s_empty; } } ////// Helper to return read only access. /// internal Transform3D Internal_GetItem(int i) { return _collection[i]; } ////// Freezable collections need to notify their contained Freezables /// about the change in the InheritanceContext /// internal override void OnInheritanceContextChangedCore(EventArgs args) { base.OnInheritanceContextChangedCore(args); for (int i=0; i.Add does not. This // is called by both Adds and IList 's just ignores the // integer private int AddHelper(Transform3D value) { int index = AddWithoutFiringPublicEvents(value); // AddAtWithoutFiringPublicEvents incremented the version WritePostscript(); return index; } internal int AddWithoutFiringPublicEvents(Transform3D value) { int index = -1; if (value == null) { throw new System.ArgumentException(SR.Get(SRID.Collection_NoNull)); } WritePreamble(); Transform3D newValue = value; OnFreezablePropertyChanged(/* oldValue = */ null, newValue); index = _collection.Add(newValue); OnInsert(newValue); ++_version; // No WritePostScript to avoid firing the Changed event. return index; } internal event ItemInsertedHandler ItemInserted; internal event ItemRemovedHandler ItemRemoved; private void OnInsert(object item) { if (ItemInserted != null) { ItemInserted(this, item); } } private void OnRemove(object oldValue) { if (ItemRemoved != null) { ItemRemoved(this, oldValue); } } private void OnSet(object oldValue, object newValue) { OnInsert(newValue); OnRemove(oldValue); } #endregion Private Helpers private static Transform3DCollection s_empty; #region Public Properties #endregion Public Properties //------------------------------------------------------ // // Protected Methods // //------------------------------------------------------ #region Protected Methods /// /// Implementation of ///Freezable.CreateInstanceCore . ///The new Freezable. protected override Freezable CreateInstanceCore() { return new Transform3DCollection(); } ////// Implementation of Freezable.CloneCore() /// protected override void CloneCore(Freezable source) { Transform3DCollection sourceTransform3DCollection = (Transform3DCollection) source; base.CloneCore(source); int count = sourceTransform3DCollection._collection.Count; _collection = new FrugalStructList(count); for (int i = 0; i < count; i++) { Transform3D newValue = (Transform3D) sourceTransform3DCollection._collection[i].Clone(); OnFreezablePropertyChanged(/* oldValue = */ null, newValue); _collection.Add(newValue); OnInsert(newValue); } } /// /// Implementation of Freezable.CloneCurrentValueCore() /// protected override void CloneCurrentValueCore(Freezable source) { Transform3DCollection sourceTransform3DCollection = (Transform3DCollection) source; base.CloneCurrentValueCore(source); int count = sourceTransform3DCollection._collection.Count; _collection = new FrugalStructList(count); for (int i = 0; i < count; i++) { Transform3D newValue = (Transform3D) sourceTransform3DCollection._collection[i].CloneCurrentValue(); OnFreezablePropertyChanged(/* oldValue = */ null, newValue); _collection.Add(newValue); OnInsert(newValue); } } /// /// Implementation of Freezable.GetAsFrozenCore() /// protected override void GetAsFrozenCore(Freezable source) { Transform3DCollection sourceTransform3DCollection = (Transform3DCollection) source; base.GetAsFrozenCore(source); int count = sourceTransform3DCollection._collection.Count; _collection = new FrugalStructList(count); for (int i = 0; i < count; i++) { Transform3D newValue = (Transform3D) sourceTransform3DCollection._collection[i].GetAsFrozen(); OnFreezablePropertyChanged(/* oldValue = */ null, newValue); _collection.Add(newValue); OnInsert(newValue); } } /// /// Implementation of Freezable.GetCurrentValueAsFrozenCore() /// protected override void GetCurrentValueAsFrozenCore(Freezable source) { Transform3DCollection sourceTransform3DCollection = (Transform3DCollection) source; base.GetCurrentValueAsFrozenCore(source); int count = sourceTransform3DCollection._collection.Count; _collection = new FrugalStructList(count); for (int i = 0; i < count; i++) { Transform3D newValue = (Transform3D) sourceTransform3DCollection._collection[i].GetCurrentValueAsFrozen(); OnFreezablePropertyChanged(/* oldValue = */ null, newValue); _collection.Add(newValue); OnInsert(newValue); } } /// /// Implementation of protected override bool FreezeCore(bool isChecking) { bool canFreeze = base.FreezeCore(isChecking); int count = _collection.Count; for (int i = 0; i < count && canFreeze; i++) { canFreeze &= Freezable.Freeze(_collection[i], isChecking); } return canFreeze; } #endregion ProtectedMethods //----------------------------------------------------- // // Internal Methods // //------------------------------------------------------ #region Internal Methods #endregion Internal Methods //----------------------------------------------------- // // Internal Properties // //----------------------------------------------------- #region Internal Properties #endregion Internal Properties //----------------------------------------------------- // // Dependency Properties // //------------------------------------------------------ #region Dependency Properties #endregion Dependency Properties //----------------------------------------------------- // // Internal Fields // //------------------------------------------------------ #region Internal Fields internal FrugalStructListFreezable.FreezeCore . ///_collection; internal uint _version = 0; #endregion Internal Fields #region Enumerator /// /// Enumerates the items in a Transform3DCollection /// public struct Enumerator : IEnumerator, IEnumerator{ #region Constructor internal Enumerator(Transform3DCollection list) { Debug.Assert(list != null, "list may not be null."); _list = list; _version = list._version; _index = -1; _current = default(Transform3D); } #endregion #region Methods void IDisposable.Dispose() { } /// /// Advances the enumerator to the next element of the collection. /// ////// true if the enumerator was successfully advanced to the next element, /// false if the enumerator has passed the end of the collection. /// public bool MoveNext() { _list.ReadPreamble(); if (_version == _list._version) { if (_index > -2 && _index < _list._collection.Count - 1) { _current = _list._collection[++_index]; return true; } else { _index = -2; // -2 indicates "past the end" return false; } } else { throw new InvalidOperationException(SR.Get(SRID.Enumerator_CollectionChanged)); } } ////// Sets the enumerator to its initial position, which is before the /// first element in the collection. /// public void Reset() { _list.ReadPreamble(); if (_version == _list._version) { _index = -1; } else { throw new InvalidOperationException(SR.Get(SRID.Enumerator_CollectionChanged)); } } #endregion #region Properties object IEnumerator.Current { get { return this.Current; } } ////// Current element /// /// The behavior of IEnumerable<T>.Current is undefined /// before the first MoveNext and after we have walked /// off the end of the list. However, the IEnumerable.Current /// contract requires that we throw exceptions /// public Transform3D Current { get { if (_index > -1) { return _current; } else if (_index == -1) { throw new InvalidOperationException(SR.Get(SRID.Enumerator_NotStarted)); } else { Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); throw new InvalidOperationException(SR.Get(SRID.Enumerator_ReachedEnd)); } } } #endregion #region Data private Transform3D _current; private Transform3DCollection _list; private uint _version; private int _index; #endregion } #endregion #region Constructors //------------------------------------------------------ // // Constructors // //----------------------------------------------------- ////// Initializes a new instance that is empty. /// public Transform3DCollection() { _collection = new FrugalStructList(); } /// /// Initializes a new instance that is empty and has the specified initial capacity. /// /// int - The number of elements that the new list is initially capable of storing. public Transform3DCollection(int capacity) { _collection = new FrugalStructList(capacity); } /// /// Creates a Transform3DCollection with all of the same elements as collection /// public Transform3DCollection(IEnumerablecollection) { // The WritePreamble and WritePostscript aren't technically necessary // in the constructor as of 1/20/05 but they are put here in case // their behavior changes at a later date WritePreamble(); if (collection != null) { bool needsItemValidation = true; ICollection icollectionOfT = collection as ICollection ; if (icollectionOfT != null) { _collection = new FrugalStructList (icollectionOfT); } else { ICollection icollection = collection as ICollection; if (icollection != null) // an IC but not and IC { _collection = new FrugalStructList (icollection); } else // not a IC or IC so fall back to the slower Add { _collection = new FrugalStructList (); foreach (Transform3D item in collection) { if (item == null) { throw new System.ArgumentException(SR.Get(SRID.Collection_NoNull)); } Transform3D newValue = item; OnFreezablePropertyChanged(/* oldValue = */ null, newValue); _collection.Add(newValue); OnInsert(newValue); } needsItemValidation = false; } } if (needsItemValidation) { foreach (Transform3D item in collection) { if (item == null) { throw new System.ArgumentException(SR.Get(SRID.Collection_NoNull)); } OnFreezablePropertyChanged(/* oldValue = */ null, item); OnInsert(item); } } WritePostscript(); } else { throw new ArgumentNullException("collection"); } } #endregion Constructors } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // // // Copyright (C) Microsoft Corporation. All rights reserved. // // // This file was generated, please do not edit it directly. // // Please see http://wiki/default.aspx/Microsoft.Projects.Avalon/MilCodeGen.html for more information. // //--------------------------------------------------------------------------- using MS.Internal; using MS.Internal.Collections; using MS.Internal.PresentationCore; using MS.Utility; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.InteropServices; using System.Text; using System.Windows.Markup; using System.Windows.Media.Media3D.Converters; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Composition; using System.Security; using System.Security.Permissions; using SR=MS.Internal.PresentationCore.SR; using SRID=MS.Internal.PresentationCore.SRID; using System.Windows.Media.Imaging; // These types are aliased to match the unamanaged names used in interop using BOOL = System.UInt32; using WORD = System.UInt16; using Float = System.Single; namespace System.Windows.Media.Media3D { ////// A collection of Transform3D objects. /// public sealed partial class Transform3DCollection : Animatable, IList, IList{ //----------------------------------------------------- // // Public Methods // //----------------------------------------------------- #region Public Methods /// /// Shadows inherited Clone() with a strongly typed /// version for convenience. /// public new Transform3DCollection Clone() { return (Transform3DCollection)base.Clone(); } ////// Shadows inherited CloneCurrentValue() with a strongly typed /// version for convenience. /// public new Transform3DCollection CloneCurrentValue() { return (Transform3DCollection)base.CloneCurrentValue(); } #endregion Public Methods //------------------------------------------------------ // // Public Properties // //----------------------------------------------------- #region IList/// /// Adds "value" to the list /// public void Add(Transform3D value) { AddHelper(value); } ////// Removes all elements from the list /// public void Clear() { WritePreamble(); // As part of Clear()'ing the collection, we will iterate it and call // OnFreezablePropertyChanged and OnRemove for each item. // However, OnRemove assumes that the item to be removed has already been // pulled from the underlying collection. To statisfy this condition, // we store the old collection and clear _collection before we call these methods. // As Clear() semantics do not include TrimToFit behavior, we create the new // collection storage at the same size as the previous. This is to provide // as close as possible the same perf characteristics as less complicated collections. FrugalStructListoldCollection = _collection; _collection = new FrugalStructList (_collection.Capacity); for (int i = oldCollection.Count - 1; i >= 0; i--) { OnFreezablePropertyChanged(/* oldValue = */ oldCollection[i], /* newValue = */ null); // Fire the OnRemove handlers for each item. We're not ensuring that // all OnRemove's get called if a resumable exception is thrown. // At this time, these call-outs are not public, so we do not handle exceptions. OnRemove( /* oldValue */ oldCollection[i]); } ++_version; WritePostscript(); } /// /// Determines if the list contains "value" /// public bool Contains(Transform3D value) { ReadPreamble(); return _collection.Contains(value); } ////// Returns the index of "value" in the list /// public int IndexOf(Transform3D value) { ReadPreamble(); return _collection.IndexOf(value); } ////// Inserts "value" into the list at the specified position /// public void Insert(int index, Transform3D value) { if (value == null) { throw new System.ArgumentException(SR.Get(SRID.Collection_NoNull)); } WritePreamble(); OnFreezablePropertyChanged(/* oldValue = */ null, /* newValue = */ value); _collection.Insert(index, value); OnInsert(value); ++_version; WritePostscript(); } ////// Removes "value" from the list /// public bool Remove(Transform3D value) { WritePreamble(); // By design collections "succeed silently" if you attempt to remove an item // not in the collection. Therefore we need to first verify the old value exists // before calling OnFreezablePropertyChanged. Since we already need to locate // the item in the collection we keep the index and use RemoveAt(...) to do // the work. (Windows OS #1016178) // We use the public IndexOf to guard our UIContext since OnFreezablePropertyChanged // is only called conditionally. IList.IndexOf returns -1 if the value is not found. int index = IndexOf(value); if (index >= 0) { Transform3D oldValue = _collection[index]; OnFreezablePropertyChanged(oldValue, null); _collection.RemoveAt(index); OnRemove(oldValue); ++_version; WritePostscript(); return true; } // Collection_Remove returns true, calls WritePostscript, // increments version, and does UpdateResource if it succeeds return false; } ////// Removes the element at the specified index /// public void RemoveAt(int index) { RemoveAtWithoutFiringPublicEvents(index); // RemoveAtWithoutFiringPublicEvents incremented the version WritePostscript(); } ////// Removes the element at the specified index without firing /// the public Changed event. /// The caller - typically a public method - is responsible for calling /// WritePostscript if appropriate. /// internal void RemoveAtWithoutFiringPublicEvents(int index) { WritePreamble(); Transform3D oldValue = _collection[ index ]; OnFreezablePropertyChanged(oldValue, null); _collection.RemoveAt(index); OnRemove(oldValue); ++_version; // No WritePostScript to avoid firing the Changed event. } ////// Indexer for the collection /// public Transform3D this[int index] { get { ReadPreamble(); return _collection[index]; } set { if (value == null) { throw new System.ArgumentException(SR.Get(SRID.Collection_NoNull)); } WritePreamble(); if (!Object.ReferenceEquals(_collection[ index ], value)) { Transform3D oldValue = _collection[ index ]; OnFreezablePropertyChanged(oldValue, value); _collection[ index ] = value; OnSet(oldValue, value); } ++_version; WritePostscript(); } } #endregion #region ICollection/// /// The number of elements contained in the collection. /// public int Count { get { ReadPreamble(); return _collection.Count; } } ////// Copies the elements of the collection into "array" starting at "index" /// public void CopyTo(Transform3D[] array, int index) { ReadPreamble(); if (array == null) { throw new ArgumentNullException("array"); } // This will not throw in the case that we are copying // from an empty collection. This is consistent with the // BCL Collection implementations. (Windows 1587365) if (index < 0 || (index + _collection.Count) > array.Length) { throw new ArgumentOutOfRangeException("index"); } _collection.CopyTo(array, index); } bool ICollection.IsReadOnly { get { ReadPreamble(); return IsFrozen; } } #endregion #region IEnumerable /// /// Returns an enumerator for the collection /// public Enumerator GetEnumerator() { ReadPreamble(); return new Enumerator(this); } IEnumeratorIEnumerable .GetEnumerator() { return this.GetEnumerator(); } #endregion #region IList bool IList.IsReadOnly { get { return ((ICollection )this).IsReadOnly; } } bool IList.IsFixedSize { get { ReadPreamble(); return IsFrozen; } } object IList.this[int index] { get { return this[index]; } set { // Forwards to typed implementation this[index] = Cast(value); } } int IList.Add(object value) { // Forward to typed helper return AddHelper(Cast(value)); } bool IList.Contains(object value) { return Contains(value as Transform3D); } int IList.IndexOf(object value) { return IndexOf(value as Transform3D); } void IList.Insert(int index, object value) { // Forward to IList Insert Insert(index, Cast(value)); } void IList.Remove(object value) { Remove(value as Transform3D); } #endregion #region ICollection void ICollection.CopyTo(Array array, int index) { ReadPreamble(); if (array == null) { throw new ArgumentNullException("array"); } // This will not throw in the case that we are copying // from an empty collection. This is consistent with the // BCL Collection implementations. (Windows 1587365) if (index < 0 || (index + _collection.Count) > array.Length) { throw new ArgumentOutOfRangeException("index"); } if (array.Rank != 1) { throw new ArgumentException(SR.Get(SRID.Collection_BadRank)); } // Elsewhere in the collection we throw an AE when the type is // bad so we do it here as well to be consistent try { int count = _collection.Count; for (int i = 0; i < count; i++) { array.SetValue(_collection[i], index + i); } } catch (InvalidCastException e) { throw new ArgumentException(SR.Get(SRID.Collection_BadDestArray, this.GetType().Name), e); } } bool ICollection.IsSynchronized { get { ReadPreamble(); return IsFrozen || Dispatcher != null; } } object ICollection.SyncRoot { get { ReadPreamble(); return this; } } #endregion #region IEnumerable IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); } #endregion #region Internal Helpers /// /// A frozen empty Transform3DCollection. /// internal static Transform3DCollection Empty { get { if (s_empty == null) { Transform3DCollection collection = new Transform3DCollection(); collection.Freeze(); s_empty = collection; } return s_empty; } } ////// Helper to return read only access. /// internal Transform3D Internal_GetItem(int i) { return _collection[i]; } ////// Freezable collections need to notify their contained Freezables /// about the change in the InheritanceContext /// internal override void OnInheritanceContextChangedCore(EventArgs args) { base.OnInheritanceContextChangedCore(args); for (int i=0; i.Add does not. This // is called by both Adds and IList 's just ignores the // integer private int AddHelper(Transform3D value) { int index = AddWithoutFiringPublicEvents(value); // AddAtWithoutFiringPublicEvents incremented the version WritePostscript(); return index; } internal int AddWithoutFiringPublicEvents(Transform3D value) { int index = -1; if (value == null) { throw new System.ArgumentException(SR.Get(SRID.Collection_NoNull)); } WritePreamble(); Transform3D newValue = value; OnFreezablePropertyChanged(/* oldValue = */ null, newValue); index = _collection.Add(newValue); OnInsert(newValue); ++_version; // No WritePostScript to avoid firing the Changed event. return index; } internal event ItemInsertedHandler ItemInserted; internal event ItemRemovedHandler ItemRemoved; private void OnInsert(object item) { if (ItemInserted != null) { ItemInserted(this, item); } } private void OnRemove(object oldValue) { if (ItemRemoved != null) { ItemRemoved(this, oldValue); } } private void OnSet(object oldValue, object newValue) { OnInsert(newValue); OnRemove(oldValue); } #endregion Private Helpers private static Transform3DCollection s_empty; #region Public Properties #endregion Public Properties //------------------------------------------------------ // // Protected Methods // //------------------------------------------------------ #region Protected Methods /// /// Implementation of ///Freezable.CreateInstanceCore . ///The new Freezable. protected override Freezable CreateInstanceCore() { return new Transform3DCollection(); } ////// Implementation of Freezable.CloneCore() /// protected override void CloneCore(Freezable source) { Transform3DCollection sourceTransform3DCollection = (Transform3DCollection) source; base.CloneCore(source); int count = sourceTransform3DCollection._collection.Count; _collection = new FrugalStructList(count); for (int i = 0; i < count; i++) { Transform3D newValue = (Transform3D) sourceTransform3DCollection._collection[i].Clone(); OnFreezablePropertyChanged(/* oldValue = */ null, newValue); _collection.Add(newValue); OnInsert(newValue); } } /// /// Implementation of Freezable.CloneCurrentValueCore() /// protected override void CloneCurrentValueCore(Freezable source) { Transform3DCollection sourceTransform3DCollection = (Transform3DCollection) source; base.CloneCurrentValueCore(source); int count = sourceTransform3DCollection._collection.Count; _collection = new FrugalStructList(count); for (int i = 0; i < count; i++) { Transform3D newValue = (Transform3D) sourceTransform3DCollection._collection[i].CloneCurrentValue(); OnFreezablePropertyChanged(/* oldValue = */ null, newValue); _collection.Add(newValue); OnInsert(newValue); } } /// /// Implementation of Freezable.GetAsFrozenCore() /// protected override void GetAsFrozenCore(Freezable source) { Transform3DCollection sourceTransform3DCollection = (Transform3DCollection) source; base.GetAsFrozenCore(source); int count = sourceTransform3DCollection._collection.Count; _collection = new FrugalStructList(count); for (int i = 0; i < count; i++) { Transform3D newValue = (Transform3D) sourceTransform3DCollection._collection[i].GetAsFrozen(); OnFreezablePropertyChanged(/* oldValue = */ null, newValue); _collection.Add(newValue); OnInsert(newValue); } } /// /// Implementation of Freezable.GetCurrentValueAsFrozenCore() /// protected override void GetCurrentValueAsFrozenCore(Freezable source) { Transform3DCollection sourceTransform3DCollection = (Transform3DCollection) source; base.GetCurrentValueAsFrozenCore(source); int count = sourceTransform3DCollection._collection.Count; _collection = new FrugalStructList(count); for (int i = 0; i < count; i++) { Transform3D newValue = (Transform3D) sourceTransform3DCollection._collection[i].GetCurrentValueAsFrozen(); OnFreezablePropertyChanged(/* oldValue = */ null, newValue); _collection.Add(newValue); OnInsert(newValue); } } /// /// Implementation of protected override bool FreezeCore(bool isChecking) { bool canFreeze = base.FreezeCore(isChecking); int count = _collection.Count; for (int i = 0; i < count && canFreeze; i++) { canFreeze &= Freezable.Freeze(_collection[i], isChecking); } return canFreeze; } #endregion ProtectedMethods //----------------------------------------------------- // // Internal Methods // //------------------------------------------------------ #region Internal Methods #endregion Internal Methods //----------------------------------------------------- // // Internal Properties // //----------------------------------------------------- #region Internal Properties #endregion Internal Properties //----------------------------------------------------- // // Dependency Properties // //------------------------------------------------------ #region Dependency Properties #endregion Dependency Properties //----------------------------------------------------- // // Internal Fields // //------------------------------------------------------ #region Internal Fields internal FrugalStructListFreezable.FreezeCore . ///_collection; internal uint _version = 0; #endregion Internal Fields #region Enumerator /// /// Enumerates the items in a Transform3DCollection /// public struct Enumerator : IEnumerator, IEnumerator{ #region Constructor internal Enumerator(Transform3DCollection list) { Debug.Assert(list != null, "list may not be null."); _list = list; _version = list._version; _index = -1; _current = default(Transform3D); } #endregion #region Methods void IDisposable.Dispose() { } /// /// Advances the enumerator to the next element of the collection. /// ////// true if the enumerator was successfully advanced to the next element, /// false if the enumerator has passed the end of the collection. /// public bool MoveNext() { _list.ReadPreamble(); if (_version == _list._version) { if (_index > -2 && _index < _list._collection.Count - 1) { _current = _list._collection[++_index]; return true; } else { _index = -2; // -2 indicates "past the end" return false; } } else { throw new InvalidOperationException(SR.Get(SRID.Enumerator_CollectionChanged)); } } ////// Sets the enumerator to its initial position, which is before the /// first element in the collection. /// public void Reset() { _list.ReadPreamble(); if (_version == _list._version) { _index = -1; } else { throw new InvalidOperationException(SR.Get(SRID.Enumerator_CollectionChanged)); } } #endregion #region Properties object IEnumerator.Current { get { return this.Current; } } ////// Current element /// /// The behavior of IEnumerable<T>.Current is undefined /// before the first MoveNext and after we have walked /// off the end of the list. However, the IEnumerable.Current /// contract requires that we throw exceptions /// public Transform3D Current { get { if (_index > -1) { return _current; } else if (_index == -1) { throw new InvalidOperationException(SR.Get(SRID.Enumerator_NotStarted)); } else { Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); throw new InvalidOperationException(SR.Get(SRID.Enumerator_ReachedEnd)); } } } #endregion #region Data private Transform3D _current; private Transform3DCollection _list; private uint _version; private int _index; #endregion } #endregion #region Constructors //------------------------------------------------------ // // Constructors // //----------------------------------------------------- ////// Initializes a new instance that is empty. /// public Transform3DCollection() { _collection = new FrugalStructList(); } /// /// Initializes a new instance that is empty and has the specified initial capacity. /// /// int - The number of elements that the new list is initially capable of storing. public Transform3DCollection(int capacity) { _collection = new FrugalStructList(capacity); } /// /// Creates a Transform3DCollection with all of the same elements as collection /// public Transform3DCollection(IEnumerablecollection) { // The WritePreamble and WritePostscript aren't technically necessary // in the constructor as of 1/20/05 but they are put here in case // their behavior changes at a later date WritePreamble(); if (collection != null) { bool needsItemValidation = true; ICollection icollectionOfT = collection as ICollection ; if (icollectionOfT != null) { _collection = new FrugalStructList (icollectionOfT); } else { ICollection icollection = collection as ICollection; if (icollection != null) // an IC but not and IC { _collection = new FrugalStructList (icollection); } else // not a IC or IC so fall back to the slower Add { _collection = new FrugalStructList (); foreach (Transform3D item in collection) { if (item == null) { throw new System.ArgumentException(SR.Get(SRID.Collection_NoNull)); } Transform3D newValue = item; OnFreezablePropertyChanged(/* oldValue = */ null, newValue); _collection.Add(newValue); OnInsert(newValue); } needsItemValidation = false; } } if (needsItemValidation) { foreach (Transform3D item in collection) { if (item == null) { throw new System.ArgumentException(SR.Get(SRID.Collection_NoNull)); } OnFreezablePropertyChanged(/* oldValue = */ null, item); OnInsert(item); } } WritePostscript(); } else { throw new ArgumentNullException("collection"); } } #endregion Constructors } } // 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
- SmtpNtlmAuthenticationModule.cs
- DesignerLoader.cs
- Helper.cs
- DocumentApplicationJournalEntry.cs
- BindingRestrictions.cs
- safex509handles.cs
- NonBatchDirectoryCompiler.cs
- ProcessHostServerConfig.cs
- DataGridAutomationPeer.cs
- TraceListeners.cs
- DataObject.cs
- AssemblyResourceLoader.cs
- TcpAppDomainProtocolHandler.cs
- ITextView.cs
- InstancePersistenceException.cs
- DispatcherExceptionEventArgs.cs
- GridViewRowEventArgs.cs
- Metafile.cs
- RtfControls.cs
- CryptoStream.cs
- hwndwrapper.cs
- ConversionHelper.cs
- UnmanagedMemoryStreamWrapper.cs
- ResourceCategoryAttribute.cs
- RadioButtonPopupAdapter.cs
- Module.cs
- ElementUtil.cs
- InstanceData.cs
- StrongNameMembershipCondition.cs
- DataColumn.cs
- Rules.cs
- EmbossBitmapEffect.cs
- CodeMemberProperty.cs
- OleDbFactory.cs
- HealthMonitoringSectionHelper.cs
- CancelEventArgs.cs
- UIElement3D.cs
- Message.cs
- AggregateNode.cs
- metadatamappinghashervisitor.cs
- ContentIterators.cs
- VectorAnimationBase.cs
- ApplyImportsAction.cs
- Filter.cs
- Wildcard.cs
- XamlToRtfParser.cs
- UnauthorizedAccessException.cs
- DefaultAssemblyResolver.cs
- ComponentChangedEvent.cs
- PolyLineSegment.cs
- Model3D.cs
- UntrustedRecipientException.cs
- SvcMapFile.cs
- SeparatorAutomationPeer.cs
- CompressEmulationStream.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- OutputScopeManager.cs
- XmlNamespaceDeclarationsAttribute.cs
- TextEditorCopyPaste.cs
- Queue.cs
- FieldBuilder.cs
- EncryptedPackage.cs
- HostedImpersonationContext.cs
- Preprocessor.cs
- SiteOfOriginPart.cs
- ListSortDescription.cs
- ToggleButton.cs
- SQLBytes.cs
- VisualCollection.cs
- TransformerInfoCollection.cs
- X509Certificate2.cs
- ObjectDataSource.cs
- MethodBuilder.cs
- ResourceReferenceExpressionConverter.cs
- ToolboxService.cs
- TrackingRecordPreFilter.cs
- TextElementEditingBehaviorAttribute.cs
- ListViewGroupItemCollection.cs
- ElementHost.cs
- ObjectReferenceStack.cs
- DetailsView.cs
- ResourceDisplayNameAttribute.cs
- UnmanagedMarshal.cs
- DataListCommandEventArgs.cs
- KnownTypeDataContractResolver.cs
- MemoryPressure.cs
- _RequestCacheProtocol.cs
- SmiConnection.cs
- XmlBinaryReader.cs
- ModuleBuilder.cs
- AudioFileOut.cs
- DataGridTemplateColumn.cs
- EditingCommands.cs
- AuthorizationBehavior.cs
- WebControlParameterProxy.cs
- AdPostCacheSubstitution.cs
- SettingsPropertyValueCollection.cs
- BitSet.cs
- DesignerSerializationOptionsAttribute.cs
- versioninfo.cs