@@ -165,11 +165,11 @@ public ConfigEntityPropertyEventArgs(Type entityType, PropertyInfo property)
165165 public class CurdBeforeEventArgs : EventArgs
166166 {
167167 public CurdBeforeEventArgs ( Type entityType , TableInfo table , CurdType curdType , string sql , DbParameter [ ] dbParms ) :
168- this ( Guid . NewGuid ( ) , new Stopwatch ( ) , entityType , table , curdType , sql , dbParms )
168+ this ( Guid . NewGuid ( ) , new Stopwatch ( ) , entityType , table , curdType , sql , dbParms , new Dictionary < string , object > ( ) )
169169 {
170170 this . Stopwatch . Start ( ) ;
171171 }
172- protected CurdBeforeEventArgs ( Guid identifier , Stopwatch stopwatch , Type entityType , TableInfo table , CurdType curdType , string sql , DbParameter [ ] dbParms )
172+ protected CurdBeforeEventArgs ( Guid identifier , Stopwatch stopwatch , Type entityType , TableInfo table , CurdType curdType , string sql , DbParameter [ ] dbParms , Dictionary < string , object > states )
173173 {
174174 this . Identifier = identifier ;
175175 this . Stopwatch = stopwatch ;
@@ -178,6 +178,7 @@ protected CurdBeforeEventArgs(Guid identifier, Stopwatch stopwatch, Type entityT
178178 this . CurdType = curdType ;
179179 this . Sql = sql ;
180180 this . DbParms = dbParms ;
181+ this . States = states ;
181182 }
182183
183184 /// <summary>
@@ -206,12 +207,16 @@ protected CurdBeforeEventArgs(Guid identifier, Stopwatch stopwatch, Type entityT
206207 /// 参数化命令
207208 /// </summary>
208209 public DbParameter [ ] DbParms { get ; }
210+ /// <summary>
211+ /// 状态数据,可与 CurdAfter 共享
212+ /// </summary>
213+ public Dictionary < string , object > States { get ; protected set ; }
209214 }
210215 public enum CurdType { Select , Delete , Update , Insert , InsertOrUpdate }
211216 public class CurdAfterEventArgs : CurdBeforeEventArgs
212217 {
213218 public CurdAfterEventArgs ( CurdBeforeEventArgs before , Exception exception , object executeResult ) :
214- base ( before . Identifier , before . StopwatchInternal , before . EntityType , before . Table , before . CurdType , before . Sql , before . DbParms )
219+ base ( before . Identifier , before . StopwatchInternal , before . EntityType , before . Table , before . CurdType , before . Sql , before . DbParms , before . States )
215220 {
216221 this . Exception = exception ;
217222 this . ExecuteResult = executeResult ;
@@ -241,15 +246,16 @@ public CurdAfterEventArgs(CurdBeforeEventArgs before, Exception exception, objec
241246 public class SyncStructureBeforeEventArgs : EventArgs
242247 {
243248 public SyncStructureBeforeEventArgs ( Type [ ] entityTypes ) :
244- this ( Guid . NewGuid ( ) , new Stopwatch ( ) , entityTypes )
249+ this ( Guid . NewGuid ( ) , new Stopwatch ( ) , entityTypes , new Dictionary < string , object > ( ) )
245250 {
246251 this . Stopwatch . Start ( ) ;
247252 }
248- protected SyncStructureBeforeEventArgs ( Guid identifier , Stopwatch stopwatch , Type [ ] entityTypes )
253+ protected SyncStructureBeforeEventArgs ( Guid identifier , Stopwatch stopwatch , Type [ ] entityTypes , Dictionary < string , object > states )
249254 {
250255 this . Identifier = identifier ;
251256 this . Stopwatch = stopwatch ;
252257 this . EntityTypes = entityTypes ;
258+ this . States = states ;
253259 }
254260
255261 /// <summary>
@@ -262,11 +268,15 @@ protected SyncStructureBeforeEventArgs(Guid identifier, Stopwatch stopwatch, Typ
262268 /// 实体类型
263269 /// </summary>
264270 public Type [ ] EntityTypes { get ; }
271+ /// <summary>
272+ /// 状态数据,可与 SyncStructureAfter 共享
273+ /// </summary>
274+ public Dictionary < string , object > States { get ; protected set ; }
265275 }
266276 public class SyncStructureAfterEventArgs : SyncStructureBeforeEventArgs
267277 {
268278 public SyncStructureAfterEventArgs ( SyncStructureBeforeEventArgs before , string sql , Exception exception ) :
269- base ( before . Identifier , before . StopwatchInternal , before . EntityTypes )
279+ base ( before . Identifier , before . StopwatchInternal , before . EntityTypes , before . States )
270280 {
271281 this . Sql = sql ;
272282 this . Exception = exception ;
@@ -381,15 +391,16 @@ public object Value
381391 public class CommandBeforeEventArgs : EventArgs
382392 {
383393 public CommandBeforeEventArgs ( DbCommand command ) :
384- this ( Guid . NewGuid ( ) , new Stopwatch ( ) , command )
394+ this ( Guid . NewGuid ( ) , new Stopwatch ( ) , command , new Dictionary < string , object > ( ) )
385395 {
386396 this . Stopwatch . Start ( ) ;
387397 }
388- protected CommandBeforeEventArgs ( Guid identifier , Stopwatch stopwatch , DbCommand command )
398+ protected CommandBeforeEventArgs ( Guid identifier , Stopwatch stopwatch , DbCommand command , Dictionary < string , object > states )
389399 {
390400 this . Identifier = identifier ;
391401 this . Stopwatch = stopwatch ;
392402 this . Command = command ;
403+ this . States = states ;
393404 }
394405
395406 /// <summary>
@@ -399,11 +410,15 @@ protected CommandBeforeEventArgs(Guid identifier, Stopwatch stopwatch, DbCommand
399410 protected Stopwatch Stopwatch { get ; }
400411 internal Stopwatch StopwatchInternal => Stopwatch ;
401412 public DbCommand Command { get ; }
413+ /// <summary>
414+ /// 状态数据,可与 CommandAfter 共享
415+ /// </summary>
416+ public Dictionary < string , object > States { get ; protected set ; }
402417 }
403418 public class CommandAfterEventArgs : CommandBeforeEventArgs
404419 {
405420 public CommandAfterEventArgs ( CommandBeforeEventArgs before , Exception exception , string log ) :
406- base ( before . Identifier , before . StopwatchInternal , before . Command )
421+ base ( before . Identifier , before . StopwatchInternal , before . Command , before . States )
407422 {
408423 this . Exception = exception ;
409424 this . Log = log ;
@@ -433,16 +448,17 @@ public CommandAfterEventArgs(CommandBeforeEventArgs before, Exception exception,
433448 public class TraceBeforeEventArgs : EventArgs
434449 {
435450 public TraceBeforeEventArgs ( string operation , object value ) :
436- this ( Guid . NewGuid ( ) , new Stopwatch ( ) , operation , value )
451+ this ( Guid . NewGuid ( ) , new Stopwatch ( ) , operation , value , new Dictionary < string , object > ( ) )
437452 {
438453 this . Stopwatch . Start ( ) ;
439454 }
440- protected TraceBeforeEventArgs ( Guid identifier , Stopwatch stopwatch , string operation , object value )
455+ protected TraceBeforeEventArgs ( Guid identifier , Stopwatch stopwatch , string operation , object value , Dictionary < string , object > states )
441456 {
442457 this . Identifier = identifier ;
443458 this . Stopwatch = stopwatch ;
444459 this . Operation = operation ;
445460 this . Value = value ;
461+ this . States = states ;
446462 }
447463
448464 /// <summary>
@@ -453,11 +469,15 @@ protected TraceBeforeEventArgs(Guid identifier, Stopwatch stopwatch, string oper
453469 internal Stopwatch StopwatchInternal => Stopwatch ;
454470 public string Operation { get ; }
455471 public object Value { get ; }
472+ /// <summary>
473+ /// 状态数据,可与 TraceAfter 共享
474+ /// </summary>
475+ public Dictionary < string , object > States { get ; protected set ; }
456476 }
457477 public class TraceAfterEventArgs : TraceBeforeEventArgs
458478 {
459479 public TraceAfterEventArgs ( TraceBeforeEventArgs before , string remark , Exception exception ) :
460- base ( before . Identifier , before . StopwatchInternal , before . Operation , before . Value )
480+ base ( before . Identifier , before . StopwatchInternal , before . Operation , before . Value , before . States )
461481 {
462482 this . Remark = remark ;
463483 this . Exception = exception ;
0 commit comments