internal void SaveCollection <T>(IDocumentCollection <T> collection) where T : class
        {
            var serializer = GetSerializer(collection.Configuration);
            var items      = collection.Find(arg => true).ToList();

            if (IsMultiFile(collection.Configuration))
            {
                foreach (var item in items)
                {
                    var fileContent    = serializer.Serialize(new[] { item }, collection.Configuration.DocumentType);
                    var collectionDir  = collection.Configuration.SourceFile;
                    var key            = collection.GetKey(item);
                    var serializerInfo = serializer.GetInfo();
                    var fileName       = Path.Combine(collectionDir, key + serializerInfo.Extension);
                    _configuration.StorageEngine.WriteFile(fileName, fileContent);
                }
            }
            else
            {
                var fileContent = serializer.Serialize(items, collection.Configuration.DocumentType);
                _configuration.StorageEngine.WriteFile(collection.Configuration.SourceFile, fileContent);
            }

            collection.HasChanges = false;
        }