RazorEmail icon indicating copy to clipboard operation
RazorEmail copied to clipboard

API show allow you to use a custom ITemplateResolver

Open georgiosd opened this issue 12 years ago • 3 comments

It would make testing in LINQPad possible, not to mention the ability to use dependency injection.

Are you open to refactoring the code so that there is also a BuildService which is constructed?

georgiosd avatar Sep 06 '13 09:09 georgiosd

Always open to refactoring . Can you provide a code example of how you would like to use the api?

markkemper1 avatar Sep 18 '13 01:09 markkemper1

I haven't looked at the code base in depth but I was thinking something like:

ITemplateLoader which is an interface that allows the engine to load templates. The default implementation would inject a default implementation ITemplateResolver. Then there would be a BuildService that injects an ITemplateLoader and can build emails.

This would allow the following use cases plus backwards compatibility:

  • Use Injection of BuildService in own code with a custom binding of ITemplateLoader to say, load templates from a DB
  • Use Injection of BuildService in own code with a custom of ITemplateResolver to use a custom way to locate the template on disk
  • For compatibility, in your static methods, you would construct the default versions of the above and leave them as-is

Thoughts?

georgiosd avatar Sep 18 '13 04:09 georgiosd

https://github.com/markkemper1/RazorEmail/pull/4

georgiosd avatar Nov 29 '13 22:11 georgiosd