@@ -6,113 +6,85 @@ namespace Zetian.Core
66 /// <summary>
77 /// Event arguments for session events
88 /// </summary>
9- public class SessionEventArgs : EventArgs
9+ public class SessionEventArgs ( ISmtpSession session ) : EventArgs
1010 {
11- public SessionEventArgs ( ISmtpSession session )
12- {
13- Session = session ?? throw new ArgumentNullException ( nameof ( session ) ) ;
14- }
15-
1611 /// <summary>
1712 /// Gets the SMTP session
1813 /// </summary>
19- public ISmtpSession Session { get ; }
14+ public ISmtpSession Session { get ; } = session ?? throw new ArgumentNullException ( nameof ( session ) ) ;
2015 }
2116
2217 /// <summary>
2318 /// Event arguments for message events
2419 /// </summary>
25- public class MessageEventArgs : EventArgs
20+ public class MessageEventArgs ( ISmtpMessage message , ISmtpSession session ) : EventArgs
2621 {
27- public MessageEventArgs ( ISmtpMessage message , ISmtpSession session )
28- {
29- Message = message ?? throw new ArgumentNullException ( nameof ( message ) ) ;
30- Session = session ?? throw new ArgumentNullException ( nameof ( session ) ) ;
31- Cancel = false ;
32- Response = SmtpResponse . Ok ;
33- }
34-
3522 /// <summary>
3623 /// Gets the received message
3724 /// </summary>
38- public ISmtpMessage Message { get ; }
25+ public ISmtpMessage Message { get ; } = message ?? throw new ArgumentNullException ( nameof ( message ) ) ;
3926
4027 /// <summary>
4128 /// Gets the session that received the message
4229 /// </summary>
43- public ISmtpSession Session { get ; }
30+ public ISmtpSession Session { get ; } = session ?? throw new ArgumentNullException ( nameof ( session ) ) ;
4431
4532 /// <summary>
4633 /// Gets or sets whether to cancel/reject the message
4734 /// </summary>
48- public bool Cancel { get ; set ; }
35+ public bool Cancel { get ; set ; } = false ;
4936
5037 /// <summary>
5138 /// Gets or sets the response to send to the client
5239 /// </summary>
53- public SmtpResponse Response { get ; set ; }
40+ public SmtpResponse Response { get ; set ; } = SmtpResponse . Ok ;
5441 }
5542
5643 /// <summary>
5744 /// Event arguments for error events
5845 /// </summary>
59- public class ErrorEventArgs : EventArgs
46+ public class ErrorEventArgs ( Exception exception , ISmtpSession ? session = null ) : EventArgs
6047 {
61- public ErrorEventArgs ( Exception exception , ISmtpSession ? session = null )
62- {
63- Exception = exception ?? throw new ArgumentNullException ( nameof ( exception ) ) ;
64- Session = session ;
65- }
66-
6748 /// <summary>
6849 /// Gets the exception that occurred
6950 /// </summary>
70- public Exception Exception { get ; }
51+ public Exception Exception { get ; } = exception ?? throw new ArgumentNullException ( nameof ( exception ) ) ;
7152
7253 /// <summary>
7354 /// Gets the session where the error occurred (if any)
7455 /// </summary>
75- public ISmtpSession ? Session { get ; }
56+ public ISmtpSession ? Session { get ; } = session ;
7657 }
7758
7859 /// <summary>
7960 /// Event arguments for authentication events
8061 /// </summary>
81- public class AuthenticationEventArgs : EventArgs
62+ public class AuthenticationEventArgs ( string mechanism , string ? username , string ? password , ISmtpSession session ) : EventArgs
8263 {
83- public AuthenticationEventArgs ( string mechanism , string ? username , string ? password , ISmtpSession session )
84- {
85- Mechanism = mechanism ?? throw new ArgumentNullException ( nameof ( mechanism ) ) ;
86- Username = username ;
87- Password = password ;
88- Session = session ?? throw new ArgumentNullException ( nameof ( session ) ) ;
89- IsAuthenticated = false ;
90- }
91-
9264 /// <summary>
9365 /// Gets the authentication mechanism
9466 /// </summary>
95- public string Mechanism { get ; }
67+ public string Mechanism { get ; } = mechanism ?? throw new ArgumentNullException ( nameof ( mechanism ) ) ;
9668
9769 /// <summary>
9870 /// Gets the username
9971 /// </summary>
100- public string ? Username { get ; }
72+ public string ? Username { get ; } = username ;
10173
10274 /// <summary>
10375 /// Gets the password
10476 /// </summary>
105- public string ? Password { get ; }
77+ public string ? Password { get ; } = password ;
10678
10779 /// <summary>
10880 /// Gets the session
10981 /// </summary>
110- public ISmtpSession Session { get ; }
82+ public ISmtpSession Session { get ; } = session ?? throw new ArgumentNullException ( nameof ( session ) ) ;
11183
11284 /// <summary>
11385 /// Gets or sets whether the authentication succeeded
11486 /// </summary>
115- public bool IsAuthenticated { get ; set ; }
87+ public bool IsAuthenticated { get ; set ; } = false ;
11688
11789 /// <summary>
11890 /// Gets or sets the authenticated identity
0 commit comments