public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var json    = reader.Value.ToString();
            var jsonObj = JsonConvert.DeserializeObject <EmptyAspect>(json, new JsonSerializerSettings()
            {
                CheckAdditionalContent = true
            });

            IItemAspect targetObj;

            if (!MigrationList.ContainsKey(jsonObj.Name))
            {
                targetObj = ItemAspectFactory.CreateAspectFromString(jsonObj.Name);
                JsonConvert.PopulateObject(json, targetObj);
            }
            else
            {
                if (MigrationList[jsonObj.Name] == "REMOVE")
                {
                    return(null);
                }
                else
                {
                    targetObj = ItemAspectFactory.CreateAspectFromString(MigrationList[jsonObj.Name]);
                }
            }

            return(targetObj);
        }
Exemple #2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var json    = reader.Value.ToString();
            var jsonObj = JsonConvert.DeserializeObject <EmptyAspect>(json, new JsonSerializerSettings()
            {
                CheckAdditionalContent = true
            });
            var targetObj = ItemAspectFactory.CreateAspectFromString(jsonObj.Name);

            JsonConvert.PopulateObject(json, targetObj);
            return(targetObj);
        }