78 lines
2.1 KiB
C#
78 lines
2.1 KiB
C#
using LibXom.Exceptions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LibXom.Data
|
|
{
|
|
public class XomType : XomFileComponent
|
|
{
|
|
private byte[] md5;
|
|
private string name;
|
|
private List<XomContainer> xomContainers = new List<XomContainer>();
|
|
public override int Id
|
|
{
|
|
get
|
|
{
|
|
return this.fileBelongs.calculateIdForXomFileComponent(this.Uuid, fileBelongs.XomTypes);
|
|
}
|
|
}
|
|
|
|
public byte[] Md5
|
|
{
|
|
get
|
|
{
|
|
return md5;
|
|
}
|
|
}
|
|
public string Name
|
|
{
|
|
get
|
|
{
|
|
return name;
|
|
}
|
|
}
|
|
public XomContainer[] Containers
|
|
{
|
|
get
|
|
{
|
|
return xomContainers.ToArray();
|
|
}
|
|
}
|
|
private int getContainerIndex(XomContainer container)
|
|
{
|
|
for (int i = 0; i < xomContainers.Count; i++)
|
|
{
|
|
if (xomContainers[i].Uuid.Equals(container.Uuid, StringComparison.InvariantCulture))
|
|
{
|
|
return i;
|
|
}
|
|
}
|
|
|
|
// maybe removed this container by mistakes; so lets just add it back
|
|
container.Type.xomContainers.Add(container);
|
|
return getContainerIndex(container);
|
|
}
|
|
public void ReplaceContainerData(XomContainer container, byte[] newData)
|
|
{
|
|
int indx = this.getContainerIndex(container);
|
|
this.xomContainers[indx].data = newData;
|
|
}
|
|
public void DeleteContainer(XomContainer container)
|
|
{
|
|
int indx = this.getContainerIndex(container);
|
|
this.xomContainers.RemoveAt(indx);
|
|
}
|
|
|
|
internal XomType(XomFile fileFrom, byte[] md5, string name, XomContainer[] xomContainers)
|
|
{
|
|
fileBelongs = fileFrom;
|
|
this.md5 = md5;
|
|
this.name = name;
|
|
this.xomContainers.AddRange(xomContainers);
|
|
}
|
|
}
|
|
}
|