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

namespace CommonHelpers {

//**************************************************************************************************
[HDbOrmType]
public class HSPResultOut<TOutData,TListItem>
: HSPCommandResultOut<TOutData>
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 TOutData Output;
// [HStrictResult] public string OutMessageNN;
// VerifyAvailable();

   public bool HasList => _List_ != null;
   /// <exception cref="InvalidOperationException" />
   [HStrictResult]
   public List<TListItem> List =>
      GetList() ?? throw HSPResultError.OutputListUnavailable;

   public HSPResultOut()
   {}
   public HSPResultOut( HSPResultParameters resultParams,
                        [HOptional] TOutData? output,
                        [HOptional] List<TListItem>? list )
   : base( resultParams, output ) =>
      _List_ = list;
   public HSPResultOut( HSPResultOutN<TOutData,TListItem> result )
   : base( result ) =>
      _List_ = result.List;

   /// <exception cref="InvalidOperationException" />
   [HOptionalResult]
   public List<TListItem>? GetList()
   {
      VerifyAvailable();
      return _List_;
   }

   readonly List<TListItem>? _List_;

} // HSPResultOut<TOutData,TListItem>
//**************************************************************************************************

//**************************************************************************************************
[HDbOrmType]
public class HSPResultOutRV<TOutData,TListItem>
: HSPCommandResultOutRV<TOutData>
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 TOutData Output;
// [HStrictResult] public string OutMessageNN;
// VerifyAvailable();

   public bool HasList => _List_ != null;
   /// <exception cref="InvalidOperationException" />
   [HStrictResult]
   public List<TListItem> List =>
      GetList() ?? throw HSPResultError.OutputListUnavailable;

   public HSPResultOutRV()
   {}
   public HSPResultOutRV( HSPResultParameters resultParams,
                          [HOptional] TOutData? output,
                          [HOptional] List<TListItem>? list )
   : base( resultParams, output ) =>
      _List_ = list;
   public HSPResultOutRV( HSPResultOutRVN<TOutData,TListItem> result )
   : base( result ) =>
      _List_ = result.List;

   /// <exception cref="InvalidOperationException" />
   [HOptionalResult]
   public List<TListItem>? GetList()
   {
      VerifyAvailable();
      return _List_;
   }

   readonly List<TListItem>? _List_;

} // HSPResultOutRV<TOutData,TListItem>
//**************************************************************************************************

} // CommonHelpers
