/// <inheritdoc /> public AzureTableStorageClient(TableStorageConfig config) : base(config) { var account = CloudStorageAccount.Parse(config.ConnectionString); var cloudTableClient = account.CreateCloudTableClient(); _cloudTable = cloudTableClient.GetTableReference(config.TableName); }
/// <summary> /// Initializes a new instance of the class. /// </summary> /// <param name="config">Configuration to access the Table Storage. /// </param> /// <exception cref="ArgumentNullException">If config is null. /// </exception> /// <exception cref="PropNullOrEmptyException">If ConnectionString or /// TableName are null or empty.</exception> /// <exception cref="FormatException">If ConnectionString or TableName /// have an invalid format.</exception> /// <exception cref="ArgumentException">If TableName is a reserved /// table name.</exception> public TableStorageClient(TableStorageConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } if (string.IsNullOrEmpty(config.ConnectionString)) { throw new PropNullOrEmptyException(nameof(config.ConnectionString)); } if (string.IsNullOrEmpty(config.TableName)) { throw new PropNullOrEmptyException(nameof(config.TableName)); } var isValidConnectionString = CloudStorageAccount.TryParse( config.ConnectionString, out _); if (!isValidConnectionString) { throw new FormatException( UtilResources.Get("InvalidConnectionString")); } if (!config.TableName.IsValidTableName()) { throw new FormatException( UtilResources.Get("InvalidTableName", config.TableName)); } if (ReservedTableNames.Contains(config.TableName)) { throw new ArgumentException( UtilResources.Get("TableStorageReservedName", config.TableName)); } Config = config; }
/// <inheritdoc /> public MockTableStorageClient(TableStorageConfig config) : base(config) { }
/// <summary> /// Creates a new ITableStorageClient instance based on the /// passed-in provider. /// </summary> /// <typeparam name="TElement">The type of table entity.</typeparam> /// <param name="config">Configuration to access the Table Storage. /// </param> /// <param name="provider">Defines the provider used to build the /// instance. By default it is set to Azure Table Storage.</param> /// <returns>ITableStorageClient instance based on the passed-in /// provider.</returns> public static ITableStorageClient <TElement> Create <TElement>( TableStorageConfig config, TableStorageProvider provider = TableStorageProvider.Azure) where TElement : ITableEntity, new() => provider switch {