46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
|
|
namespace SessionZero.Data;
|
|
|
|
public class Dataset
|
|
{
|
|
public DatasetMetadata Metadata { get; private set; }
|
|
|
|
private Dictionary<string, SzDataObject> _objectLookup = [];
|
|
private readonly string _path;
|
|
|
|
public Dataset(string name, string id, string dataType, string templateId, string iconPath = "", string description = "")
|
|
{
|
|
Metadata = new()
|
|
{
|
|
Name = name,
|
|
Id = id,
|
|
DatasetType = dataType,
|
|
Description = description,
|
|
ObjectTemplateId = templateId,
|
|
Icon = iconPath
|
|
};
|
|
|
|
_path = Path.Combine(AppManager.DatapacksDirectory, "datasets", id);
|
|
}
|
|
|
|
public void Save()
|
|
{
|
|
if (!Directory.Exists(_path))
|
|
{
|
|
Directory.CreateDirectory(_path);
|
|
Directory.CreateDirectory($"{_path}/objects");
|
|
}
|
|
|
|
if (!File.Exists($"{_path}/dataset.meta"))
|
|
{
|
|
File.WriteAllText($"{_path}/dataset.meta", Metadata.ToString());
|
|
}
|
|
}
|
|
|
|
public void AddObject(SzDataObject obj)
|
|
{
|
|
_objectLookup.TryAdd(obj.Id, obj);
|
|
}
|
|
} |