ReadAndAssertProperty() private static method

private static ReadAndAssertProperty ( JsonReader reader, string propertyName ) : void
reader JsonReader
propertyName string
return void
        public override object ReadJson(JsonReader reader, Type objectType, [Nullable(2)] object existingValue, JsonSerializer serializer)
        {
            EntityKeyMemberConverter.EnsureReflectionObject(objectType);

            object obj = EntityKeyMemberConverter._reflectionObject.Creator(new object[0]);

            EntityKeyMemberConverter.ReadAndAssertProperty(reader, "Key");
            reader.ReadAndAssert();
            ReflectionObject reflectionObject = EntityKeyMemberConverter._reflectionObject;
            object           target           = obj;
            string           member           = "Key";
            object           value            = reader.Value;

            reflectionObject.SetValue(target, member, (value != null) ? value.ToString() : null);
            EntityKeyMemberConverter.ReadAndAssertProperty(reader, "Type");
            reader.ReadAndAssert();
            object value2 = reader.Value;
            Type   type   = Type.GetType((value2 != null) ? value2.ToString() : null);

            EntityKeyMemberConverter.ReadAndAssertProperty(reader, "Value");
            reader.ReadAndAssert();
            EntityKeyMemberConverter._reflectionObject.SetValue(obj, "Value", serializer.Deserialize(reader, type));
            reader.ReadAndAssert();
            return(obj);
        }
Example #2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            EntityKeyMemberConverter.EnsureReflectionObject(objectType);
            object creator = EntityKeyMemberConverter._reflectionObject.Creator(new object[0]);

            EntityKeyMemberConverter.ReadAndAssertProperty(reader, "Key");
            reader.ReadAndAssert();
            EntityKeyMemberConverter._reflectionObject.SetValue(creator, "Key", reader.Value.ToString());
            EntityKeyMemberConverter.ReadAndAssertProperty(reader, "Type");
            reader.ReadAndAssert();
            Type type = Type.GetType(reader.Value.ToString());

            EntityKeyMemberConverter.ReadAndAssertProperty(reader, "Value");
            reader.ReadAndAssert();
            EntityKeyMemberConverter._reflectionObject.SetValue(creator, "Value", serializer.Deserialize(reader, type));
            reader.ReadAndAssert();
            return(creator);
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            IEntityKeyMember entityKeyMember = DynamicWrapper.CreateWrapper <IEntityKeyMember>(Activator.CreateInstance(objectType));

            EntityKeyMemberConverter.ReadAndAssertProperty(reader, "Key");
            EntityKeyMemberConverter.ReadAndAssert(reader);
            entityKeyMember.Key = reader.Value.ToString();
            EntityKeyMemberConverter.ReadAndAssertProperty(reader, "Type");
            EntityKeyMemberConverter.ReadAndAssert(reader);
            string typeName = reader.Value.ToString();
            Type   type     = Type.GetType(typeName);

            EntityKeyMemberConverter.ReadAndAssertProperty(reader, "Value");
            EntityKeyMemberConverter.ReadAndAssert(reader);
            entityKeyMember.Value = serializer.Deserialize(reader, type);
            EntityKeyMemberConverter.ReadAndAssert(reader);
            return(DynamicWrapper.GetUnderlyingObject(entityKeyMember));
        }