private static object NewWithInitializer(JsType type, JsObject json) { var obj = JsCompiler.NewByFunc(type.ctor); if (@typeof(json) == "array") { throw new Exception("not implemented"); } else { foreach (var p in json) { var setter = obj.As <JsObject>()["set_" + p]; if (@typeof(setter) == "function") { setter.As <JsFunction>().call(obj, json[p]); } else { obj.As <JsObject>()[p] = json[p]; } } } return(obj); }
private static object New(string typeName, JsArray args) { //TODO: var type = JsTypeHelper.GetType(typeName, true); if (args == null || args.length == 0) { var obj = JsCompiler.NewByFunc(type.ctor); return(obj); } else { var obj = JsCompiler.NewByFuncArgs(type.ctor, args); return(obj); } }