Skip to content

Commit 443ac8b

Browse files
committed
Restrict visibility of implementations constructors
The intended usage pattern for the library is to create the implementations using the `TableRepository.Create` or `TablePartition.Create` factory methods. The implementations are public so that if a consumer wants to inherit them and provide different defaults for the constructors, they can do that, but users should not be instantiating the implementations directly. For DI scenarios, the factory method can be used to provide instances, or a such a derived generic class providing default values for the lambdas that are hard to inject (the `Func<T, string>` for partitionKey and rowKey) can be used instead. Fixes #14
1 parent dd7bf5e commit 443ac8b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/TableStorage/TablePartition`1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ partial class TablePartition<T> : ITablePartition<T> where T : class
1919
/// </summary>
2020
/// <param name="storageAccount">The storage account to use.</param>
2121
/// <param name="tableName">Optional table name. If no value is provided, <see cref="DefaultTableName"/> will be used.</param>
22-
public TablePartition(CloudStorageAccount storageAccount, string tableName, string partitionKey, Func<T, string> rowKey)
22+
protected internal TablePartition(CloudStorageAccount storageAccount, string tableName, string partitionKey, Func<T, string> rowKey)
2323
{
2424
TableName = tableName ?? TablePartition.GetDefaultTableName<T>();
2525
PartitionKey = partitionKey ?? TablePartition.GetDefaultPartitionKey<T>();

src/TableStorage/TableRepository`1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ partial class TableRepository<T> : ITableRepository<T> where T : class
2828
readonly Func<T, string> rowKey;
2929
readonly AsyncLazy<CloudTable> table;
3030

31-
public TableRepository(CloudStorageAccount storageAccount, string tableName, Func<T, string> partitionKey, Func<T, string> rowKey)
31+
protected internal TableRepository(CloudStorageAccount storageAccount, string tableName, Func<T, string> partitionKey, Func<T, string> rowKey)
3232
{
3333
this.storageAccount = storageAccount;
3434
TableName = tableName ?? TableRepository.GetDefaultTableName<T>();

0 commit comments

Comments
 (0)