//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// CommonHelpers satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Runtime.Serialization;

namespace CommonHelpers {

//**************************************************************************************************
/// <summary>
/// </summary>
[Serializable]
public partial class HCmdLineParametersParseException: HException {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public HCmdLineParametersParseException([HOptional] string message)
   :base (AppendMessageComment(message))
{}
/// <exception cref="ArgumentException" />
public HCmdLineParametersParseException([HOptional] string message,int zeroBasedPosition)
   :base (AppendMessageComment(message,zeroBasedPosition))
{}
/// <exception cref="ArgumentException" />
public HCmdLineParametersParseException( [HOptional] string message,
                                         int zeroBasedPosition,
                                         bool isInFullCmdLinePosition )
   :base (AppendMessageComment(message,zeroBasedPosition,isInFullCmdLinePosition))
{}

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

public HCmdLineParametersParseException([HOptional] string message,Exception innerException)
   :base (AppendMessageComment(message),innerException)
{}
/// <exception cref="ArgumentException" />
public HCmdLineParametersParseException( [HOptional] string message,
                                         Exception innerException,
                                         int zeroBasedPosition )
   :base (AppendMessageComment(message,zeroBasedPosition),innerException)
{}
/// <exception cref="ArgumentException" />
public HCmdLineParametersParseException( [HOptional] string message,
                                         [HOptional] Exception innerException,
                                         int zeroBasedPosition, bool isInFullCmdLinePosition )
   :base (AppendMessageComment(message,zeroBasedPosition,isInFullCmdLinePosition),innerException)
{}

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

protected HCmdLineParametersParseException(SerializationInfo info,StreamingContext context)
   :base (info,context) {}

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

static HCmdLineParametersParseException()
{
   CommonHelpers_Plus.Access();
}

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

/// <exception cref="ArgumentException" />
static string AppendMessageComment( string message,
                                    int? zeroBasedPosition = null,
                                    bool isInFullCmdLinePosition = false )
{
   if ( zeroBasedPosition.HasValue && zeroBasedPosition.Value < 0 )
      throw new ArgumentException(
         "Position parameter for \"HCmdLineParametersParseException\" constructor "+
         "can not be negative.", "zeroBasedPosition" );
   if ( message == null ) return null;
   int pos = HNullable.NullAsMinusOne( zeroBasedPosition );
   return HString.FormatAsText
   (
      "{0}{1}",
      message,
      pos >= 0 ?
         HString.FormatAsText(
            "\nCharacter position: #{0} ({1}).",
            pos + 1,
            isInFullCmdLinePosition ?
               "from the start of full command line" :
               "from parameters part of the command line" ) :
         ""
   );
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HCmdLineParametersParseException
//**************************************************************************************************

} // CommonHelpers
