diff --git a/Skyhop.Mail.sln b/Skyhop.Mail.sln index 3f8da6e..5c7624e 100644 --- a/Skyhop.Mail.sln +++ b/Skyhop.Mail.sln @@ -24,6 +24,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B03343F8-EE4 ProjectSection(SolutionItems) = preProject src\Directory.Build.props = src\Directory.Build.props src\Directory.Build.targets = src\Directory.Build.targets + src\PackageDetails.props = src\PackageDetails.props EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{923EB0D6-45A2-4E56-9979-E80FAF9EDE75}" @@ -38,6 +39,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.Templates", "samples EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Skyhop.Mail", "src\Skyhop.Mail\Skyhop.Mail.csproj", "{23BAD21E-79CB-4665-AD95-EDC0B2449C58}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Skyhop.Mail.Abstractions", "src\Skyhop.Mail.Abstractions\Skyhop.Mail.Abstractions.csproj", "{1F4A7C5A-53F6-441B-ADAC-E880AB4CA3B6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -56,6 +59,10 @@ Global {23BAD21E-79CB-4665-AD95-EDC0B2449C58}.Debug|Any CPU.Build.0 = Debug|Any CPU {23BAD21E-79CB-4665-AD95-EDC0B2449C58}.Release|Any CPU.ActiveCfg = Release|Any CPU {23BAD21E-79CB-4665-AD95-EDC0B2449C58}.Release|Any CPU.Build.0 = Release|Any CPU + {1F4A7C5A-53F6-441B-ADAC-E880AB4CA3B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F4A7C5A-53F6-441B-ADAC-E880AB4CA3B6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F4A7C5A-53F6-441B-ADAC-E880AB4CA3B6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F4A7C5A-53F6-441B-ADAC-E880AB4CA3B6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -67,6 +74,7 @@ Global {B20B9859-B36F-4C12-8AEE-2E4631E6E477} = {421325E9-9344-43DD-962E-D1FE890F7E8D} {EDF5D8A1-8DBA-43C6-BD58-4A2933E8A985} = {421325E9-9344-43DD-962E-D1FE890F7E8D} {23BAD21E-79CB-4665-AD95-EDC0B2449C58} = {B03343F8-EE4C-4386-90BF-94225E44D24C} + {1F4A7C5A-53F6-441B-ADAC-E880AB4CA3B6} = {B03343F8-EE4C-4386-90BF-94225E44D24C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {02451752-289A-4A52-9BBF-1BCB4C640289} diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 5e7dafd..d099888 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,7 +2,7 @@ - netcoreapp3.1 + netcoreapp3.1;net5.0 diff --git a/src/PackageDetails.props b/src/PackageDetails.props new file mode 100644 index 0000000..9009dfb --- /dev/null +++ b/src/PackageDetails.props @@ -0,0 +1,25 @@ + + + + + true + true + + + + 3.0.0-rc6 + 0.0.1 + $(PackageVersion) + + true + Apache-2.0 + mail razor + A library smoothing email generation from .NET code, by enforcing a strong boundary between the template, and code rendering the template. + https://github.com/skyhop/Mail + https://github.com/skyhop/Mail + + - Split the interfaces and base classes into different packages + + + + \ No newline at end of file diff --git a/src/Skyhop.Mail.Abstractions/IMailDispatcher.cs b/src/Skyhop.Mail.Abstractions/IMailDispatcher.cs new file mode 100644 index 0000000..593b21b --- /dev/null +++ b/src/Skyhop.Mail.Abstractions/IMailDispatcher.cs @@ -0,0 +1,40 @@ +using MimeKit; +using System; +using System.Threading.Tasks; + +namespace Skyhop.Mail.Abstractions +{ + /// + /// Interface to a class used to generate and send emails + /// + public interface IMailDispatcher + { + /// + /// Sends the email + /// + /// The type of the model carrying the payload of the mail. + /// The message payload + /// The addresses to which the mail must be sent + /// The addresses to which the mail must be cc'ed. + /// The addresses to which the mail must be bcc'ed. + /// The addresses from which the mail is sent, can be null. + /// An awaitable which represents this method call. + public Task SendMail( + T data, + MailboxAddress[] to, + MailboxAddress[]? cc = default, + MailboxAddress[]? bcc = default, + MailboxAddress? from = default) where T : MailBase; + + /// + /// Sends the email + /// + /// The type of the model carrying the payload of the mail. + /// The message payload + /// An async action that can be used to set the different properties on the . The To and From properties must be set. + /// An awaitable which represents this method call. + public Task SendMail( + T data, Func senderTransformation) + where T : MailBase; + } +} diff --git a/src/Skyhop.Mail/Abstractions/IMailSender.cs b/src/Skyhop.Mail.Abstractions/IMailSender.cs similarity index 100% rename from src/Skyhop.Mail/Abstractions/IMailSender.cs rename to src/Skyhop.Mail.Abstractions/IMailSender.cs diff --git a/src/Skyhop.Mail/Abstractions/IMessageContent.cs b/src/Skyhop.Mail.Abstractions/IMessageContent.cs similarity index 100% rename from src/Skyhop.Mail/Abstractions/IMessageContent.cs rename to src/Skyhop.Mail.Abstractions/IMessageContent.cs diff --git a/src/Skyhop.Mail/Abstractions/IMessageSenderInfo.cs b/src/Skyhop.Mail.Abstractions/IMessageSenderInfo.cs similarity index 100% rename from src/Skyhop.Mail/Abstractions/IMessageSenderInfo.cs rename to src/Skyhop.Mail.Abstractions/IMessageSenderInfo.cs diff --git a/src/Skyhop.Mail/Abstractions/IModelIdentifierLister.cs b/src/Skyhop.Mail.Abstractions/IModelIdentifierLister.cs similarity index 100% rename from src/Skyhop.Mail/Abstractions/IModelIdentifierLister.cs rename to src/Skyhop.Mail.Abstractions/IModelIdentifierLister.cs diff --git a/src/Skyhop.Mail/MailBase.cs b/src/Skyhop.Mail.Abstractions/MailBase.cs similarity index 94% rename from src/Skyhop.Mail/MailBase.cs rename to src/Skyhop.Mail.Abstractions/MailBase.cs index 4b333d5..c4dc4f0 100644 --- a/src/Skyhop.Mail/MailBase.cs +++ b/src/Skyhop.Mail.Abstractions/MailBase.cs @@ -6,7 +6,7 @@ namespace Skyhop.Mail { /// - /// Base class for all view-models for the views + /// Base class for all view-models for the views /// public class MailBase { @@ -61,7 +61,7 @@ public AttachmentCollection LinkedResources /// /// The body builder used for the , , Html body and text body of the message. /// - protected internal BodyBuilder BodyBuilder { get; } + public BodyBuilder BodyBuilder { get; } /// /// A transform that can be used to update message headers and/or content before sending the message. diff --git a/src/Skyhop.Mail.Abstractions/PackageDetails.props b/src/Skyhop.Mail.Abstractions/PackageDetails.props new file mode 100644 index 0000000..83451b5 --- /dev/null +++ b/src/Skyhop.Mail.Abstractions/PackageDetails.props @@ -0,0 +1,12 @@ + + + + + Skyhop.Mail.Abstractions + $(Title) + + - Split the interfaces and base classes into different packages + + + + \ No newline at end of file diff --git a/src/Skyhop.Mail.Abstractions/Skyhop.Mail.Abstractions.csproj b/src/Skyhop.Mail.Abstractions/Skyhop.Mail.Abstractions.csproj new file mode 100644 index 0000000..a1b48ae --- /dev/null +++ b/src/Skyhop.Mail.Abstractions/Skyhop.Mail.Abstractions.csproj @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/Skyhop.Mail/Extensions/IServiceCollectionExtensions.cs b/src/Skyhop.Mail/Extensions/IServiceCollectionExtensions.cs index 67cf26a..b250c24 100644 --- a/src/Skyhop.Mail/Extensions/IServiceCollectionExtensions.cs +++ b/src/Skyhop.Mail/Extensions/IServiceCollectionExtensions.cs @@ -26,7 +26,7 @@ public static IServiceCollection AddMailDispatcher(this IServiceCollection servi // Renderer + internal dependencies serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); - serviceCollection.AddSingleton(); + serviceCollection.AddSingleton(); serviceCollection.Configure(mailDispatcherOptionsBuilder ?? (_ => { } )); // Try add if not already added needed Razor dependencies diff --git a/src/Skyhop.Mail/MailDispatcher.cs b/src/Skyhop.Mail/MailDispatcher.cs index ed725cc..6a34dfb 100644 --- a/src/Skyhop.Mail/MailDispatcher.cs +++ b/src/Skyhop.Mail/MailDispatcher.cs @@ -11,10 +11,8 @@ namespace Skyhop.Mail { - /// - /// Class used to generate and send emails - /// - public class MailDispatcher + /// + public class MailDispatcher : IMailDispatcher { private readonly RazorViewToStringRenderer _renderer; private readonly MailDispatcherOptions _options; @@ -33,16 +31,7 @@ public MailDispatcher(RazorViewToStringRenderer renderer, IOptions - /// Sends the email - /// - /// The type of the model carrying the payload of the mail. - /// The message payload - /// The addresses to which the mail must be sent - /// The addresses to which the mail must be cc'ed. - /// The addresses to which the mail must be bcc'ed. - /// The addresses from which the mail is sent, can be null, but then a DefaultFromAddress in must be set. - /// An awaitable which represents this method call. + /// public Task SendMail( T data, MailboxAddress[] to, @@ -69,13 +58,7 @@ public Task SendMail( return SendMail(data, senderTransform); } - /// - /// Sends the email - /// - /// The type of the model carrying the payload of the mail. - /// The message payload - /// An async action that can be used to set the different properties on the . The To and From properties must be set. - /// An awaitable which represents this method call. + /// public async Task SendMail(T data, Func senderTransformation) where T : MailBase { diff --git a/src/Skyhop.Mail/PackageDetails.props b/src/Skyhop.Mail/PackageDetails.props index de9e2b6..2b1aa68 100644 --- a/src/Skyhop.Mail/PackageDetails.props +++ b/src/Skyhop.Mail/PackageDetails.props @@ -1,27 +1,11 @@ - - true - true - - - - 3.0.0-rc4 - 0.0.1 - $(PackageVersion) - - true - Apache-2.0 - mail razor Skyhop.Mail $(Title) A library smoothing email generation from .NET code, by enforcing a strong boundary between the template, and code rendering the template. - https://github.com/skyhop/Mail - https://github.com/skyhop/Mail - - Added transformations to edit the message content and senderinfo + - Split the interfaces and base classes into different packages - \ No newline at end of file diff --git a/src/Skyhop.Mail/Skyhop.Mail.csproj b/src/Skyhop.Mail/Skyhop.Mail.csproj index 56aa5e3..b0c8023 100644 --- a/src/Skyhop.Mail/Skyhop.Mail.csproj +++ b/src/Skyhop.Mail/Skyhop.Mail.csproj @@ -1,12 +1,24 @@ + - + + + + + + + + + + + +