@@ -17,23 +17,37 @@ public sealed class LightningEnvironment : IDisposable
1717 internal nint _handle ;
1818
1919 /// <summary>
20- /// Creates a new instance of LightningEnvironment.
20+ /// Creates a new instance of LightningEnvironment with default configuration .
2121 /// </summary>
2222 /// <param name="path">Directory for storing database files.</param>
23- /// <param name="configuration">Configuration for the environment. If null, default configuration is used.</param>
24- public LightningEnvironment ( string path , EnvironmentConfiguration ? configuration = null )
23+ public LightningEnvironment ( string path )
2524 {
2625 if ( string . IsNullOrWhiteSpace ( path ) )
2726 throw new ArgumentException ( "Invalid directory name" ) ;
2827
29- var config = configuration ?? _config ;
30-
3128 mdb_env_create ( out _handle ) . ThrowOnError ( ) ;
32- config . Configure ( this ) ;
33- _config = config ;
29+ _config . Configure ( this ) ;
3430
3531 Path = path ;
32+ }
3633
34+ /// <summary>
35+ /// Creates a new instance of LightningEnvironment.
36+ /// </summary>
37+ /// <param name="path">Directory for storing database files.</param>
38+ /// <param name="configuration">Configuration for the environment.</param>
39+ public LightningEnvironment ( string path , EnvironmentConfiguration configuration )
40+ {
41+ if ( string . IsNullOrWhiteSpace ( path ) )
42+ throw new ArgumentException ( "Invalid directory name" ) ;
43+ if ( configuration == null )
44+ throw new ArgumentNullException ( nameof ( configuration ) ) ;
45+
46+ mdb_env_create ( out _handle ) . ThrowOnError ( ) ;
47+ configuration . Configure ( this ) ;
48+ _config = configuration ;
49+
50+ Path = path ;
3751 }
3852
3953 /// <summary>
@@ -218,47 +232,52 @@ public void Open(EnvironmentOpenFlags openFlags = EnvironmentOpenFlags.None, Uni
218232 }
219233
220234 /// <summary>
221- /// Create a transaction for use with the environment.
235+ /// Create a top-level transaction for use with the environment.
222236 /// The transaction handle may be discarded using Abort() or Commit().
223237 /// Note:
224238 /// Transactions may not span threads; a transaction must only be used by a single thread. Also, a thread may only have a single transaction.
225239 /// Cursors may not span transactions; each cursor must be opened and closed within a single transaction.
226240 /// </summary>
227- /// <param name="parent">
228- /// If this parameter is non-null, the new transaction will be a nested transaction, with the transaction indicated by parent as its parent.
229- /// Transactions may be nested to any level.
230- /// A parent transaction may not issue any other operations besides BeginTransaction, Abort, or Commit while it has active child transactions.
231- /// </param>
232241 /// <param name="beginFlags">
233242 /// Special options for this transaction.
234243 /// </param>
235244 /// <returns>
236245 /// New LightningTransaction
237246 /// </returns>
238- public LightningTransaction BeginTransaction ( LightningTransaction ? parent = null , TransactionBeginFlags beginFlags = LightningTransaction . DefaultTransactionBeginFlags )
247+ public LightningTransaction BeginTransaction ( TransactionBeginFlags beginFlags = LightningTransaction . DefaultTransactionBeginFlags )
239248 {
240- if ( ! IsOpened )
241- throw new InvalidOperationException ( "Environment must be opened before starting a transaction" ) ;
242-
243- return new LightningTransaction ( this , parent , beginFlags ) ;
249+ return BeginTransactionImpl ( null , beginFlags ) ;
244250 }
245251
246252 /// <summary>
247- /// Create a transaction for use with the environment.
253+ /// Create a nested transaction for use with the environment.
248254 /// The transaction handle may be discarded using Abort() or Commit().
249255 /// Note:
250256 /// Transactions may not span threads; a transaction must only be used by a single thread. Also, a thread may only have a single transaction.
251257 /// Cursors may not span transactions; each cursor must be opened and closed within a single transaction.
252258 /// </summary>
259+ /// <param name="parent">
260+ /// The parent transaction. The new transaction will be a nested transaction.
261+ /// Transactions may be nested to any level.
262+ /// A parent transaction may not issue any other operations besides BeginTransaction, Abort, or Commit while it has active child transactions.
263+ /// </param>
253264 /// <param name="beginFlags">
254265 /// Special options for this transaction.
255266 /// </param>
256267 /// <returns>
257268 /// New LightningTransaction
258269 /// </returns>
259- public LightningTransaction BeginTransaction ( TransactionBeginFlags beginFlags )
270+ public LightningTransaction BeginTransaction ( LightningTransaction parent , TransactionBeginFlags beginFlags = LightningTransaction . DefaultTransactionBeginFlags )
271+ {
272+ return BeginTransactionImpl ( parent , beginFlags ) ;
273+ }
274+
275+ private LightningTransaction BeginTransactionImpl ( LightningTransaction ? parent , TransactionBeginFlags beginFlags )
260276 {
261- return BeginTransaction ( null , beginFlags ) ;
277+ if ( ! IsOpened )
278+ throw new InvalidOperationException ( "Environment must be opened before starting a transaction" ) ;
279+
280+ return new LightningTransaction ( this , parent , beginFlags ) ;
262281 }
263282
264283 /// <summary>
0 commit comments