public override AbstractEditor CreateEditor() { ObjectEditor.StructField[] fields = new NekoKun.ObjectEditor.StructField[this.fields.Count]; this.fields.Values.CopyTo(fields, 0); Dictionary <string, object> param = new Dictionary <string, object>(); param["Views"] = this.views; if (this.arrayMode) { var array = new ObjectEditor.ArrayEditor(new ObjectEditor.StructEditor(param, fields)); array.ClipboardFormat = this.clipboardFormat; array.LoadObject = (item) => { var ms = new System.IO.MemoryStream(item); ms.Seek(4, System.IO.SeekOrigin.Begin); return(LoadItem((NekoKun.Serialization.RubyMarshal.RubyMarshal.Load(ms) as RubyArray)[0])); }; array.DumpObject = (item) => { var ms = new System.IO.MemoryStream(); ms.WriteByte(0); ms.WriteByte(0); ms.WriteByte(0); ms.WriteByte(0); NekoKun.Serialization.RubyMarshal.RubyMarshal.Dump(ms, new RubyArray(new List <object>() { this.CreateRubyObject(this.className, item as ObjectEditor.Struct) })); ms.Seek(0, System.IO.SeekOrigin.Begin); System.IO.BinaryWriter bw = new System.IO.BinaryWriter(ms); bw.Write((int)ms.Length - 4); return(ms.ToArray()); }; array.CreateDefaultObject = () => { ObjectEditor.Struct obj = new ObjectEditor.Struct(); foreach (var item in this.fields.Values) { obj[item] = item.DefaultValue; } return(obj); }; return(new ObjectEditor.ObjectFileEditor(this, array)); } else { return(new ObjectEditor.ObjectFileEditor(this, new ObjectEditor.StructEditor(param, fields))); } }
public override AbstractEditor CreateEditor() { ObjectEditor.StructField[] fields = new NekoKun.ObjectEditor.StructField[this.fields.Count]; this.fields.Values.CopyTo(fields, 0); Dictionary<string, object> param = new Dictionary<string, object>(); param["Views"] = this.views; if (this.arrayMode) { var array = new ObjectEditor.ArrayEditor(new ObjectEditor.StructEditor(param, fields)); array.ClipboardFormat = this.clipboardFormat; array.LoadObject = (item) => { var ms = new System.IO.MemoryStream(item); ms.Seek(4, System.IO.SeekOrigin.Begin); return LoadItem((NekoKun.Serialization.RubyMarshal.RubyMarshal.Load(ms) as RubyArray)[0]); }; array.DumpObject = (item) => { var ms = new System.IO.MemoryStream(); ms.WriteByte(0); ms.WriteByte(0); ms.WriteByte(0); ms.WriteByte(0); NekoKun.Serialization.RubyMarshal.RubyMarshal.Dump(ms, new RubyArray(new List<object>() { this.CreateRubyObject(this.className, item as ObjectEditor.Struct) })); ms.Seek(0, System.IO.SeekOrigin.Begin); System.IO.BinaryWriter bw = new System.IO.BinaryWriter(ms); bw.Write((int)ms.Length - 4); return ms.ToArray(); }; array.CreateDefaultObject = () => { ObjectEditor.Struct obj = new ObjectEditor.Struct(); foreach (var item in this.fields.Values) { obj[item] = item.DefaultValue; } return obj; }; return new ObjectEditor.ObjectFileEditor(this, array); } else return new ObjectEditor.ObjectFileEditor(this, new ObjectEditor.StructEditor(param, fields)); }