Documentation Coverage Report
Current view: top level - Azure/Cqrs.Azure.BlobStorage/DataStores - TableStorageDataStore.cs Hit Total Coverage
Version: 2.2 Artefacts: 6 6 100.0 %
Date: 2018-08-07 15:04:50

          Line data    Source code
       1             : #region Copyright
       2             : // // -----------------------------------------------------------------------
       3             : // // <copyright company="Chinchilla Software Limited">
       4             : // //   Copyright Chinchilla Software Limited. All rights reserved.
       5             : // // </copyright>
       6             : // // -----------------------------------------------------------------------
       7             : #endregion
       8             : 
       9             : using System;
      10             : using cdmdotnet.Logging;
      11             : using Cqrs.Entities;
      12             : using Microsoft.WindowsAzure.Storage.Table;
      13             : 
      14             : namespace Cqrs.Azure.BlobStorage.DataStores
      15             : {
      16             :         /// <summary>
      17             :         /// A <see cref="TableStorageStore{TData,TCollectionItemData}"/> that uses Azure Storage for storage.
      18             :         /// </summary>
      19             :         /// <typeparam name="TData">The <see cref="Type"/> of <see cref="TableEntity"/> Azure Table Storage will contain.</typeparam>
      20             :         public class TableStorageDataStore<TData>
      21             :                 : TableStorageStore<EntityTableEntity<TData>, TData>
      22             :                 where TData : Entity
      23           1 :         {
      24             :                 /// <summary>
      25             :                 /// Initializes a new instance of the <see cref="BlobStorage"/> class using the specified container.
      26             :                 /// </summary>
      27           1 :                 public TableStorageDataStore(ILogger logger, ITableStorageDataStoreConnectionStringFactory tableStorageDataStoreConnectionStringFactory)
      28             :                         : base(logger)
      29             :                 {
      30             :                         GetContainerName = tableStorageDataStoreConnectionStringFactory.GetTableName<TData>;
      31             :                         IsContainerPublic = () => false;
      32             : 
      33             :                         // ReSharper disable DoNotCallOverridableMethodsInConstructor
      34             :                         Initialise(tableStorageDataStoreConnectionStringFactory);
      35             :                         // ReSharper restore DoNotCallOverridableMethodsInConstructor
      36             :                 }
      37             : 
      38             :                 #region Implementation of IDataStore<TData>
      39             : 
      40             :                 /// <summary>
      41             :                 /// Will mark the <paramref name="data"/> as logically (or soft).
      42             :                 /// </summary>
      43           1 :                 public override void Remove(TData data)
      44             :                 {
      45             :                         data.IsLogicallyDeleted = true;
      46             :                         Update(data);
      47             :                 }
      48             : 
      49             :                 #endregion
      50             : 
      51             :                 #region Overrides of TableStorageStore<TData>
      52             : 
      53             :                 /// <summary>
      54             :                 /// Creates a new instance of <see cref="EntityTableEntity{TData}"/> populating it with the provided <paramref name="data"/>.
      55             :                 /// </summary>
      56             :                 /// <param name="data">The data to store.</param>
      57           1 :                 protected override ITableEntity CreateTableEntity(TData data)
      58             :                 {
      59             :                         return new EntityTableEntity<TData>(data);
      60             :                 }
      61             : 
      62             :                 /// <summary>
      63             :                 /// Gets a <see cref="TableOperation"/> that calls <see cref="TableOperation.Retrieve{TData}(string,string,System.Collections.Generic.List{string})"/>
      64             :                 /// for updating.
      65             :                 /// </summary>
      66             :                 /// <param name="data">The data containing the <see cref="IEntity.Rsn"/> property populated.</param>
      67           1 :                 protected override TableOperation GetUpdatableTableEntity(TData data)
      68             :                 {
      69             :                         return TableOperation.Retrieve<EntityTableEntity<TData>>(data.GetType().FullName, data.Rsn.ToString("N"));
      70             :                 }
      71             : 
      72             :                 /// <summary>
      73             :                 /// Gets a <see cref="TableOperation"/> that calls <see cref="TableOperation.Retrieve{TData}(string,string,System.Collections.Generic.List{string})"/>
      74             :                 /// for updating.
      75             :                 /// </summary>
      76             :                 /// <param name="data">The <see cref="EntityTableEntity{TEntity}"/> containing the <see cref="EntityTableEntity{TEntity}.Entity"/> containing the <see cref="IEntity.Rsn"/> property populated.</param>
      77           1 :                 protected override TableOperation GetUpdatableTableEntity(EntityTableEntity<TData> data)
      78             :                 {
      79             :                         return GetUpdatableTableEntity(data.Entity);
      80             :                 }
      81             : 
      82             :                 #endregion
      83             :         }
      84             : }

Generated by: LCOV version 1.12