More data object creation and test commands
This commit is contained in:
@@ -8,7 +8,8 @@ public class Dataset
|
||||
public DatasetMetadata Metadata { get; private set; }
|
||||
|
||||
private Dictionary<string, SzDataObject> _objectLookup = [];
|
||||
private readonly string _path;
|
||||
|
||||
private string _path = "";
|
||||
|
||||
public Dataset(string name, string id, string dataType, string templateId, string iconPath = "", string description = "")
|
||||
{
|
||||
@@ -21,26 +22,31 @@ public class Dataset
|
||||
ObjectTemplateId = templateId,
|
||||
Icon = iconPath
|
||||
};
|
||||
|
||||
_path = Path.Combine(AppManager.DatapacksDirectory, "datasets", id);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
public void Save(string path)
|
||||
{
|
||||
if (!Directory.Exists(_path))
|
||||
_path = path;
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(_path);
|
||||
Directory.CreateDirectory($"{_path}/objects");
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(Path.Combine(path, "objects"));
|
||||
|
||||
if (!File.Exists($"{_path}/dataset.meta"))
|
||||
if (!File.Exists($"{path}/dataset.meta"))
|
||||
{
|
||||
File.WriteAllText($"{_path}/dataset.meta", Metadata.ToString());
|
||||
File.WriteAllText($"{path}/dataset.meta", Metadata.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public void AddObject(SzDataObject obj)
|
||||
{
|
||||
_objectLookup.TryAdd(obj.Id, obj);
|
||||
var success = _objectLookup.TryAdd(obj.Id, obj);
|
||||
if (success)
|
||||
{
|
||||
File.WriteAllText($"{_path}/objects/{obj.Id}.szo", obj.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user