123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- 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<RemoveType>? keep_on { get; set; }
- public Vector<InstallType>? skip_for { get; set; }
- public static PropertyMapper<ManifestFile> get_mapper() {
- return new PropertyMapperBuilder<ManifestFile>()
- .map<string>("path", o => o.path, (o, v) => o.path = v)
- .map<string>("type", o => o.file_type.to_string(), (o, v) => o.file_type = ManifestFileType.from_string(v))
- .map<string>("dest", o => o.destination, (o, v) => o.destination = v, false)
- .map_many<string>("keepOn", o => o.keep_on.select<string>(i => i.to_string()), (o, v) => o.keep_on = v.convert<RemoveType>(i => RemoveType.from_string(i)).to_vector(), false)
- .map_many<string>("skipFor", o => o.skip_for.select<string>(i => i.to_string()), (o, v) => o.skip_for = v.convert<InstallType>(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\".");
- }
- }
- }
- }
|