<commit_before>using System.Data.SqlClient;
using DotJEM.Json.Storage.Configuration;

namespace DotJEM.Json.Storage
{
    public interface IStorageContext
    {
        IStorageConfigurator Configure { get; }
        IStorageArea Area(string name = "content");
    }

    public class SqlServerStorageContext : IStorageContext
    {
        private readonly string connectionString;

        public IStorageConfigurator Configure { get { return Configuration; } }
        public IBsonSerializer Serializer { get; private set; }
        
        internal StorageConfiguration Configuration { get; private set; }

        public SqlServerStorageContext(string connectionString)
        {
            Serializer = new BsonSerializer();
            Configuration = new StorageConfiguration();

            this.connectionString = connectionString;
        }

        public IStorageArea Area(string name = "content")
        {
            //TODO: Cache configurations?
            return new SqlServerStorageArea(this, name);
        }

        internal SqlConnection Connection()<commit_msg>Cashing of storage areas and release. (Implement a dispose pattern later?)<commit_after>using System.Collections.Generic;
using System.Data.SqlClient;
using DotJEM.Json.Storage.Configuration;

namespace DotJEM.Json.Storage
{
    public interface IStorageContext
    {
        IStorageConfigurator Configure { get; }
        IStorageArea Area(string name = "content");
        bool Release(string name = "content");
    }

    public class SqlServerStorageContext : IStorageContext
    {
        private readonly string connectionString;
        private readonly Dictionary<string, IStorageArea> openAreas = new Dictionary<string, IStorageArea>(); 

        public IStorageConfigurator Configure { get { return Configuration; } }
        public IBsonSerializer Serializer { get; private set; }
        
        internal StorageConfiguration Configuration { get; private set; }



        public SqlServerStorageContext(string connectionString)
        {
            Serializer = new BsonSerializer();
            Configuration = new StorageConfiguration();

            this.connectionString = connectionString;
        }

        public IStorageArea Area(string name = "content")
        {
            if (!openAreas.ContainsKey(name))
                return openAreas[name] = new SqlServerStorageArea(this, name);
            return openAreas[name];
        }

        public bool Release(string name = "content")
        {
            return openAreas.Remove(name);
        }

        internal SqlConnection Connection()
{'fraction_non_alphanumeric': 0.07126436781609195, 'fraction_numerical': 0.0, 'mean_word_length': 2.6415620641562065, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5380148', 'n_tokens_mistral': 622, 'n_tokens_neox': 596, 'n_words': 168}