Closed the-avid-engineer closed 4 years ago
(the regex came from mongodb's connection string parser, watered-down a little bit)
Since EmailServiceOptions is implemented by options pattern, you can assign the values by any logic.
Parsing the option from a connections strings format would be a great idea. I need time to think and implement whether a static method approach is fine.
PR is welcome :)
Ugh, this is kind of annoying - some of the RegularExpression features I'm using aren't available in .NET Standard 2.0 (but are available to .NET Core) - I will try to work around the missing pieces
I've had a branch for this for a while, kind of forgot about it, but I can't publish it to this repo (never contributed to a public repo before.. not sure if there's something I'm supposed to do.)
You can make a pull request.
Here is a guideline https://guides.github.com/activities/forking/
@the-avid-engineer Thank you very much
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
In my application, instead of storing all of the connection data as a structured object in appsettings, I'm just storing it like most connections strings:
smtp://{username}:{password}@{host}:{port}?enableSsl={bool}
and parsing it with this:
Note that Port is optional, and later on if I had a null port, I would just use
new SmtpClient(host)
It would be very nice if this was turned into a static method on EmailServiceOptions, such as
public static EmailServiceOptions FromSmtpConnectionString(string smtpConnectionString);
I can add a pull request if this seems like a useful feature.