Browse Source

Renamed and documented ChildrenList (ChildrenCollection) and IChildOfList (IChildOf)

Vicente Penades 2 years ago
parent
commit
2b05eaf37d

+ 3 - 3
build/SharpGLTF.CodeGen/Ext.AGI_Articulations.cs

@@ -51,19 +51,19 @@ namespace SharpGLTF
             var agiArticulationRootClass = ctx.FindClass("AGI_articulations glTF extension");
             var agiArticulationRootClass = ctx.FindClass("AGI_articulations glTF extension");
             if (agiArticulationRootClass != null)
             if (agiArticulationRootClass != null)
             {
             {
-                newEmitter.SetCollectionContainer(agiArticulationRootClass.UseField("articulations"), "ChildrenCollection<TItem,AgiRootArticulations>");
+                newEmitter.SetCollectionContainer(agiArticulationRootClass.UseField("articulations"), "ChildrenList<TItem,AgiRootArticulations>");
             }
             }
 
 
             var agiArticulationClass = ctx.FindClass("Articulation");
             var agiArticulationClass = ctx.FindClass("Articulation");
             if (agiArticulationClass != null)
             if (agiArticulationClass != null)
             {
             {
-                newEmitter.SetCollectionContainer(agiArticulationClass.UseField("stages"), "ChildrenCollection<TItem,AgiArticulation>");
+                newEmitter.SetCollectionContainer(agiArticulationClass.UseField("stages"), "ChildrenList<TItem,AgiArticulation>");
             }
             }
 
 
             var agiStkMetadataRootClass = ctx.FindClass("AGI_stk_metadata glTF extension");
             var agiStkMetadataRootClass = ctx.FindClass("AGI_stk_metadata glTF extension");
             if (agiStkMetadataRootClass != null)
             if (agiStkMetadataRootClass != null)
             {
             {
-                newEmitter.SetCollectionContainer(agiStkMetadataRootClass.UseField("solarPanelGroups"), "ChildrenCollection<TItem,AgiRootStkMetadata>");
+                newEmitter.SetCollectionContainer(agiStkMetadataRootClass.UseField("solarPanelGroups"), "ChildrenList<TItem,AgiRootStkMetadata>");
             }
             }
         }
         }
     }
     }

+ 4 - 4
build/SharpGLTF.CodeGen/MainSchemaProcessor.cs

@@ -94,14 +94,14 @@ namespace SharpGLTF
             var meshClass = ctx.FindClass("Mesh");
             var meshClass = ctx.FindClass("Mesh");
             if (meshClass != null)
             if (meshClass != null)
             {
             {
-                newEmitter.SetCollectionContainer(meshClass.UseField("primitives"), "ChildrenCollection<TItem,Mesh>");
+                newEmitter.SetCollectionContainer(meshClass.UseField("primitives"), "ChildrenList<TItem,Mesh>");
             }
             }
 
 
             var animationClass = ctx.FindClass("Animation");
             var animationClass = ctx.FindClass("Animation");
             if (animationClass != null)
             if (animationClass != null)
             {
             {
-                newEmitter.SetCollectionContainer(animationClass.UseField("channels"), "ChildrenCollection<TItem,Animation>");
-                newEmitter.SetCollectionContainer(animationClass.UseField("samplers"), "ChildrenCollection<TItem,Animation>");
+                newEmitter.SetCollectionContainer(animationClass.UseField("channels"), "ChildrenList<TItem,Animation>");
+                newEmitter.SetCollectionContainer(animationClass.UseField("samplers"), "ChildrenList<TItem,Animation>");
             }
             }
 
 
             var classes = ctx.Classes.ToArray();
             var classes = ctx.Classes.ToArray();
@@ -117,7 +117,7 @@ namespace SharpGLTF
                     {
                     {
                         if (ctype.BaseClass != null && ctype.BaseClass.PersistentName == "glTF Child of Root Property")
                         if (ctype.BaseClass != null && ctype.BaseClass.PersistentName == "glTF Child of Root Property")
                         {
                         {
-                            newEmitter.SetCollectionContainer(f, $"ChildrenCollection<TItem,{rootName}>");
+                            newEmitter.SetCollectionContainer(f, $"ChildrenList<TItem,{rootName}>");
                         }
                         }
                     }
                     }
                 }
                 }

+ 87 - 63
src/SharpGLTF.Core/Collections/ChildrenCollection.cs → src/SharpGLTF.Core/Collections/ChildrenList.cs

