예제 #1
0
 public void WriteValue(Object Value, JsonWriter Writer, MudObject Owner)
 {
     if (Serializer != null)
     {
         Serializer.WriteValue(Value, Writer, Owner);
     }
     else
     {
         PersistAttribute._WriteValue(Value, Writer, Owner);
     }
 }
        public override object ReadValue(Type ValueType, Newtonsoft.Json.JsonReader Reader, MudObject Owner)
        {
            var r = new Dictionary <String, Object>();

            Reader.Read();
            while (Reader.TokenType != Newtonsoft.Json.JsonToken.EndObject)
            {
                var name = Reader.Value.ToString();
                Reader.Read();
                var value = PersistAttribute._ReadValue(null, Reader, Owner);
                r.Upsert(name, value);
            }
            Reader.Read();

            return(r);
        }
        public override void WriteValue(object Value, Newtonsoft.Json.JsonWriter Writer, MudObject Owner)
        {
            var contents = Value as Dictionary <String, Object>;

            if (contents == null)
            {
                throw new InvalidOperationException();
            }

            Writer.WriteStartObject();

            foreach (var pair in contents)
            {
                Writer.WritePropertyName(pair.Key);
                PersistAttribute._WriteValue(pair.Value, Writer, Owner);
            }

            Writer.WriteEndObject();
        }