public ScriptObject this[int index] { get{ x.exec("document.body['<msg:argument>']=document.body['<mwg:root>'].args[" + index.ToString() + "];"); return(x.FromManaged(x.win.document.body.getAttribute("<mwg:argument>", 0))); } set{ x.win.document.body.setAttribute("<mwg:argument>", value.obj, 0); x.exec("document.body['<mwg:root>'].args[" + index.ToString() + "]=document.body['<mwg:argument>'];"); } }
internal static ScriptObject FromManaged(ScriptExecutor x, object obj) { if (obj == null) { return(new ScriptObject(x, obj)); } System.Type t = obj.GetType(); // 配列に変換 if (t.IsArray && ((System.Array)obj).Rank == 1) { object[] arr = (object[])obj; Array a = (Array)x.execFunc("var a=[];document.body['<mwg:root>'].creatingArrays.push(a);return a;"); for (int i = 0, m = arr.Length; i < m; i++) { x.execSub("$[0].push($[1]);", a, x.FromManaged(arr[i])); } return(a); } ScriptObject r = new ScriptObject(x, obj); if (t == typeof(string) || t.IsValueType) { return(r); } // 具体化 if (r.instanceof("Array")) { return(new Array(x, obj)); } else { switch (r.@typeof) { case "object": case "unknown": case "number": case "string": case "null": default: return(r); } } }