Ejemplo n.º 1
0
        protected ObjectEditor.Struct LoadItem(object RubyObj)
        {
            if (RubyObj is RubyNil)
            {
                return(new ObjectEditor.Struct());
            }

            ObjectEditor.Struct dict = new NekoKun.ObjectEditor.Struct();

            foreach (var item in (RubyObj as RubyObject).InstanceVariables)
            {
                if (!this.fields.ContainsKey(item.Key.GetString()))
                {
                    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                    NekoKun.Serialization.RubyMarshal.RubyMarshal.Dump(ms, item.Value);
                    byte[] buf = ms.ToArray();

                    this.fields.Add(
                        item.Key.GetString(),
                        new ObjectEditor.StructField(
                            item.Key.GetString(),
                            delegate
                    {
                        System.IO.MemoryStream ms2 = new System.IO.MemoryStream(buf);
                        return(NekoKun.Serialization.RubyMarshal.RubyMarshal.Load(ms2));
                    }
                            )
                        );
                }

                var field = this.fields[item.Key.GetString()];
                dict.Add(field, item.Value);
            }

            return(dict);
        }
Ejemplo n.º 2
0
        protected ObjectEditor.Struct LoadItem(object RubyObj)
        {
            if (RubyObj is RubyNil)
                return new ObjectEditor.Struct();

            ObjectEditor.Struct dict = new NekoKun.ObjectEditor.Struct();

            foreach (var item in (RubyObj as RubyObject).InstanceVariables)
            {
                if (!this.fields.ContainsKey(item.Key.GetString()))
                {
                    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                    NekoKun.Serialization.RubyMarshal.RubyMarshal.Dump(ms, item.Value);
                    byte[] buf = ms.ToArray();

                    this.fields.Add(
                        item.Key.GetString(),
                        new ObjectEditor.StructField(
                            item.Key.GetString(),
                            delegate
                            {
                                System.IO.MemoryStream ms2 = new System.IO.MemoryStream(buf);
                                return NekoKun.Serialization.RubyMarshal.RubyMarshal.Load(ms2);
                            }
                        )
                    );
                }

                var field = this.fields[item.Key.GetString()];
                dict.Add(field, item.Value);
            }

            return dict;
        }