75 lines
2.0 KiB
C#
75 lines
2.0 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;
|
|
}
|
|
}
|
|
throw new XomContainerNotFoundException("Could not find Xom Container with uuid: " + container.uuid + " in type: " + this.Name);
|
|
}
|
|
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);
|
|
}
|
|
}
|
|
}
|