//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// CommonHelpers satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Reflection;
using System.Threading.Tasks;

namespace CommonHelpers {

//**************************************************************************************************
[HDbOrmType]
public static class HDbAccessPerformer {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <exception cref="ArgumentNullException" />
public static async Task Do_A( Func<Task> bodyA )
{
   HArgChecking.VerifyNotNull( bodyA );
   using (new HDbQuery()) {
      await HDbQuery.Connect_A().ConfigureAwait(false);
      await bodyA().ConfigureAwait(false); }
}

/// <exception cref="ArgumentNullException" />
public static async Task<R> Do_A<R>( Func<Task<R>> bodyA )
{
   HArgChecking.VerifyNotNull( bodyA );
   using (new HDbQuery()) {
      await HDbQuery.Connect_A().ConfigureAwait(false);
      return await bodyA().ConfigureAwait(false); }
}

//==================================================================================================

/// <exception cref="ArgumentNullException" />
public static async Task Do_A( string procedureName, Func<Task> bodyA )
{
   HArgChecking.VerifyNotNulls( procedureName, bodyA );
   using (new HSP(procedureName)) {
      await HDbQuery.Connect_A().ConfigureAwait(false);
      await bodyA().ConfigureAwait(false); }
}

/// <exception cref="ArgumentNullException" />
public static async Task<R> Do_A<R>( string procedureName, Func<Task<R>> bodyA )
{
   HArgChecking.VerifyNotNulls( procedureName, bodyA );
   using (new HSP(procedureName)) {
      await HDbQuery.Connect_A().ConfigureAwait(false);
      return await bodyA().ConfigureAwait(false); }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HDbAccessPerformer
//**************************************************************************************************

} // CommonHelpers
