| | 1 | | namespace Configuration.Helper; |
| | 2 | |
|
| | 3 | | /// <summary>Base class for Folder Information implementations.</summary> |
| | 4 | | public abstract class FolderInfoBase : IFolderInfo |
| | 5 | | { |
| | 6 | | #region IFolderInfo Implementation |
| | 7 | |
|
| | 8 | | #region Properties |
| | 9 | |
|
| | 10 | | /// <inheritdoc /> |
| 43 | 11 | | public string Location { get; protected set; } |
| | 12 | |
|
| | 13 | | /// <inheritdoc /> |
| 21 | 14 | | public virtual bool Exists { get; protected set; } |
| | 15 | |
|
| | 16 | | /// <inheritdoc /> |
| 21 | 17 | | public IOHelper.PathType Source { get; protected set; } |
| | 18 | |
|
| | 19 | | /// <inheritdoc /> |
| 121 | 20 | | public SortedList<string, string> FileList { get; } |
| | 21 | |
|
| | 22 | | /// <inheritdoc /> |
| 22 | 23 | | public SortedList<string, IFolderInfo> FolderList { get; } |
| | 24 | |
|
| | 25 | | #endregion |
| | 26 | |
|
| | 27 | | #region Methods |
| | 28 | |
|
| | 29 | | /// <inheritdoc /> |
| | 30 | | public string[] SortFileList() |
| 3 | 31 | | { |
| 3 | 32 | | if( FileList.Count > 0 ) |
| 1 | 33 | | { |
| 1 | 34 | | string[] retValue = FileList.Keys.ToArray(); |
| 1 | 35 | | Array.Sort( retValue, new AlphanumComparator() ); |
| 1 | 36 | | return retValue; |
| | 37 | | } |
| | 38 | |
|
| 2 | 39 | | return Array.Empty<string>(); |
| 3 | 40 | | } |
| | 41 | |
|
| | 42 | | /// <inheritdoc /> |
| | 43 | | public string[] SortFolderList() |
| 3 | 44 | | { |
| 3 | 45 | | if( FolderList.Count > 0 ) |
| 1 | 46 | | { |
| 1 | 47 | | string[] retValue = FolderList.Keys.ToArray(); |
| 1 | 48 | | Array.Sort( retValue, new AlphanumComparator() ); |
| 1 | 49 | | return retValue; |
| | 50 | | } |
| | 51 | |
|
| 2 | 52 | | return Array.Empty<string>(); |
| 3 | 53 | | } |
| | 54 | |
|
| | 55 | | #endregion |
| | 56 | |
|
| | 57 | | #endregion |
| | 58 | |
|
| | 59 | | #region Default Constructor and Variables |
| | 60 | |
|
| | 61 | | /// <summary>Disk folder name separator.</summary> |
| 1 | 62 | | protected static readonly string _separator = Path.DirectorySeparatorChar.ToString(); |
| | 63 | |
|
| | 64 | | /// <summary>Alternate folder name separator.</summary> |
| 1 | 65 | | protected static readonly string _separatorAlt = Path.AltDirectorySeparatorChar.ToString(); |
| | 66 | |
|
| | 67 | | /// <summary>Sorting comparer for the collections.</summary> |
| 1 | 68 | | private static readonly StringComparer _comparer = StringComparer.OrdinalIgnoreCase; |
| | 69 | |
|
| | 70 | | /// <summary>Default constructor.</summary> |
| 22 | 71 | | protected FolderInfoBase() |
| 22 | 72 | | { |
| 22 | 73 | | Location = string.Empty; |
| 22 | 74 | | FileList = new SortedList<string, string>( _comparer ); |
| 22 | 75 | | FolderList = new SortedList<string, IFolderInfo>( _comparer ); |
| 22 | 76 | | } |
| | 77 | |
|
| | 78 | | #endregion |
| | 79 | | } |