/// <summary> /// Creates a <see cref="JsonProperty"/> for the given <see cref="SyntheticForeignKeyProperty"/>. /// </summary> /// <param name="type">The declared type of the synthetic member.</param> /// <param name="syntheticForeignKeyProperty">The synthetic foreign key member to create a <see cref="JsonProperty"/> for.</param> /// <param name="memberConfiguration">The synthetic foreign key member configuration</param> /// <param name="associationMemberConfiguration">The association member configuration.</param> /// <returns>A created <see cref="JsonProperty"/> for the given <see cref="SyntheticForeignKeyProperty"/>.</returns> protected virtual JsonProperty CreateSyntheticForeignKeyProperty( Type type, SyntheticForeignKeyProperty syntheticForeignKeyProperty, SyntheticMemberConfiguration memberConfiguration, MemberConfiguration associationMemberConfiguration) { var property = new JsonProperty { PropertyName = ResolvePropertyName(syntheticForeignKeyProperty.Name), UnderlyingName = syntheticForeignKeyProperty.Name, PropertyType = syntheticForeignKeyProperty.IdentifierType, Ignored = memberConfiguration?.Ignored == true || associationMemberConfiguration?.Ignored == true && memberConfiguration?.Ignored == null, DeclaringType = type, Readable = memberConfiguration?.Serialize ?? associationMemberConfiguration?.Serialize ?? true, Writable = false, ValueProvider = new SyntheticForeignKeyPropertyValueProvider( syntheticForeignKeyProperty.GetAssociationFunction, syntheticForeignKeyProperty.GetIdentifierFunction, syntheticForeignKeyProperty.HasCompositeKey) }; if (memberConfiguration?.HasDefaultValue == true) { property.DefaultValue = memberConfiguration.DefaultValue; } return(property); }
private DataProperty CreateDataProperty( string name, DataType?dataType, bool isPartOfKey, bool isNullable, bool isVersion, SyntheticMemberConfiguration memberConfiguration, StructuralType structuralType, int?typeLength) { return(CreateDataProperty( name, dataType, isPartOfKey, memberConfiguration?.IsNullable ?? isNullable, isVersion, memberConfiguration?.HasDefaultValue == true, memberConfiguration?.DefaultValue, structuralType, memberConfiguration?.MaxLength ?? typeLength, memberConfiguration?.Custom)); }
/// <summary> /// Creates a <see cref="JsonProperty"/> for the given <see cref="SyntheticMemberConfiguration"/>. /// </summary> /// <param name="memberConfiguration">The synthetic member configuration to create a <see cref="JsonProperty"/> for.</param> /// <returns>A created <see cref="JsonProperty"/> for the given <see cref="SyntheticMemberConfiguration"/>.</returns> protected virtual JsonProperty CreateSyntheticProperty(SyntheticMemberConfiguration memberConfiguration) { var valueProvider = new SyntheticMemberValueProvider(memberConfiguration.MemberName, memberConfiguration.SerializeFunction); var property = new JsonProperty { PropertyName = ResolvePropertyName(memberConfiguration.MemberName), UnderlyingName = memberConfiguration.MemberName, PropertyType = memberConfiguration.MemberType, DeclaringType = memberConfiguration.DeclaringType, Readable = memberConfiguration.Serialize ?? true, Ignored = memberConfiguration.Ignored ?? false, Writable = false, ShouldSerialize = CreateShouldSerialize(memberConfiguration.DeclaringType, memberConfiguration.ShouldSerializePredicate, valueProvider.GetValue), ValueProvider = valueProvider }; if (memberConfiguration.HasDefaultValue) { property.DefaultValue = memberConfiguration.DefaultValue; } return(property); }