public string GetRead(string target, IPropertySymbol targetProperty, IValueSerializationGeneratorContext context) { var serializerType = FindCustomSerializerType(targetProperty); if (serializerType != null) { return($@"{target}.{targetProperty.Name} = {StaticJsonCustomDeserializerGenerator.GetClassName(serializerType)}.Instance.Deserialize( {context.Read.Reader}, {context.Read.FirstChar}, out {context.Read.OverChar});" ); } return(null); }
public string GetWrite(string sourceName, string source, IPropertySymbol sourceProperty, IValueSerializationGeneratorContext context) { var serializerType = FindCustomSerializerType(sourceProperty); if (serializerType != null) { var value = VariableHelper.GetName(sourceProperty.Type); return($@" var {value} = {source}.{sourceProperty.Name}; if ({value} != null) {{ {context.Write.Object}.WritePropertyName(""{sourceName}""); {StaticJsonCustomDeserializerGenerator.GetClassName(serializerType)}.Instance.Serialize({context.Write.Writer}, {value}); }}" ); } return(null); }