mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -04:00
72 lines
1.1 KiB
C#
72 lines
1.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
|
|
namespace AssetStudio
|
|
{
|
|
public interface IObjChild
|
|
{
|
|
dynamic Parent { get; set; }
|
|
}
|
|
|
|
public abstract class ObjChildren<T> : IEnumerable<T> where T : IObjChild
|
|
{
|
|
protected List<T> children;
|
|
|
|
public T this[int i]
|
|
{
|
|
get { return (T)children[i]; }
|
|
}
|
|
|
|
public int Count
|
|
{
|
|
get { return children.Count; }
|
|
}
|
|
|
|
public void InitChildren(int count)
|
|
{
|
|
children = new List<T>(count);
|
|
}
|
|
|
|
public void AddChild(T obj)
|
|
{
|
|
children.Add(obj);
|
|
obj.Parent = this;
|
|
}
|
|
|
|
public void InsertChild(int i, T obj)
|
|
{
|
|
children.Insert(i, obj);
|
|
obj.Parent = this;
|
|
}
|
|
|
|
public void RemoveChild(T obj)
|
|
{
|
|
obj.Parent = null;
|
|
children.Remove(obj);
|
|
}
|
|
|
|
public void RemoveChild(int i)
|
|
{
|
|
children[i].Parent = null;
|
|
children.RemoveAt(i);
|
|
}
|
|
|
|
public int IndexOf(T obj)
|
|
{
|
|
return children.IndexOf(obj);
|
|
}
|
|
|
|
public IEnumerator<T> GetEnumerator()
|
|
{
|
|
return children.GetEnumerator();
|
|
}
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
{
|
|
return GetEnumerator();
|
|
}
|
|
}
|
|
}
|