12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using Invercargill;
- namespace Usm {
- public enum LicenceCategory {
- PROPRIETARY = 0,
- SOURCE_AVAILABLE = 1,
- OPEN_SOURCE = 2,
- LIBRE = 3;
- public static LicenceCategory from_string(string str) throws ManifestError {
- switch (str) {
- case "libre":
- return LicenceCategory.LIBRE;
- case "open-source":
- return LicenceCategory.OPEN_SOURCE;
- case "source-available":
- return LicenceCategory.SOURCE_AVAILABLE;
- case "proprietary":
- return LicenceCategory.PROPRIETARY;
- default:
- throw new ManifestError.INVALID_LICENCE_CATEGORY(@"Unknown licence category \"$str\".");
- }
- }
- public string to_string() {
- switch (this) {
- case LicenceCategory.LIBRE:
- return "libre";
- case LicenceCategory.OPEN_SOURCE:
- return "open-source";
- case LicenceCategory.SOURCE_AVAILABLE:
- return "source-available";
- case LicenceCategory.PROPRIETARY:
- return "proprietary";
- default:
- assert_not_reached();
- }
- }
- }
- public class Licence {
- public string name { get; set; }
- public LicenceCategory category { get; set; }
- public string text_path { get; set; }
- public static PropertyMapper<Licence> get_mapper() {
- return once<PropertyMapper<Licence>>(() => new PropertyMapperBuilder<Licence>()
- .map<string>("name", o => o.name, (o, v) => o.name = v)
- .map<string>("category", o => o.category.to_string(), (o, v) => o.category = LicenceCategory.from_string(v))
- .map<string>("text", o => o.text_path, (o, v) => o.text_path = v)
- .set_constructor(() => new Licence())
- .build());
- }
- }
- }
|