Пример #1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JToken jToken = JToken.Load(reader);

            if (jToken.Type == JTokenType.Null)
            {
                return(null);
            }
            if (jToken.Type == JTokenType.Boolean)
            {
                return(jToken.Value <bool>()
                    ? WorkspaceChangeNotification.True
                    : WorkspaceChangeNotification.False);
            }

            return(WorkspaceChangeNotification.WithId(jToken.Value <string>()));
        }
Пример #2
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            if (value == null)
            {
                writer.WriteNull();
                return;
            }

            WorkspaceChangeNotification castValue = (WorkspaceChangeNotification)value;

            if (castValue.UnregisterId != null)
            {
                writer.WriteValue(castValue.UnregisterId);
            }
            else
            {
                writer.WriteValue(castValue.BooleanValue);
            }
        }