123456789101112131415161718192021222324252627 |
- using Invercargill;
- using InvercargillJson;
- namespace Binman {
- public Attempts<CompositionComponent> get_composition(string path = "/etc/composition") throws Error {
- return new JsonlInputStream(File.new_for_path(path).read())
- .as_property_groups()
- .try_map_with<CompositionComponent>(CompositionComponent.get_mapper());
- }
- public class CompositionComponent {
- public string name { get; set; }
- public BinaryData key { get; set; }
- public Vector<string> uris { get; set; }
- public static PropertyMapper<CompositionComponent> get_mapper() {
- return PropertyMapper.build_for<CompositionComponent>(cfg => cfg
- .map<string>("name", o => o.name, (o, v) => o.name = v)
- .map<string>("key", o => o.key.to_base64(), (o, v) => o.key = new BinaryData.from_base64(v))
- .map_many<string>("uris", o => o.uris, (o, v) => o.uris = v.to_vector())
- .set_constructor(() => new CompositionComponent())
- );
- }
- }
- }
|