-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Write legacy Proffer.Emails code documentation #10
- Loading branch information
1 parent
ae76d4a
commit d541a87
Showing
16 changed files
with
344 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
namespace Proffer.Email.InMemory | ||
namespace Proffer.Email.InMemory | ||
{ | ||
using System.Collections.Generic; | ||
|
||
/// <summary> | ||
/// A repository in memory to hold sent emails through the provider. | ||
/// </summary> | ||
public interface IInMemoryEmailRepository | ||
{ | ||
/// <summary> | ||
/// Gets the emails store. | ||
/// </summary> | ||
IReadOnlyCollection<InMemoryEmail> Store { get;} | ||
|
||
/// <summary> | ||
/// Saves the specified email in the store. | ||
/// </summary> | ||
/// <param name="email">The email.</param> | ||
void Save(InMemoryEmail email); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,55 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Proffer.Email.InMemory | ||
{ | ||
using System.Collections.Generic; | ||
|
||
/// <summary> | ||
/// An object to retain the values of the email that would have been sent. | ||
/// </summary> | ||
public class InMemoryEmail | ||
{ | ||
/// <summary> | ||
/// Gets or sets the subject. | ||
/// </summary> | ||
public string Subject { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the message as plain-text. | ||
/// </summary> | ||
public string MessageText { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the message as HTML. | ||
/// </summary> | ||
public string MessageHtml { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the email recipients. | ||
/// </summary> | ||
public IEmailAddress[] To { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the email recipients. | ||
/// </summary> | ||
public IEmailAddress[] Cc { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the BCC email recipients. | ||
/// </summary> | ||
public IEmailAddress[] Bcc { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the sender email address. | ||
/// </summary> | ||
public IEmailAddress From { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the reply-to email address. | ||
/// </summary> | ||
public IEmailAddress ReplyTo { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the attachments files. | ||
/// </summary> | ||
public IEnumerable<IEmailAttachment> Attachments { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,35 @@ | ||
namespace Proffer.Email.InMemory | ||
namespace Proffer.Email.InMemory | ||
{ | ||
/// <summary> | ||
/// Builds <see cref="InMemoryEmailProvider"/>. | ||
/// </summary> | ||
/// <seealso cref="IEmailProviderType" /> | ||
public class InMemoryEmailProviderType : IEmailProviderType | ||
{ | ||
/// <summary> | ||
/// Gets the name. | ||
/// </summary> | ||
public string Name => "InMemory"; | ||
|
||
private IInMemoryEmailRepository inMemoryEmailRepository; | ||
private readonly IInMemoryEmailRepository inMemoryEmailRepository; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="InMemoryEmailProviderType"/> class. | ||
/// </summary> | ||
/// <param name="inMemoryEmailRepository">The in-memory email repository.</param> | ||
public InMemoryEmailProviderType(IInMemoryEmailRepository inMemoryEmailRepository) | ||
{ | ||
this.inMemoryEmailRepository = inMemoryEmailRepository; | ||
} | ||
|
||
public IEmailProvider BuildProvider(IEmailProviderOptions options) | ||
{ | ||
return new InMemoryEmailProvider(options, this.inMemoryEmailRepository); | ||
} | ||
/// <summary> | ||
/// Builds the provider. | ||
/// </summary> | ||
/// <param name="providerOptions">The provider options.</param> | ||
/// <returns> | ||
/// A new <see cref="IEmailProvider" />. | ||
/// </returns> | ||
public IEmailProvider BuildProvider(IEmailProviderOptions providerOptions) | ||
=> new InMemoryEmailProvider(this.inMemoryEmailRepository); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
namespace Proffer.Email.InMemory | ||
namespace Proffer.Email.InMemory | ||
{ | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
|
||
/// <summary> | ||
/// A repository in memory to hold sent emails through the provider. | ||
/// </summary> | ||
/// <seealso cref="IInMemoryEmailRepository" /> | ||
public class InMemoryEmailRepository : IInMemoryEmailRepository | ||
{ | ||
private List<InMemoryEmail> innerEmailStore = new List<InMemoryEmail>(); | ||
private readonly List<InMemoryEmail> innerEmailStore = new(); | ||
|
||
public IReadOnlyCollection<InMemoryEmail> Store | ||
{ | ||
get | ||
{ | ||
return new ReadOnlyCollection<InMemoryEmail>(innerEmailStore); | ||
} | ||
} | ||
/// <summary> | ||
/// Gets the emails store. | ||
/// </summary> | ||
public IReadOnlyCollection<InMemoryEmail> Store => new ReadOnlyCollection<InMemoryEmail>(this.innerEmailStore); | ||
|
||
public void Save(InMemoryEmail email) | ||
{ | ||
this.innerEmailStore.Add(email); | ||
} | ||
/// <summary> | ||
/// Saves the specified email in the store. | ||
/// </summary> | ||
/// <param name="email">The email.</param> | ||
public void Save(InMemoryEmail email) => this.innerEmailStore.Add(email); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace Proffer.Email.SendGrid | ||
{ | ||
using global::SendGrid.Helpers.Mail; | ||
|
||
/// <summary> | ||
/// <see cref="IEmailAddress"/> extension methods. | ||
/// </summary> | ||
internal static class EmailAddressExtensions | ||
{ | ||
/// <summary> | ||
/// Converts an email address to its equivalent SendGrid model. | ||
/// </summary> | ||
/// <param name="email">The email.</param> | ||
/// <returns>The SendGrid model for the email address.</returns> | ||
internal static EmailAddress ToSendGridEmail(this IEmailAddress email) | ||
{ | ||
return new EmailAddress(email.Email, email.DisplayName); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.