using Invercargill; namespace Usm { public class ManifestFile { public string path { get; set; } public ManifestFileType file_type { get; set; } public string? destination { get; set; } public Vector? keep_on { get; set; } public Vector? skip_for { get; set; } public static PropertyMapper get_mapper() { return new PropertyMapperBuilder() .map("path", o => o.path, (o, v) => o.path = v) .map("type", o => o.file_type.to_string(), (o, v) => o.file_type = ManifestFileType.from_string(v)) .map("dest", o => o.destination, (o, v) => o.destination = v, false) .map_many("keepOn", o => o.keep_on.select(i => i.to_string()), (o, v) => o.keep_on = v.convert(i => RemoveType.from_string(i)).to_vector(), false) .map_many("skipFor", o => o.skip_for.select(i => i.to_string()), (o, v) => o.skip_for = v.convert(i => InstallType.from_string(i)).to_vector(), false) .set_constructor(() => new ManifestFile()) .build(); } public ManifestFile.from_string(string str) { path = str; file_type = ManifestFileType.REGULAR; } } public enum ManifestFileType { REGULAR, DIRECTORY, SYMBOLIC_LINK; public string to_string() { switch(this) { case ManifestFileType.REGULAR: return "reg"; case ManifestFileType.DIRECTORY: return "dir"; case ManifestFileType.SYMBOLIC_LINK: return "lnk"; default: assert_not_reached(); } } public static ManifestFileType from_string(string str) throws ManifestError { switch(str) { case "reg": return ManifestFileType.REGULAR; case "dir": return ManifestFileType.DIRECTORY; case "lnk": return ManifestFileType.SYMBOLIC_LINK; default: throw new ManifestError.INVALID_FILE_TYPE(@"Unknown file type \"$str\"."); } } } }