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

namespace CommonHelpers {

//**************************************************************************************************
[HDbOrmType]
public class HSPCommandResultOut<TOutData>: HSPCommandResult
where TOutData: class
{
// public SPResultStateForm StateForm;
// public bool IsAvailable;
// public bool Success;
// [HOptionalValue] public Guid Status;
// [HOptionalValue] public string? OutMessage;
// [HNotNull] public string ErrorMessage;
// [HStrictResult] public string OutMessageNN;
// VerifyAvailable();

   public bool HasOutput => _Output_ != null;
   /// <exception cref="InvalidOperationException" />
   [HStrictResult]
   public TOutData Output =>
      GetOutput() ?? throw HSPResultError.OutputDataUnavailable;

   public HSPCommandResultOut()
   {}
   public HSPCommandResultOut( HSPResultParameters resultParams,
                               [HOptional] TOutData? output )
   : base( resultParams ) =>
      _Output_ = output;
   public HSPCommandResultOut( HSPCommandResultOutN<TOutData> result )
   : base( result.Success, result.Status, result.OutMessage ) =>
      _Output_ = result.Output;

   /// <exception cref="InvalidOperationException" />
   [HOptionalResult]
   public TOutData? GetOutput()
   {
      VerifyAvailable();
      return _Output_;
   }

   readonly TOutData? _Output_;

} // HSPCommandResultOut<TOutData>
//**************************************************************************************************

//**************************************************************************************************
[HDbOrmType]
public class HSPCommandResultOutRV<TOutData>: HSPCommandResultRV
where TOutData: class
{
// public SPResultStateForm StateForm;
// public bool IsAvailable;
// public int RetValue;
// [HOptionalValue] public Guid Status;
// [HOptionalValue] public string? OutMessage;
// [HNotNull] public string OutMessageAsError;
// [HStrictResult] public string OutMessageNN;
// VerifyAvailable();

   public bool HasOutput => _Output_ != null;
   /// <exception cref="InvalidOperationException" />
   [HStrictResult]
   public TOutData Output =>
      GetOutput() ?? throw HSPResultError.OutputDataUnavailable;

   public HSPCommandResultOutRV()
   {}
   public HSPCommandResultOutRV( HSPResultParameters resultParams,
                                 [HOptional] TOutData? output )
   : base( resultParams ) =>
      _Output_ =  output;
   public HSPCommandResultOutRV( HSPCommandResultOutRVN<TOutData> result )
   : base( result.RetValue, result.Status, result.OutMessage ) =>
      _Output_ = result.Output;

   /// <exception cref="InvalidOperationException" />
   [HOptionalResult]
   public TOutData? GetOutput()
   {
      VerifyAvailable();
      return _Output_;
   }

   readonly TOutData? _Output_;

} // HSPCommandResultOutRV<TOutData>
//**************************************************************************************************

} // CommonHelpers
