public string CalcStats()
{
var res = new StringBuilder();
res.AppendFormat("Files {0} FileInfos {1} FileGeneration {2} Cached items {3}{4}", _fileCollection.GetCount(),
_fileInfos.Count, _fileGeneration, _cache.Count, Environment.NewLine);
var totalSize = 0UL;
var totalControledSize = 0UL;
foreach (var fileCollectionFile in _fileCollection.Enumerate())
{
IFileInfo fileInfo;
_fileInfos.TryGetValue(fileCollectionFile.Index, out fileInfo);
var size = fileCollectionFile.GetSize();
totalSize += size;
if (fileInfo == null)
{
res.AppendFormat("{0} Size: {1} Unknown to cache{2}", fileCollectionFile.Index,
size, Environment.NewLine);
}
else
{
res.AppendFormat("{0} Size: {1} Type: {2} {3}", fileCollectionFile.Index,
size, fileInfo.FileType, Environment.NewLine);
totalControledSize += size;
}
}
res.AppendFormat("TotalSize {0} TotalControledSize {1} Limit {2}{3}", totalSize, totalControledSize,
_cacheCapacity, Environment.NewLine);
Debug.Assert(totalControledSize <= (ulong)_cacheCapacity);
return res.ToString();
}