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

namespace CommonHelpers {

//**************************************************************************************************
[HDbOrmType]
public class HSPResultN<TListItem>: HSPCommandResult
{
// 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 HasList => _List_ != null;
   /// <exception cref="InvalidOperationException" />
   [HOptionalValue]
   public List<TListItem>? List
   {
      get {
         VerifyAvailable();
         return _List_;
      }
   }
   /// <exception cref="InvalidOperationException" />
   [HStrictResult]
   public List<TListItem> ListNN =>
      List ?? throw HSPResultError.OutputListUnavailable;

   public HSPResultN()
   {}
   public HSPResultN( HSPResultParameters resultParams,
                      [HOptional] List<TListItem>? list )
   : base( resultParams ) =>
      _List_ = list;
   public HSPResultN( HSPResult<TListItem> result )
   : base( result.Success, result.Status, result.OutMessage ) =>
      _List_ = result.GetList();

   readonly List<TListItem>? _List_;

} // HSPResultN<TListItem>
//**************************************************************************************************

//**************************************************************************************************
[HDbOrmType]
public class HSPResultRVN<TListItem>: HSPCommandResultRV
{
// 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 HasList => _List_ != null;
   /// <exception cref="InvalidOperationException" />
   [HOptionalValue]
   public List<TListItem>? List
   {
      get {
         VerifyAvailable();
         return _List_;
      }
   }
   /// <exception cref="InvalidOperationException" />
   [HStrictResult]
   public List<TListItem> ListNN =>
      List ?? throw HSPResultError.OutputListUnavailable;

   public HSPResultRVN()
   {}
   public HSPResultRVN( HSPResultParameters resultParams,
                        [HOptional] List<TListItem>? list )
   : base( resultParams ) =>
      _List_ = list;
   public HSPResultRVN( HSPResultRV<TListItem> result )
   : base( result.RetValue, result.Status, result.OutMessage ) =>
      _List_ = result.GetList();

   readonly List<TListItem>? _List_;

} // HSPResultRVN<TListItem>
//**************************************************************************************************

} // CommonHelpers
