Exemplo n.º 1
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var hist = value as Network.HistTagChange;

            writer.WriteStartObject();
            writer.WritePropertyName("Entity");
            writer.WriteValue(hist.Entity);
            writer.WritePropertyName("__status");
            writer.WriteValue(EntityDB.GetStatus(hist.Entity));
            writer.WritePropertyName("Change");
            writer.WriteStartObject();
            writer.WritePropertyName(Enum.GetName(typeof(GAME_TAG), hist.Tag));
            var stringVal = TagFormat.GetValue(hist.Tag, hist.Value);

            if (stringVal == null)
            {
                writer.WriteValue(hist.Value);
            }
            else
            {
                writer.WriteValue(stringVal);
            }
            writer.WriteEndObject();
            writer.WritePropertyName("Type");
            writer.WriteValue(Enum.GetName(typeof(Network.PowerType), hist.Type));
            writer.WriteEndObject();
        }
Exemplo n.º 2
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var tags = value as List <Network.Entity.Tag>;

            writer.WriteStartObject();
            foreach (var tag in tags)
            {
                var name      = Enum.GetName(typeof(GAME_TAG), tag.Name);
                var val       = tag.Value;
                var stringVal = TagFormat.GetValue(tag);
                writer.WritePropertyName(name);
                if (stringVal == null)
                {
                    writer.WriteValue(val);
                }
                else
                {
                    writer.WriteValue(stringVal);
                }
            }
            writer.WriteEndObject();
        }