/// <summary> Name of logging subdirectory.</summary>
privateconststringLOGDIRECTORYTITLE="Log";
/// <summary> Prevents an invalid instance to be created. </summary>
privateLoggingDirectoryManager(){}
publicLoggingDirectoryManager(
Func<string,IList<string>>p_oFileListProvider,
Func<string,bool>p_oDirectoryExistsChecker,
Action<string>p_oDirectoryCreator,
Action<string>p_oFileEraser,
stringp_oLogFilePath,
charp_strDirectorySeparatorChar,
intp_iRetainedFilesCountLimit)
{
m_oFileListProvider=p_oFileListProvider??thrownewArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. File list provider delegate can not be null.");
if(p_oDirectoryExistsChecker==null)
{
thrownewArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. Directory existance checker delegate can not be null.");
}
if(p_oDirectoryCreator==null)
{
thrownewArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. Directory creator delegate can not be null.");
}
m_oFileEraser=p_oFileEraser??thrownewArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. File eraser delegate can not be null.");
if(string.IsNullOrEmpty(p_oLogFilePath))
{
thrownewArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. Log file path can not be null or empty.");
thrownewArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. Directory separtor character can not be null or empty.");
}
if(p_iRetainedFilesCountLimit<1)
{
thrownewArgumentException($"Can not instantiate {nameof(LoggingDirectoryManager)}- object. Count of retained log files is {p_iRetainedFilesCountLimit} but must be equal or larger one.");
l_iIndex>=m_iRetainedFilesCountLimit-1;/* files remaining count must be m_iRetainedFilesCountLimit - 1 because new log file will be added afterwards */