Closed ongun23 closed 4 years ago
Do you mean specifying a field name at-runtime?
If yes, I'd be glad to work out a way to make this work, so any suggestion on how you'd like it to work is more than welcome.
Hey there, Using an app config file would be much easier for the property field change for many cases. Also, the class is sealed so inheritance is a bit tight.
I had some time to think about this and I don't think it should be part of this library as feels like an opinionated way to store fieldnames in appsettings.json (we cannot support every single use-case of different ways of storing fieldnames). Additionally, it would mean an additional dependency on System.Configuration
.
Anyway, I believe you should be able to do what you want to do and so I have removed the sealed
modifier from the SapNameAttribute
class, which enables you to do:
[AttributeUsage(AttributeTargets.Property)]
public class SapNameFromAppSettings : SapNameAttribute
{
public SapNameFromAppSettings (string path)
: base(ConfigurationManager.AppSettings[path])
{
}
}
Please look for version 1.0.0.56 or higher of this package.
Thank you for bringing this up!
@huysentruitw Great job! I've been using this amazing library for one of a project and it was taking so much time to change property names because of the production and development environment. Because the property field mapping was limited to hand coded. However, your recent development just nailed it! Great job, thanks!
@ongun23 glad this small change helped you out. Feel free to star this project here on github, always appreciated ⭐
Can the developer provide a dynamic SAP field name like below for the Contract class?