Elements.vala 918 B

12345678910111213141516171819202122232425262728293031
  1. namespace Invercargill {
  2. public interface Elements : Enumerable<Element>, Sticky<Elements, Element> {
  3. public virtual Enumerable<T> elements_as<T>() {
  4. return select_where<T>((e, out r) => e.try_get_as<T>(out r));
  5. }
  6. public virtual Enumerable<T> assert_elements_as<T>() {
  7. return select<T>(e => e.assert_as<T>());
  8. }
  9. }
  10. private class ElementsPromotionImplementation : StickyProxyPromotion<Elements, Element>, Sticky<Elements, Element>, Elements {
  11. protected override Elements adhere (Enumerable<Element> enumerable) {
  12. return (Elements)new ElementsPromotionImplementation().wrap(enumerable);
  13. }
  14. protected override Elements passthrough () {
  15. return this;
  16. }
  17. public override bool can_wrap (GLib.Type element_type) {
  18. return element_type.is_a (typeof(Element));
  19. }
  20. }
  21. }