@@ -1,19 +1,25 @@
 using System;
 using System;
 using System.Collections;
 using System.Collections;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
 
 
 namespace SharpGLTF.Collections
 namespace SharpGLTF.Collections
 {
 {
+    /// <summary>
+    /// An Specialisation of <see cref="List{T}"/>, which interconnects the list items with the parent of the collection.
+    /// </summary>
+    /// <typeparam name="T"></typeparam>
+    /// <typeparam name="TParent"></typeparam>
     [System.Diagnostics.DebuggerDisplay("{Count}")]
     [System.Diagnostics.DebuggerDisplay("{Count}")]
-    sealed class ChildrenCollection<T, TParent> : IList<T>, IReadOnlyList<T>
-        where T : class, IChildOf<TParent>
+    sealed class ChildrenList<T, TParent> : IList<T>, IReadOnlyList<T>
+        where T : class, IChildOfList<TParent>
         where TParent : class
         where TParent : class
     {
     {
         #region lifecycle
         #region lifecycle
 
 
-        public ChildrenCollection(TParent parent)
+        public ChildrenList(TParent parent)
         {
         {
             Guard.NotNull(parent, nameof(parent));
             Guard.NotNull(parent, nameof(parent));
             _Parent = parent;
             _Parent = parent;
@@ -33,6 +39,7 @@ namespace SharpGLTF.Collections
 
 
         #region properties
         #region properties
 
 
+        /// <inheritdoc/>
         public T this[int index]
         public T this[int index]
         {
         {
             get
             get
@@ -44,36 +51,34 @@ namespace SharpGLTF.Collections
             set
             set
             {
             {
                 // new value must be an orphan
                 // new value must be an orphan
-                Guard.NotNull(value, nameof(value));
-                Guard.MustBeNull(value.LogicalParent, nameof(value.LogicalParent));
+                _VerifyIsOrphan(value);
 
 
                 if (_Collection == null) throw new ArgumentOutOfRangeException(nameof(index));
                 if (_Collection == null) throw new ArgumentOutOfRangeException(nameof(index));
 
 
                 if (_Collection[index] == value) return; // nothing to do
                 if (_Collection[index] == value) return; // nothing to do
 
 
-                // orphan the current child
+                // make the current child orphan.
                 if (_Collection[index] != null)
                 if (_Collection[index] != null)
                 {
                 {
-                    _Collection[index]._SetLogicalParent(null, -1);
-                    System.Diagnostics.Debug.Assert(_Collection[index].LogicalParent == null);
-                    System.Diagnostics.Debug.Assert(_Collection[index].LogicalIndex == -1);
+                    _Collection[index].SetLogicalParent(null, -1);
+                    _AssertItem(_Collection[index], -1);
                 }
                 }
 
 
-                _Collection[index] = null;
-
-                // adopt the new child
+                // update the collection with new child
                 _Collection[index] = value;
                 _Collection[index] = value;
+
                 if (_Collection[index] != null)
                 if (_Collection[index] != null)
                 {
                 {
-                    _Collection[index]._SetLogicalParent(_Parent, index);
-                    System.Diagnostics.Debug.Assert(_Collection[index].LogicalParent == _Parent);
-                    System.Diagnostics.Debug.Assert(_Collection[index].LogicalIndex == index);
+                    _Collection[index].SetLogicalParent(_Parent, index);
+                    _AssertItem(_Collection[index], index);
                 }
                 }
             }
             }
         }
         }
 
 
+        /// <inheritdoc/>
         public int Count => _Collection == null ? 0 : _Collection.Count;
         public int Count => _Collection == null ? 0 : _Collection.Count;
 
 
+        /// <inheritdoc/>
         [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
         [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
         public bool IsReadOnly => false;
         public bool IsReadOnly => false;
 
 
@@ -81,112 +86,131 @@ namespace SharpGLTF.Collections
 
 
         #region API
         #region API
 
 
-        public void Add(T item)
+        /// <inheritdoc/>
+        public bool Contains(T item)
         {
         {
-            // new value must be an orphan
-            Guard.NotNull(item, nameof(item));
-            Guard.MustBeNull(item.LogicalParent, nameof(item.LogicalParent));
-            Guard.MustBeEqualTo(-1, item.LogicalIndex, nameof(item.LogicalIndex));
+            return _Collection?.Contains(item) ?? false;
+        }
+
+        /// <inheritdoc/>
+        public int IndexOf(T item)
+        {
+            return _Collection?.IndexOf(item) ?? -1;
+        }
+
+        /// <inheritdoc/>
+        public void CopyTo(T[] array, int arrayIndex)
+        {
+            if (_Collection == null) return;
+            _Collection.CopyTo(array, arrayIndex);
+        }
 
 
-            if (_Collection == null) _Collection = new List<T>();
+        /// <inheritdoc/>
+        public void Add(T item)
+        {
+            _VerifyIsOrphan(item);
 
 
-            item._SetLogicalParent(_Parent, _Collection.Count);
-            System.Diagnostics.Debug.Assert(item.LogicalParent == _Parent);
-            System.Diagnostics.Debug.Assert(item.LogicalIndex == _Collection.Count);
+            _Collection ??= new List<T>();
 
 
+            var idx =_Collection.Count;
             _Collection.Add(item);
             _Collection.Add(item);
+            item.SetLogicalParent(_Parent, idx);
+            _AssertItem(item, idx);
         }
         }
 
 
+        /// <inheritdoc/>
         public void Clear()
         public void Clear()
         {
         {
             if (_Collection == null) return;
             if (_Collection == null) return;
 
 
-            foreach (var item in _Collection)
+            foreach (var item in _Collection) // orphan all children
             {
             {
-                item._SetLogicalParent(null, -1);
-                System.Diagnostics.Debug.Assert(item.LogicalParent == null);
-                System.Diagnostics.Debug.Assert(item.LogicalIndex == -1);
+                item.SetLogicalParent(null, -1);
+                _AssertItem(item, -1);
             }
             }
 
 
             _Collection = null;
             _Collection = null;
         }
         }
 
 
-        public bool Contains(T item)
-        {
-            return _Collection == null ? false : _Collection.Contains(item);
-        }
-
-        public void CopyTo(T[] array, int arrayIndex)
-        {
-            if (_Collection == null) return;
-            _Collection.CopyTo(array, arrayIndex);
-        }
-
-        public int IndexOf(T item)
-        {
-            return _Collection == null ? -1 : _Collection.IndexOf(item);
-        }
-
+        /// <inheritdoc/>
         public void Insert(int index, T item)
         public void Insert(int index, T item)
         {
         {
-            // new value must be an orphan
-            Guard.NotNull(item, nameof(item));
-            Guard.MustBeNull(item.LogicalParent, nameof(item.LogicalParent));
-            Guard.MustBeEqualTo(-1, item.LogicalIndex, nameof(item.LogicalIndex));
-
-            if (_Collection == null) _Collection = new List<T>();
+            _VerifyIsOrphan(item);
 
 
+            _Collection ??= new List<T>();
             _Collection.Insert(index, item);
             _Collection.Insert(index, item);
 
 
             // fix indices of upper items
             // fix indices of upper items
             for (int i = index; i < _Collection.Count; ++i)
             for (int i = index; i < _Collection.Count; ++i)
             {
             {
-                _Collection[i]._SetLogicalParent(_Parent, i);
-                System.Diagnostics.Debug.Assert(_Collection[i].LogicalParent == _Parent);
-                System.Diagnostics.Debug.Assert(_Collection[i].LogicalIndex == i);
+                item = _Collection[i];
+                if (item == null) continue;
+                item.SetLogicalParent(_Parent, i);
+                _AssertItem(item, i);
             }
             }
         }
         }
 
 
+        /// <inheritdoc/>
         public bool Remove(T item)
         public bool Remove(T item)
         {
         {
             var idx = IndexOf(item);
             var idx = IndexOf(item);
-
             if (idx < 0) return false;
             if (idx < 0) return false;
-
             RemoveAt(idx);
             RemoveAt(idx);
 
 
             return true;
             return true;
         }
         }
 
 
+        /// <inheritdoc/>
         public void RemoveAt(int index)
         public void RemoveAt(int index)
         {
         {
             if (_Collection == null) throw new ArgumentOutOfRangeException(nameof(index));
             if (_Collection == null) throw new ArgumentOutOfRangeException(nameof(index));
             if (index < 0 || index >= _Collection.Count) throw new ArgumentOutOfRangeException(nameof(index));
             if (index < 0 || index >= _Collection.Count) throw new ArgumentOutOfRangeException(nameof(index));
 
 
-            // orphan the current child
-            if (_Collection[index] != null) { _Collection[index]._SetLogicalParent(null, -1); }
-
+            var item = _Collection[index];
             _Collection.RemoveAt(index);
             _Collection.RemoveAt(index);
 
 
+            // orphan the current child
+            item?.SetLogicalParent(null, -1);
+
             // fix indices of upper items
             // fix indices of upper items
             for (int i = index; i < _Collection.Count; ++i)
             for (int i = index; i < _Collection.Count; ++i)
             {
             {
-                _Collection[i]._SetLogicalParent(_Parent, i);
-                System.Diagnostics.Debug.Assert(_Collection[i].LogicalParent == _Parent);
-                System.Diagnostics.Debug.Assert(_Collection[i].LogicalIndex == i);
+                item = _Collection[i];
+
+                item.SetLogicalParent(_Parent, i);
+                _AssertItem(item, i);
             }
             }
 
 
             if (_Collection.Count == 0) _Collection = null;
             if (_Collection.Count == 0) _Collection = null;
         }
         }
 
 
+        /// <inheritdoc/>
         public IEnumerator<T> GetEnumerator()
         public IEnumerator<T> GetEnumerator()
         {
         {
-            return _Collection == null ? Enumerable.Empty<T>().GetEnumerator() : _Collection.GetEnumerator();
+            return _Collection?.GetEnumerator() ?? Enumerable.Empty<T>().GetEnumerator();
         }
         }
 
 
+        /// <inheritdoc/>
         IEnumerator IEnumerable.GetEnumerator()
         IEnumerator IEnumerable.GetEnumerator()
         {
         {
-            return _Collection == null ? Enumerable.Empty<T>().GetEnumerator() : _Collection.GetEnumerator();
+            return _Collection?.GetEnumerator() ?? Enumerable.Empty<T>().GetEnumerator();
+        }
+
+        private static void _VerifyIsOrphan(T item)
+        {            
+            Guard.NotNull(item, nameof(item));
+            Guard.MustBeNull(item.LogicalParent, nameof(item.LogicalParent));
+            Guard.MustBeEqualTo(-1, item.LogicalIndex, nameof(item.LogicalIndex));
+        }
+
+        [Conditional("DEBUG")]
+        private void _AssertItem(T item, int index)
+        {
+            System.Diagnostics.Debug.Assert(item.LogicalIndex == index);
+
+            var parent = index >= 0 ? _Parent : null;
+
+            System.Diagnostics.Debug.Assert(item.LogicalParent == parent);            
         }
         }
 
 
         #endregion
         #endregion

+ 0 - 16
src/SharpGLTF.Core/Collections/IChildOf.cs

@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace SharpGLTF.Collections
-{
-    interface IChildOf<TParent>
-        where TParent : class
-    {
-        int LogicalIndex { get; }
-
-        TParent LogicalParent { get; }
-
-        void _SetLogicalParent(TParent parent, int index);
-    }
-}

+ 35 - 0
src/SharpGLTF.Core/Collections/IChildOfList.cs

@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace SharpGLTF.Collections
+{
+    /// <summary>
+    /// Implemented by children of <see cref="ChildrenList{T, TParent}"/>
+    /// </summary>
+    /// <typeparam name="TParent">The type of the parent class containing the collection.</typeparam>
+    interface IChildOfList<TParent>
+        where TParent : class
+    {
+        /// <summary>
+        /// Gets the logical parent that owns the collection containing this object.
+        /// </summary>
+        TParent LogicalParent { get; }
+
+        /// <summary>
+        /// Gets the logical index of this item within the parent's collection.
+        /// </summary>
+        int LogicalIndex { get; }        
+
+        /// <summary>
+        /// Assigns a parent and index to this object.
+        /// </summary>
+        /// <param name="parent">The new parent, or null</param>
+        /// <param name="index">The new index, or -1</param>
+        /// <remarks>
+        /// For internal use of the collection.<br/>
+        /// ALWAYS IMPLEMENT EXPLICITLY!
+        /// </remarks>
+        void SetLogicalParent(TParent parent, int index);
+    }
+}

+ 3 - 3
src/SharpGLTF.Core/Collections/SingleChild.cs

@@ -5,7 +5,7 @@ using System.Text;
 namespace SharpGLTF.Collections
 namespace SharpGLTF.Collections
 {
 {
     sealed class SingleChild<T, TParent>
     sealed class SingleChild<T, TParent>
-        where T : class, IChildOf<TParent>
+        where T : class, IChildOfList<TParent>
         where TParent : class
         where TParent : class
     {
     {
         #region lifecycle
         #region lifecycle
@@ -41,12 +41,12 @@ namespace SharpGLTF.Collections
                 }
                 }
 
 
                 // orphan the current child
                 // orphan the current child
-                if (this._Child != null) { this._Child._SetLogicalParent(null, -1); }
+                if (this._Child != null) { this._Child.SetLogicalParent(null, -1); }
                 this._Child = null;
                 this._Child = null;
 
 
                 // adopt the new child
                 // adopt the new child
                 this._Child = value;
                 this._Child = value;
-                if (this._Child != null) { this._Child._SetLogicalParent(_Parent, 0); }
+                if (this._Child != null) { this._Child.SetLogicalParent(_Parent, 0); }
             }
             }
         }
         }
 
 

+ 2 - 2
src/SharpGLTF.Core/Schema2/Generated/ext.AgiRootArticulations.g.cs

@@ -98,7 +98,7 @@ namespace SharpGLTF.Schema2
 		private Vector3? _pointingVector;
 		private Vector3? _pointingVector;
 		
 		
 		private const int _stagesMinItems = 1;
 		private const int _stagesMinItems = 1;
-		private ChildrenCollection<AgiArticulationStage,AgiArticulation> _stages;
+		private ChildrenList<AgiArticulationStage,AgiArticulation> _stages;
 		
 		
 	
 	
 		protected override void SerializeProperties(Utf8JsonWriter writer)
 		protected override void SerializeProperties(Utf8JsonWriter writer)
@@ -129,7 +129,7 @@ namespace SharpGLTF.Schema2
 	{
 	{
 	
 	
 		private const int _articulationsMinItems = 1;
 		private const int _articulationsMinItems = 1;
-		private ChildrenCollection<AgiArticulation,AgiRootArticulations> _articulations;
+		private ChildrenList<AgiArticulation,AgiRootArticulations> _articulations;
 		
 		
 	
 	
 		protected override void SerializeProperties(Utf8JsonWriter writer)
 		protected override void SerializeProperties(Utf8JsonWriter writer)

+ 1 - 1
src/SharpGLTF.Core/Schema2/Generated/ext.AgiRootStkMetadata.g.cs

@@ -66,7 +66,7 @@ namespace SharpGLTF.Schema2
 	{
 	{
 	
 	
 		private const int _solarPanelGroupsMinItems = 1;
 		private const int _solarPanelGroupsMinItems = 1;
-		private ChildrenCollection<AgiStkSolarPanelGroup,AgiRootStkMetadata> _solarPanelGroups;
+		private ChildrenList<AgiStkSolarPanelGroup,AgiRootStkMetadata> _solarPanelGroups;
 		
 		
 	
 	
 		protected override void SerializeProperties(Utf8JsonWriter writer)
 		protected override void SerializeProperties(Utf8JsonWriter writer)

+ 1 - 1
src/SharpGLTF.Core/Schema2/Generated/ext.ModelLightsPunctual.g.cs

@@ -110,7 +110,7 @@ namespace SharpGLTF.Schema2
 	{
 	{
 	
 	
 		private const int _lightsMinItems = 1;
 		private const int _lightsMinItems = 1;
-		private ChildrenCollection<PunctualLight,ModelRoot> _lights;
+		private ChildrenList<PunctualLight,ModelRoot> _lights;
 		
 		
 	
 	
 		protected override void SerializeProperties(Utf8JsonWriter writer)
 		protected override void SerializeProperties(Utf8JsonWriter writer)

+ 16 - 16
src/SharpGLTF.Core/Schema2/Generated/gltf.g.cs

@@ -468,10 +468,10 @@ namespace SharpGLTF.Schema2
 	{
 	{
 	
 	
 		private const int _channelsMinItems = 1;
 		private const int _channelsMinItems = 1;
-		private ChildrenCollection<AnimationChannel,Animation> _channels;
+		private ChildrenList<AnimationChannel,Animation> _channels;
 		
 		
 		private const int _samplersMinItems = 1;
 		private const int _samplersMinItems = 1;
-		private ChildrenCollection<AnimationSampler,Animation> _samplers;
+		private ChildrenList<AnimationSampler,Animation> _samplers;
 		
 		
 	
 	
 		protected override void SerializeProperties(Utf8JsonWriter writer)
 		protected override void SerializeProperties(Utf8JsonWriter writer)
@@ -968,7 +968,7 @@ namespace SharpGLTF.Schema2
 	{
 	{
 	
 	
 		private const int _primitivesMinItems = 1;
 		private const int _primitivesMinItems = 1;
-		private ChildrenCollection<MeshPrimitive,Mesh> _primitives;
+		private ChildrenList<MeshPrimitive,Mesh> _primitives;
 		
 		
 		private const int _weightsMinItems = 1;
 		private const int _weightsMinItems = 1;
 		private List<Double> _weights;
 		private List<Double> _weights;
@@ -1202,45 +1202,45 @@ namespace SharpGLTF.Schema2
 		private List<String> _extensionsUsed;
 		private List<String> _extensionsUsed;
 		
 		
 		private const int _accessorsMinItems = 1;
 		private const int _accessorsMinItems = 1;
-		private ChildrenCollection<Accessor,ModelRoot> _accessors;
+		private ChildrenList<Accessor,ModelRoot> _accessors;
 		
 		
 		private const int _animationsMinItems = 1;
 		private const int _animationsMinItems = 1;
-		private ChildrenCollection<Animation,ModelRoot> _animations;
+		private ChildrenList<Animation,ModelRoot> _animations;
 		
 		
 		private const int _bufferViewsMinItems = 1;
 		private const int _bufferViewsMinItems = 1;
-		private ChildrenCollection<BufferView,ModelRoot> _bufferViews;
+		private ChildrenList<BufferView,ModelRoot> _bufferViews;
 		
 		
 		private const int _buffersMinItems = 1;
 		private const int _buffersMinItems = 1;
-		private ChildrenCollection<Buffer,ModelRoot> _buffers;
+		private ChildrenList<Buffer,ModelRoot> _buffers;
 		
 		
 		private const int _camerasMinItems = 1;
 		private const int _camerasMinItems = 1;
-		private ChildrenCollection<Camera,ModelRoot> _cameras;
+		private ChildrenList<Camera,ModelRoot> _cameras;
 		
 		
 		private const int _imagesMinItems = 1;
 		private const int _imagesMinItems = 1;
-		private ChildrenCollection<Image,ModelRoot> _images;
+		private ChildrenList<Image,ModelRoot> _images;
 		
 		
 		private const int _materialsMinItems = 1;
 		private const int _materialsMinItems = 1;
-		private ChildrenCollection<Material,ModelRoot> _materials;
+		private ChildrenList<Material,ModelRoot> _materials;
 		
 		
 		private const int _meshesMinItems = 1;
 		private const int _meshesMinItems = 1;
-		private ChildrenCollection<Mesh,ModelRoot> _meshes;
+		private ChildrenList<Mesh,ModelRoot> _meshes;
 		
 		
 		private const int _nodesMinItems = 1;
 		private const int _nodesMinItems = 1;
-		private ChildrenCollection<Node,ModelRoot> _nodes;
+		private ChildrenList<Node,ModelRoot> _nodes;
 		
 		
 		private const int _samplersMinItems = 1;
 		private const int _samplersMinItems = 1;
-		private ChildrenCollection<TextureSampler,ModelRoot> _samplers;
+		private ChildrenList<TextureSampler,ModelRoot> _samplers;
 		
 		
 		private Int32? _scene;
 		private Int32? _scene;
 		
 		
 		private const int _scenesMinItems = 1;
 		private const int _scenesMinItems = 1;
-		private ChildrenCollection<Scene,ModelRoot> _scenes;
+		private ChildrenList<Scene,ModelRoot> _scenes;
 		
 		
 		private const int _skinsMinItems = 1;
 		private const int _skinsMinItems = 1;
-		private ChildrenCollection<Skin,ModelRoot> _skins;
+		private ChildrenList<Skin,ModelRoot> _skins;
 		
 		
 		private const int _texturesMinItems = 1;
 		private const int _texturesMinItems = 1;
-		private ChildrenCollection<Texture,ModelRoot> _textures;
+		private ChildrenList<Texture,ModelRoot> _textures;
 		
 		
 	
 	
 		protected override void SerializeProperties(Utf8JsonWriter writer)
 		protected override void SerializeProperties(Utf8JsonWriter writer)

+ 6 - 6
src/SharpGLTF.Core/Schema2/agi.Articulations.cs

@@ -11,7 +11,7 @@ namespace SharpGLTF.Schema2
     {
     {
         internal AgiRootArticulations(ModelRoot root)
         internal AgiRootArticulations(ModelRoot root)
         {
         {
-            _articulations = new ChildrenCollection<AgiArticulation, AgiRootArticulations>(this);
+            _articulations = new ChildrenList<AgiArticulation, AgiRootArticulations>(this);
         }
         }
 
 
         protected override IEnumerable<ExtraProperties> GetLogicalChildren()
         protected override IEnumerable<ExtraProperties> GetLogicalChildren()
@@ -51,7 +51,7 @@ namespace SharpGLTF.Schema2
         }
         }
     }
     }
 
 
-    public sealed partial class AgiArticulation : IChildOf<AgiRootArticulations>
+    public sealed partial class AgiArticulation : IChildOfList<AgiRootArticulations>
     {
     {
         public static readonly ReadOnlyCollection<AgiArticulationTransformType> AgiRotationTypes =
         public static readonly ReadOnlyCollection<AgiArticulationTransformType> AgiRotationTypes =
             new ReadOnlyCollection<AgiArticulationTransformType>(new List<AgiArticulationTransformType>
             new ReadOnlyCollection<AgiArticulationTransformType>(new List<AgiArticulationTransformType>
@@ -63,7 +63,7 @@ namespace SharpGLTF.Schema2
 
 
         internal AgiArticulation()
         internal AgiArticulation()
         {
         {
-            _stages = new ChildrenCollection<AgiArticulationStage, AgiArticulation>(this);
+            _stages = new ChildrenList<AgiArticulationStage, AgiArticulation>(this);
         }
         }
 
 
         protected override IEnumerable<ExtraProperties> GetLogicalChildren()
         protected override IEnumerable<ExtraProperties> GetLogicalChildren()
@@ -124,14 +124,14 @@ namespace SharpGLTF.Schema2
 
 
         public AgiRootArticulations LogicalParent { get; private set; }
         public AgiRootArticulations LogicalParent { get; private set; }
 
 
-        public void _SetLogicalParent(AgiRootArticulations parent, int index)
+        void IChildOfList<AgiRootArticulations>.SetLogicalParent(AgiRootArticulations parent, int index)
         {
         {
             LogicalParent = parent;
             LogicalParent = parent;
             LogicalIndex = index;
             LogicalIndex = index;
         }
         }
     }
     }
 
 
-    public sealed partial class AgiArticulationStage : IChildOf<AgiArticulation>
+    public sealed partial class AgiArticulationStage : IChildOfList<AgiArticulation>
     {
     {
         internal AgiArticulationStage()
         internal AgiArticulationStage()
         {
         {
@@ -162,7 +162,7 @@ namespace SharpGLTF.Schema2
 
 
         public AgiArticulation LogicalParent { get; private set; }
         public AgiArticulation LogicalParent { get; private set; }
 
 
-        public void _SetLogicalParent(AgiArticulation parent, int index)
+        void IChildOfList<AgiArticulation>.SetLogicalParent(AgiArticulation parent, int index)
         {
         {
             LogicalParent = parent;
             LogicalParent = parent;
             LogicalIndex = index;
             LogicalIndex = index;

+ 3 - 3
src/SharpGLTF.Core/Schema2/agi.StkMetadata.cs

@@ -9,7 +9,7 @@ namespace SharpGLTF.Schema2
     {
     {
         internal AgiRootStkMetadata(ModelRoot root)
         internal AgiRootStkMetadata(ModelRoot root)
         {
         {
-            _solarPanelGroups = new ChildrenCollection<AgiStkSolarPanelGroup, AgiRootStkMetadata>(this);
+            _solarPanelGroups = new ChildrenList<AgiStkSolarPanelGroup, AgiRootStkMetadata>(this);
         }
         }
 
 
         protected override IEnumerable<ExtraProperties> GetLogicalChildren()
         protected override IEnumerable<ExtraProperties> GetLogicalChildren()
@@ -49,13 +49,13 @@ namespace SharpGLTF.Schema2
         }
         }
     }
     }
 
 
-    public sealed partial class AgiStkSolarPanelGroup : IChildOf<AgiRootStkMetadata>
+    public sealed partial class AgiStkSolarPanelGroup : IChildOfList<AgiRootStkMetadata>
     {
     {
         public int LogicalIndex { get; private set; } = -1;
         public int LogicalIndex { get; private set; } = -1;
 
 
         public AgiRootStkMetadata LogicalParent { get; private set; }
         public AgiRootStkMetadata LogicalParent { get; private set; }
 
 
-        public void _SetLogicalParent(AgiRootStkMetadata parent, int index)
+        void IChildOfList<AgiRootStkMetadata>.SetLogicalParent(AgiRootStkMetadata parent, int index)
         {
         {
             LogicalParent = parent;
             LogicalParent = parent;
             LogicalIndex = index;
             LogicalIndex = index;

+ 2 - 2
src/SharpGLTF.Core/Schema2/gltf.AnimationChannel.cs

@@ -47,7 +47,7 @@ namespace SharpGLTF.Schema2
     }
     }
 
 
     [System.Diagnostics.DebuggerDisplay("AnimChannel LogicalNode[{TargetNode.LogicalIndex}].{TargetNodePath}")]
     [System.Diagnostics.DebuggerDisplay("AnimChannel LogicalNode[{TargetNode.LogicalIndex}].{TargetNodePath}")]
-    public sealed partial class AnimationChannel : IChildOf<Animation>
+    public sealed partial class AnimationChannel : IChildOfList<Animation>
     {
     {
         #region lifecycle
         #region lifecycle
         internal AnimationChannel() { }
         internal AnimationChannel() { }
@@ -66,7 +66,7 @@ namespace SharpGLTF.Schema2
             _sampler = sampler.LogicalIndex;
             _sampler = sampler.LogicalIndex;
         }
         }
 
 
-        void IChildOf<Animation>._SetLogicalParent(Animation parent, int index)
+        void IChildOfList<Animation>.SetLogicalParent(Animation parent, int index)
         {
         {
             LogicalParent = parent;
             LogicalParent = parent;
             LogicalIndex = index;
             LogicalIndex = index;

+ 2 - 2
src/SharpGLTF.Core/Schema2/gltf.AnimationSampler.cs

@@ -65,7 +65,7 @@ namespace SharpGLTF.Schema2
     /// </list>
     /// </list>
     /// </remarks>
     /// </remarks>
     sealed partial class AnimationSampler :
     sealed partial class AnimationSampler :
-        IChildOf<Animation>,
+        IChildOfList<Animation>,
         IAnimationSampler<Vector3>,
         IAnimationSampler<Vector3>,
         IAnimationSampler<Quaternion>,
         IAnimationSampler<Quaternion>,
         IAnimationSampler<SPARSE8>,
         IAnimationSampler<SPARSE8>,
@@ -95,7 +95,7 @@ namespace SharpGLTF.Schema2
         /// </summary>
         /// </summary>
         public int LogicalIndex { get; private set; } = -1;
         public int LogicalIndex { get; private set; } = -1;
 
 
-        void IChildOf<Animation>._SetLogicalParent(Animation parent, int index)
+        void IChildOfList<Animation>.SetLogicalParent(Animation parent, int index)
         {
         {
             LogicalParent = parent;
             LogicalParent = parent;
             LogicalIndex = index;
             LogicalIndex = index;

+ 2 - 2
src/SharpGLTF.Core/Schema2/gltf.Animations.cs

@@ -20,8 +20,8 @@ namespace SharpGLTF.Schema2
 
 
         internal Animation()
         internal Animation()
         {
         {
-            _channels = new ChildrenCollection<AnimationChannel, Animation>(this);
-            _samplers = new ChildrenCollection<AnimationSampler, Animation>(this);
+            _channels = new ChildrenList<AnimationChannel, Animation>(this);
+            _samplers = new ChildrenList<AnimationSampler, Animation>(this);
         }
         }
 
 
         #endregion
         #endregion

+ 3 - 3
src/SharpGLTF.Core/Schema2/gltf.LogicalChildOfRoot.cs

@@ -9,7 +9,7 @@ namespace SharpGLTF.Schema2
     /// <summary>
     /// <summary>
     /// All gltf elements stored in ModelRoot must inherit from this class.
     /// All gltf elements stored in ModelRoot must inherit from this class.
     /// </summary>
     /// </summary>
-    public abstract partial class LogicalChildOfRoot : IChildOf<ModelRoot>
+    public abstract partial class LogicalChildOfRoot : IChildOfList<ModelRoot>
     {
     {
         #region properties
         #region properties
 
 
@@ -31,7 +31,7 @@ namespace SharpGLTF.Schema2
 
 
         #endregion
         #endregion
 
 
-        #region IChildOf<ROOT>
+        #region IChildOflist<ROOT>
 
 
         /// <summary>
         /// <summary>
         /// Gets the <see cref="ModelRoot"/> instance that owns this object.
         /// Gets the <see cref="ModelRoot"/> instance that owns this object.
@@ -43,7 +43,7 @@ namespace SharpGLTF.Schema2
         /// </summary>
         /// </summary>
         public int LogicalIndex { get; private set; } = -1;
         public int LogicalIndex { get; private set; } = -1;
 
 
-        void IChildOf<ModelRoot>._SetLogicalParent(ModelRoot parent, int index)
+        void IChildOfList<ModelRoot>.SetLogicalParent(ModelRoot parent, int index)
         {
         {
             LogicalParent = parent;
             LogicalParent = parent;
             LogicalIndex = index;
             LogicalIndex = index;

+ 1 - 1
src/SharpGLTF.Core/Schema2/gltf.Mesh.cs

@@ -29,7 +29,7 @@ namespace SharpGLTF.Schema2
 
 
         internal Mesh()
         internal Mesh()
         {
         {
-            _primitives = new ChildrenCollection<MeshPrimitive, Mesh>(this);
+            _primitives = new ChildrenList<MeshPrimitive, Mesh>(this);
             _weights = new List<double>();
             _weights = new List<double>();
         }
         }
 
 

+ 2 - 2
src/SharpGLTF.Core/Schema2/gltf.MeshPrimitive.cs

@@ -7,7 +7,7 @@ using SharpGLTF.Collections;
 namespace SharpGLTF.Schema2
 namespace SharpGLTF.Schema2
 {
 {
     [System.Diagnostics.DebuggerDisplay("{_DebuggerDisplay(),nq}")]
     [System.Diagnostics.DebuggerDisplay("{_DebuggerDisplay(),nq}")]
-    public sealed partial class MeshPrimitive : IChildOf<Mesh>
+    public sealed partial class MeshPrimitive : IChildOfList<Mesh>
     {
     {
         #region debug
         #region debug
 
 
@@ -42,7 +42,7 @@ namespace SharpGLTF.Schema2
         /// </summary>
         /// </summary>
         public Mesh LogicalParent { get; private set; }
         public Mesh LogicalParent { get; private set; }
 
 
-        void IChildOf<Mesh>._SetLogicalParent(Mesh parent, int index)
+        void IChildOfList<Mesh>.SetLogicalParent(Mesh parent, int index)
         {
         {
             LogicalParent = parent;
             LogicalParent = parent;
             LogicalIndex = index;
             LogicalIndex = index;

+ 1 - 1
src/SharpGLTF.Core/Schema2/gltf.Root.PunctualLights.cs

@@ -11,7 +11,7 @@ namespace SharpGLTF.Schema2
     {
     {
         internal _ModelPunctualLights(ModelRoot root)
         internal _ModelPunctualLights(ModelRoot root)
         {
         {
-            _lights = new ChildrenCollection<PunctualLight, ModelRoot>(root);
+            _lights = new ChildrenList<PunctualLight, ModelRoot>(root);
         }
         }
 
 
         protected override IEnumerable<ExtraProperties> GetLogicalChildren()
         protected override IEnumerable<ExtraProperties> GetLogicalChildren()

+ 13 - 13
src/SharpGLTF.Core/Schema2/gltf.Root.cs

@@ -28,19 +28,19 @@ namespace SharpGLTF.Schema2
             _extensionsUsed = new List<string>();
             _extensionsUsed = new List<string>();
             _extensionsRequired = new List<string>();
             _extensionsRequired = new List<string>();
 
 
-            _accessors = new ChildrenCollection<Accessor, ModelRoot>(this);
-            _animations = new ChildrenCollection<Animation, ModelRoot>(this);
-            _buffers = new ChildrenCollection<Buffer, ModelRoot>(this);
-            _bufferViews = new ChildrenCollection<BufferView, ModelRoot>(this);
-            _cameras = new ChildrenCollection<Camera, ModelRoot>(this);
-            _images = new ChildrenCollection<Image, ModelRoot>(this);
-            _materials = new ChildrenCollection<Material, ModelRoot>(this);
-            _meshes = new ChildrenCollection<Mesh, ModelRoot>(this);
-            _nodes = new ChildrenCollection<Node, ModelRoot>(this);
-            _samplers = new ChildrenCollection<TextureSampler, ModelRoot>(this);
-            _scenes = new ChildrenCollection<Scene, ModelRoot>(this);
-            _skins = new ChildrenCollection<Skin, ModelRoot>(this);
-            _textures = new ChildrenCollection<Texture, ModelRoot>(this);
+            _accessors = new ChildrenList<Accessor, ModelRoot>(this);
+            _animations = new ChildrenList<Animation, ModelRoot>(this);
+            _buffers = new ChildrenList<Buffer, ModelRoot>(this);
+            _bufferViews = new ChildrenList<BufferView, ModelRoot>(this);
+            _cameras = new ChildrenList<Camera, ModelRoot>(this);
+            _images = new ChildrenList<Image, ModelRoot>(this);
+            _materials = new ChildrenList<Material, ModelRoot>(this);
+            _meshes = new ChildrenList<Mesh, ModelRoot>(this);
+            _nodes = new ChildrenList<Node, ModelRoot>(this);
+            _samplers = new ChildrenList<TextureSampler, ModelRoot>(this);
+            _scenes = new ChildrenList<Scene, ModelRoot>(this);
+            _skins = new ChildrenList<Skin, ModelRoot>(this);
+            _textures = new ChildrenList<Texture, ModelRoot>(this);
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 5 - 5
tests/SharpGLTF.Core.Tests/Collections/ChildrenCollectionTests.cs → tests/SharpGLTF.Core.Tests/Collections/ChildrenListTests.cs

@@ -8,15 +8,15 @@ namespace SharpGLTF.Collections
 {
 {
     [TestFixture]
     [TestFixture]
     [Category("Core")]
     [Category("Core")]
-    public class ChildrenCollectionTests
+    public class ChildrenListTests
     {
     {
-        class TestChild : IChildOf<ChildrenCollectionTests>
+        class TestChild : IChildOfList<ChildrenListTests>
         {
         {
-            public ChildrenCollectionTests LogicalParent { get; private set; }
+            public ChildrenListTests LogicalParent { get; private set; }
 
 
             public int LogicalIndex { get; private set; } = -1;
             public int LogicalIndex { get; private set; } = -1;
 
 
-            public void _SetLogicalParent(ChildrenCollectionTests parent, int index)
+            void IChildOfList<ChildrenListTests>.SetLogicalParent(ChildrenListTests parent, int index)
             {
             {
                 LogicalParent = parent;
                 LogicalParent = parent;
                 LogicalIndex = index;
                 LogicalIndex = index;
@@ -28,7 +28,7 @@ namespace SharpGLTF.Collections
         {
         {
             if (System.Diagnostics.Debugger.IsAttached) return;
             if (System.Diagnostics.Debugger.IsAttached) return;
 
 
-            var list = new ChildrenCollection<TestChild, ChildrenCollectionTests>(this);
+            var list = new ChildrenList<TestChild, ChildrenListTests>(this);
             
             
             Assert.Throws<ArgumentNullException>(() => list.Add(null));
             Assert.Throws<ArgumentNullException>(() => list.Add(null));