forked from cosullivan/SmtpServer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSmtpSessionContext.cs
More file actions
109 lines (90 loc) · 3.72 KB
/
Copy pathSmtpSessionContext.cs
File metadata and controls
109 lines (90 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections.Generic;
using SmtpServer.IO;
using SmtpServer.Protocol;
namespace SmtpServer
{
internal sealed class SmtpSessionContext : ISessionContext
{
/// <inheritdoc />
public Guid SessionId { get; private set; }
/// <inheritdoc />
public event EventHandler<SmtpCommandEventArgs> CommandExecuting;
/// <inheritdoc />
public event EventHandler<SmtpCommandEventArgs> CommandExecuted;
/// <inheritdoc />
public event EventHandler<SmtpResponseExceptionEventArgs> ResponseException;
/// <inheritdoc />
public event EventHandler<EventArgs> SessionAuthenticated;
/// <summary>
/// Constructor.
/// </summary>
/// <param name="serviceProvider">The service provider instance.</param>
/// <param name="options">The server options.</param>
/// <param name="endpointDefinition">The endpoint definition.</param>
internal SmtpSessionContext(IServiceProvider serviceProvider, ISmtpServerOptions options, IEndpointDefinition endpointDefinition)
{
SessionId = Guid.NewGuid();
ServiceProvider = serviceProvider;
ServerOptions = options;
EndpointDefinition = endpointDefinition;
Transaction = new SmtpMessageTransaction();
Properties = new Dictionary<string, object>();
}
/// <summary>
/// Raise the command executing event.
/// </summary>
/// <param name="command">The command that is executing.</param>
internal void RaiseCommandExecuting(SmtpCommand command)
{
CommandExecuting?.Invoke(this, new SmtpCommandEventArgs(this, command));
}
/// <summary>
/// Raise the command executed event.
/// </summary>
/// <param name="command">The command that was executed.</param>
internal void RaiseCommandExecuted(SmtpCommand command)
{
CommandExecuted?.Invoke(this, new SmtpCommandEventArgs(this, command));
}
/// <summary>
/// Raise the response exception event.
/// </summary>
/// <param name="responseException">The response exception that was raised.</param>
internal void RaiseResponseException(SmtpResponseException responseException)
{
ResponseException?.Invoke(this, new SmtpResponseExceptionEventArgs(this, responseException));
}
/// <summary>
/// Raise the session authenticated event.
/// </summary>
internal void RaiseSessionAuthenticated()
{
SessionAuthenticated?.Invoke(this, EventArgs.Empty);
}
/// <inheritdoc />
public IServiceProvider ServiceProvider { get; }
/// <inheritdoc />
public ISmtpServerOptions ServerOptions { get; }
/// <inheritdoc />
public IEndpointDefinition EndpointDefinition { get; }
/// <inheritdoc />
public ISecurableDuplexPipe Pipe { get; internal set; }
/// <summary>
/// Gets the current transaction.
/// </summary>
public SmtpMessageTransaction Transaction { get; }
/// <inheritdoc />
public AuthenticationContext Authentication { get; internal set; } = AuthenticationContext.Unauthenticated;
/// <summary>
/// Returns the number of athentication attempts.
/// </summary>
public int AuthenticationAttempts { get; internal set; }
/// <summary>
/// Gets a value indicating whether a quit has been requested.
/// </summary>
public bool IsQuitRequested { get; internal set; }
/// <inheritdoc />
public IDictionary<string, object> Properties { get; }
}
}