//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// CommonHelpers satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace CommonHelpers {

//**************************************************************************************************
partial class HSqlParam {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <exception cref="ArgumentNullException" />
public static SqlParameter In(string paramName,SqlDbType dbType,object value)
{
   HArgChecking.VerifyNotNulls( paramName, value );
   return new SqlParameter(){
      ParameterName = paramName,
      SqlDbType = dbType,
      Direction = ParameterDirection.Input,
      IsNullable = false,
      Value = value };
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter Out(string paramName,SqlDbType dbType)
{
   HArgChecking.VerifyNotNull( paramName );
   return new SqlParameter(){
      ParameterName = paramName,
      SqlDbType = dbType,
      Direction = ParameterDirection.Output,
      IsNullable = false };
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter InOut(string paramName,SqlDbType dbType,object value)
{
   HArgChecking.VerifyNotNulls( paramName, value );
   return new SqlParameter(){
      ParameterName = paramName,
      SqlDbType = dbType,
      Direction = ParameterDirection.InputOutput,
      IsNullable = false,
      Value = value };
}
public static SqlParameter RetValue(SqlDbType dbType) =>
   new SqlParameter(){
      SqlDbType = dbType,
      Direction = ParameterDirection.ReturnValue,
      IsNullable = false };

//--------------------------------------------------------------------------------------------------

/// <exception cref="ArgumentNullException" />
public static SqlParameter In(string paramName,SqlDbType dbType,int size,object value)
{
   HArgChecking.VerifyNotNull( value );
   return new SqlParameter(){
      ParameterName = paramName,
      SqlDbType = dbType,
      Size = size,
      Direction = ParameterDirection.Input,
      IsNullable = false,
      Value = value };
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter Out(string paramName,SqlDbType dbType,int size)
{
   HArgChecking.VerifyNotNull( paramName );
   return new SqlParameter(){
      ParameterName = paramName,
      SqlDbType = dbType,
      Size = size,
      Direction = ParameterDirection.Output,
      IsNullable = false };
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter InOut(string paramName,SqlDbType dbType,int size,object value)
{
   HArgChecking.VerifyNotNulls( paramName, value );
   return new SqlParameter(){
      ParameterName = paramName,
      SqlDbType = dbType,
      Size = size,
      Direction = ParameterDirection.InputOutput,
      IsNullable = false,
      Value = value };
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter RetValue(SqlDbType dbType,int size) =>
   new SqlParameter(){
      SqlDbType = dbType,
      Size = size,
      Direction = ParameterDirection.ReturnValue,
      IsNullable = false };

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

/// <exception cref="ArgumentNullException" />
public static SqlParameter AddIn( SqlCommand command, string paramName,
                                  SqlDbType dbType, object value )
{
   HArgChecking.VerifyNotNull( command );
   return command.Parameters.Add( In( paramName, dbType, value ) );
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter AddOut(SqlCommand command,string paramName,SqlDbType dbType)
{
   HArgChecking.VerifyNotNull( command );
   return command.Parameters.Add( Out( paramName, dbType ) );
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter AddInOut( SqlCommand command, string paramName,
                                     SqlDbType dbType, object value )
{
   HArgChecking.VerifyNotNull( command );
   return command.Parameters.Add( InOut( paramName, dbType, value ) );
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter AddRetValue(SqlCommand command,SqlDbType dbType)
{
   HArgChecking.VerifyNotNull( command );
   return command.Parameters.Add( RetValue( dbType ) );
}

//--------------------------------------------------------------------------------------------------

/// <exception cref="ArgumentNullException" />
public static SqlParameter AddIn( SqlCommand command, string paramName,
                                  SqlDbType dbType, int size, object value )
{
   HArgChecking.VerifyNotNull( command );
   return command.Parameters.Add( In( paramName, dbType, size, value ) );
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter AddOut(SqlCommand command,string paramName,SqlDbType dbType,int size)
{
   HArgChecking.VerifyNotNull( command );
   return command.Parameters.Add( Out( paramName, dbType, size ) );
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter AddInOut( SqlCommand command, string paramName,
                                     SqlDbType dbType, int size, object value )
{
   HArgChecking.VerifyNotNull( command );
   return command.Parameters.Add( InOut( paramName, dbType, size, value ) );
}
/// <exception cref="ArgumentNullException" />
public static SqlParameter AddRetValue(SqlCommand command,SqlDbType dbType,int size)
{
   HArgChecking.VerifyNotNull( command );
   return command.Parameters.Add( RetValue( dbType, size ) );
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HSqlParam
//**************************************************************************************************

} // CommonHelpers
