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

namespace CommonHelpers {

//**************************************************************************************************
partial class HXmlConfigurationBase {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <exception cref="InvalidOperationException" />
protected string ProvideErrorMessageWithFile(string message)
{
   return ComposeErrorMessageWithFile( FileFullPath, message );
}

/// <exception cref="InvalidOperationException" />
protected string ProvideErrorMessageWithFile(string messageFmt,params object[] parameters)
{
   return ProvideErrorMessageWithFile( string.Format(messageFmt,parameters) );
}

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

/// <exception cref="InvalidOperationException" />
protected string ProvideErrorMessageWithPath(string message)
{
   return ComposeErrorMessageWithPath( FileFullPath, CurrentElementPath, message );
}

/// <exception cref="InvalidOperationException" />
protected string ProvideErrorMessageWithPath(string messageFmt,params object[] parameters)
{
   return ProvideErrorMessageWithPath( string.Format(messageFmt,parameters) );
}

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

/// <exception cref="InvalidOperationException" />
protected string ProvideErrorMessageWithPathAndAttribute(string attributeName,string message)
{
   return ComposeErrorMessageWithPathAndAttribute(
      FileFullPath, CurrentElementPath, attributeName, message );
}

/// <exception cref="InvalidOperationException" />
protected string ProvideErrorMessageWithPathAndAttribute( string attributeName,
                                                          string messageFmt,
                                                          params object[] parameters )
{
   return ProvideErrorMessageWithPathAndAttribute(
      attributeName, string.Format(messageFmt,parameters) );
}

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

/// <exception cref="InvalidOperationException" />
protected string ProvideErrorMessageWithExplicitPath(string elementPath,string message)
{
   return ComposeErrorMessageWithPath( FileFullPath, elementPath, message );
}

/// <exception cref="InvalidOperationException" />
protected string ProvideErrorMessageWithExplicitPath( string elementPath,
                                                      string messageFmt,
                                                      params object[] parameters )
{
   return ProvideErrorMessageWithExplicitPath( elementPath, string.Format(messageFmt,parameters) );
}

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

/// <exception cref="InvalidOperationException" />
protected string ProvideErrorMessageWithExplicitPathAndAttribute( string elementPath,
                                                                  string attributeName,
                                                                  string message )
{
   return ComposeErrorMessageWithPathAndAttribute(
      FileFullPath, elementPath, attributeName, message );
}

/// <exception cref="InvalidOperationException" />
protected string ProvideErrorMessageWithExplicitPathAndAttribute( string elementPath,
                                                                  string attributeName,
                                                                  string messageFmt,
                                                                  params object[] parameters )
{
   return ProvideErrorMessageWithExplicitPathAndAttribute(
      elementPath, attributeName, string.Format(messageFmt,parameters) );
}

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

protected static string ComposeErrorMessageWithFile([HOptional]string filePath,string message)
{
   return filePath != null ?
      string.Format(
         "{0}\n"+
         Verbose.File+": \"{1}\".",
         message, filePath ) :
      message;
}

protected static string ComposeErrorMessageWithFile( [HOptional] string filePath,
                                                     string messageFmt,
                                                     params object[] parameters )
{
   return ComposeErrorMessageWithFile( filePath, string.Format(messageFmt,parameters) );
}

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

protected static string ComposeErrorMessageWithPath( [HOptional]string filePath,
                                                     string elementPath,
                                                     string message )
{
   return ComposeErrorMessageWithFile( filePath, string.Format(
      "{0}\n"+
      Verbose.Element_path+": \"{1}\".",
      message, elementPath ) );
}

protected static string ComposeErrorMessageWithPath( [HOptional] string filePath,
                                                     string elementPath,
                                                     string messageFmt,
                                                     params object[] parameters )
{
   return ComposeErrorMessageWithPath(
      filePath, elementPath, string.Format(messageFmt,parameters) );
}

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

protected string ComposeErrorMessageWithPathAndAttribute( [HOptional] string filePath,
                                                          string elementPath,
                                                          string attributeName,
                                                          string message )
{
   VerifyCurrentElementSelected();
   return ComposeErrorMessageWithPath( filePath, elementPath, string.Format(
      "{0}\n"+
      Verbose.Attribute+": \"{1}\".",
      message, attributeName ));
}

protected string ComposeErrorMessageWithPathAndAttribute( [HOptional] string filePath,
                                                          string elementPath,
                                                          string attributeName,
                                                          string messageFmt,
                                                          params object[] parameters )
{
   return ComposeErrorMessageWithPathAndAttribute(
      filePath, elementPath, attributeName, string.Format(messageFmt,parameters) );
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HXmlConfigurationBase
//**************************************************************************************************

} // CommonHelpers
