Esempio n. 1
0
        internal Boolean CanExecute(ref JsonPropertyValues <T> propertyValues)
        {
            foreach (var property in Properties)
            {
                if (!propertyValues.HasValue(property))
                {
                    return(false);
                }
            }

            return(true);
        }
        internal override unsafe void ReadValue(JsonReader reader, ref TOwner target, bool targetCreated, ref JsonPropertyValues <TOwner> propertyValues)
        {
            TProperty value;

            if (Converter is object)
            {
                // Try to avoid boxing if possible
                if (IsValueType && Converter is JsonConverter <TProperty> valueConverter)
                {
                    value = valueConverter.Read(reader, NonNullablePropertyType);
                }
                else
                {
                    value = (TProperty)Converter.ReadObject(reader, NonNullablePropertyType);
                }
            }
            else
            {
                // If what we are trying to read is reference type with already created
                if (m_setter is null && targetCreated && Traits <TProperty> .IsPopulatable)
                {
                    var currentValue = m_getter(target);

                    if (currentValue is not null)
                    {
                        reader.Populate(currentValue);
                        propertyValues.MarkAsPresent(this);

                        return;
                    }
                }

                value = reader.ReadValue <TProperty>();
            }

            if (targetCreated && m_setter is not null)
            {
                m_setter(ref target, value);
                propertyValues.MarkAsPresent(this);
            }
            else
            {
                propertyValues.SetValue(this, value);
            }
        }
 internal override Object GetValue(ref JsonPropertyValues <TOwner> propertyValues) => propertyValues.GetValue(this);
 internal override void SetValue(ref TOwner target, ref JsonPropertyValues <TOwner> propertyValues)
 {
     m_setter(ref target, propertyValues.GetValue(this));
 }
Esempio n. 5
0
 internal abstract void SetValue(ref TOwner target, ref JsonPropertyValues <TOwner> propertyValues);
Esempio n. 6
0
 internal abstract unsafe void ReadValue(JsonReader reader, ref TOwner owner, bool ownerCreated, ref JsonPropertyValues <TOwner> propertyValues);
Esempio n. 7
0
 internal abstract Object GetValue(ref JsonPropertyValues <TOwner> propertyValues);