using Connected.Data.DataProtection; using Connected.Entities; using Connected.Entities.Storage; using Connected.Middleware; using Connected.ServiceModel.Transactions; namespace Connected.Data.Storage; internal sealed class StorageProvider : IStorageProvider { public StorageProvider(IEntityProtectionService dataProtection, IConnectionProvider connections, ITransactionContext transactions, IMiddlewareService middleware) { DataProtection = dataProtection; Connections = connections; Transactions = transactions; Middleware = middleware; } private IEntityProtectionService DataProtection { get; } private IConnectionProvider Connections { get; } private ITransactionContext Transactions { get; } private IMiddlewareService Middleware { get; } /// /// Opens for reading and writing entities. /// /// Type type of the entity to be used. /// The on which LINQ queries and updates can be performed. public IStorage Open() where TEntity : IEntity { var result = new EntityStorage(DataProtection, Middleware, Connections, Transactions); AsyncUtils.RunSync(result.Initialize); return result; } }