public void VisitDescendents(JSWrapper target, JSFunction action) { Element element = target?.As <Element>(); if (element == null) { throw new ObjectDisposedException("Cannot visit descendents of null"); } var views = element as IViewContainer <View>; if (views == null) { return; } foreach (var e in views.Children) { var ac = WAContext.GetAtomControl(e); var child = e.Wrap(Engine); var r = action.Call(null, new Java.Lang.Object[] { child, (JSValue)ac }); if ((bool)r.IsUndefined() || (bool)r.IsNull() || !((bool)r.ToBoolean())) { continue; } VisitDescendents(JSWrapper.Register(e), action); } }
public static JSValue Wrap(this object value, JSContext context) { if (value == null) { return(null); } if (value is JSValue jv) { return(jv); } if (value is string s) { return(new JSValue(context, s)); } if (value is int i) { return(new JSValue(context, i)); } if (value is float f) { return(new JSValue(context, f)); } if (value is double d) { return(new JSValue(context, d)); } if (value is decimal dec) { return(new JSValue(context, (double)dec)); } if (value is bool b) { return(new JSValue(context, b)); } if (value is DateTime dt) { return(dt.ToJSDate(context)); } if (value is JSWrapper w) { return(new JSValue(context, w.Key)); } return(new JSValue(context, JSWrapper.Register(value).Key)); }