Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to append prefix on some specific values when deserializing #463

Open
diegosasw opened this issue Jan 7, 2020 · 0 comments
Open

How to append prefix on some specific values when deserializing #463

diegosasw opened this issue Jan 7, 2020 · 0 comments

Comments

@diegosasw
Copy link

diegosasw commented Jan 7, 2020

I am using YamlDotNet to deserialize a yml file into a custom object. For certain strings I'd like to append some prefix on the result.
For example, my custom class is:

class Metadata {
  public string Path {get; set; }
}

and my YML has:

path: image.jpg

and I want to append a given relative path so that when a path value is found it will be modified resulting in myMetadata.Path // /myPrefix/image.jpg when deserializing.

Something like .WithAttributeOverride but for values would be ideal. But I suspect I should do something with a custom Type converters although documentation at https://github.com/aaubry/YamlDotNet/wiki/Serialization.TypeConverters is empty and I couldn't manage to have anything working.

Any guide on whether this is possible would be much appreciated. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant