|
|
@@ -2,37 +2,37 @@
|
|
|
using Invercargill;
|
|
|
namespace InvercargillJson {
|
|
|
|
|
|
- public interface JsonElements : Enumerable<JsonElement>, Elements {
|
|
|
+ public interface JsonElements : Enumerable<JsonElement>, Sticky<JsonElements, JsonElement>, Elements {
|
|
|
|
|
|
- public virtual Enumerable<JsonArray> as_arrays() {
|
|
|
+ public Enumerable<JsonArray> as_arrays() {
|
|
|
return select<JsonArray>(n => new JsonArray.from_existing(n.assert_as<Json.Node>().get_array()));
|
|
|
}
|
|
|
|
|
|
- public virtual Enumerable<bool> as_bools() {
|
|
|
+ public Enumerable<bool> as_bools() {
|
|
|
return select<bool>(n => n.assert_as<Json.Node>().get_boolean());
|
|
|
}
|
|
|
|
|
|
- public virtual Doubles as_doubles() {
|
|
|
- return select<double?>(n => n.assert_as<Json.Node>().get_double()).promote_to<Doubles>();
|
|
|
+ public Doubles as_doubles() {
|
|
|
+ return select<double?>(n => n.assert_as<Json.Node>().get_double()).assert_promotion<Doubles>();
|
|
|
}
|
|
|
|
|
|
- public virtual Signed64BitIntegers as_integers() {
|
|
|
- return select<int64?>(n => n.assert_as<Json.Node>().get_int()).promote_to<Signed64BitIntegers>();
|
|
|
+ public Signed64BitIntegers as_integers() {
|
|
|
+ return select<int64?>(n => n.assert_as<Json.Node>().get_int()).assert_promotion<Signed64BitIntegers>();
|
|
|
}
|
|
|
|
|
|
- public virtual Enumerable<string> as_strings() {
|
|
|
+ public Enumerable<string> as_strings() {
|
|
|
return select<string>(n => n.assert_as<Json.Node>().get_string());
|
|
|
}
|
|
|
|
|
|
- public virtual Enumerable<JsonObject> as_objects() {
|
|
|
+ public Enumerable<JsonObject> as_objects() {
|
|
|
return select<JsonObject>(n => new JsonObject.from_existing(n.assert_as<Json.Node>().get_object()));
|
|
|
}
|
|
|
|
|
|
- public virtual PropertyGroups as_property_groups() {
|
|
|
- return as_objects().promote_to<PropertyGroups>();
|
|
|
+ public PropertyGroups as_property_groups() {
|
|
|
+ return as_objects().assert_promotion<PropertyGroups>();
|
|
|
}
|
|
|
|
|
|
- public virtual JsonArray to_json_array() {
|
|
|
+ public JsonArray to_json_array() {
|
|
|
var array = new JsonArray();
|
|
|
array.add_all((Enumerable<JsonElement>)this);
|
|
|
return array;
|
|
|
@@ -40,19 +40,19 @@ namespace InvercargillJson {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private class JsonElementsPromotionImplementation : Object, Promotion<Element> {
|
|
|
- public bool can_wrap(GLib.Type element_type) {
|
|
|
+ private class JsonElementsPromotionImplementation : StickyProxyPromotion<JsonElements, JsonElement>, JsonElements, Elements {
|
|
|
+ public override bool can_wrap(GLib.Type element_type) {
|
|
|
return element_type.is_a(typeof(JsonElement));
|
|
|
}
|
|
|
- public Enumerable<Element> wrap(Enumerable<Element> enumerable) {
|
|
|
- return new JsonElementsProxy(enumerable.cast<JsonElement>());
|
|
|
+ protected override JsonElements adhere(Invercargill.Enumerable<JsonElement> enumerable) {
|
|
|
+ return new JsonElementsPromotionImplementation().wrap(enumerable);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- private class JsonElementsProxy : ProxyEnumerable<JsonElement>, Elements, JsonElements {
|
|
|
- public JsonElementsProxy(Enumerable<JsonElement> elements) {
|
|
|
- inner = elements;
|
|
|
+ protected override JsonElements passthrough() {
|
|
|
+ return this;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
}
|