11using System ;
22using System . Linq . Expressions ;
3- using Microsoft . Azure . Cosmos . Table ;
3+ using Azure . Data . Tables ;
44using Newtonsoft . Json ;
55using TableStorage . Abstractions . TableEntityConverters ;
66
7- namespace TableStorage . Abstractions . POCO
8- {
7+ namespace TableStorage . Abstractions . POCO ;
8+
99 public class CalculatedKeysConverter < T , TPartitionKey , TRowKey > : IKeysConverter < T , TPartitionKey , TRowKey >
10- where T : new ( )
10+ where T : new ( )
1111 {
12- private readonly KeyMapper < T , TPartitionKey > _partitionMapper ;
13- private readonly KeyMapper < T , TRowKey > _rowMapper ;
12+ private readonly Expression < Func < T , object > > [ ] _ignoredProperties ;
1413 private readonly JsonSerializerSettings _jsonSerializerSettings ;
14+ private readonly KeyMapper < T , TPartitionKey > _partitionMapper ;
1515 private readonly PropertyConverters < T > _propertyConverters ;
16- private readonly Expression < Func < T , object > > [ ] _ignoredProperties ;
16+ private readonly KeyMapper < T , TRowKey > _rowMapper ;
1717
18- public CalculatedKeysConverter ( KeyMapper < T , TPartitionKey > partitionMapper , KeyMapper < T , TRowKey > rowMapper , JsonSerializerSettings jsonSerializerSettings ,
18+ public CalculatedKeysConverter ( KeyMapper < T , TPartitionKey > partitionMapper , KeyMapper < T , TRowKey > rowMapper , JsonSerializerSettings jsonSerializerSettings ,
1919 PropertyConverters < T > propertyConverters = default ,
2020 params Expression < Func < T , object > > [ ] ignoredProperties )
2121 {
@@ -25,30 +25,32 @@ public CalculatedKeysConverter(KeyMapper<T, TPartitionKey> partitionMapper, KeyM
2525 _propertyConverters = propertyConverters ?? new PropertyConverters < T > ( ) ;
2626 _ignoredProperties = ignoredProperties ;
2727 }
28- public CalculatedKeysConverter ( KeyMapper < T , TPartitionKey > partitionMapper , KeyMapper < T , TRowKey > rowMapper ,
28+
29+ public CalculatedKeysConverter ( KeyMapper < T , TPartitionKey > partitionMapper , KeyMapper < T , TRowKey > rowMapper ,
2930 PropertyConverters < T > propertyConverters = default ,
30- params Expression < Func < T , object > > [ ] ignoredProperties ) : this ( partitionMapper , rowMapper , new JsonSerializerSettings ( ) , propertyConverters , ignoredProperties )
31+ params Expression < Func < T , object > > [ ] ignoredProperties )
32+ : this ( partitionMapper , rowMapper , new JsonSerializerSettings ( ) , propertyConverters , ignoredProperties )
3133 {
3234 }
33- public DynamicTableEntity ToEntity ( T obj )
35+
36+ public string PartitionKey ( TPartitionKey key )
3437 {
35- return obj . ToTableEntity ( _partitionMapper . ToKey ( obj ) , _rowMapper . ToKey ( obj ) , _jsonSerializerSettings , _propertyConverters , _ignoredProperties ) ;
38+ return _partitionMapper . ToKeyFromParameter ( key ) ;
3639 }
3740
38- public T FromEntity ( DynamicTableEntity entity )
41+ public string RowKey ( TRowKey key )
3942 {
40- return entity . FromTableEntity ( _partitionMapper . KeyProperty , _partitionMapper . FromKey , _rowMapper . KeyProperty ,
41- _rowMapper . FromKey , _jsonSerializerSettings , _propertyConverters ) ;
43+ return _rowMapper . ToKeyFromParameter ( key ) ;
4244 }
4345
44- public string PartitionKey ( TPartitionKey key )
46+ public TableEntity ToEntity ( T obj )
4547 {
46- return _partitionMapper . ToKeyFromParameter ( key ) ;
48+ return obj . ToTableEntity ( _partitionMapper . ToKey ( obj ) , _rowMapper . ToKey ( obj ) , _jsonSerializerSettings , _propertyConverters , _ignoredProperties ) ;
4749 }
4850
49- public string RowKey ( TRowKey key )
51+ public T FromEntity ( TableEntity entity )
5052 {
51- return _rowMapper . ToKeyFromParameter ( key ) ;
53+ return entity . FromTableEntity ( _partitionMapper . KeyProperty , _partitionMapper . FromKey , _rowMapper . KeyProperty ,
54+ _rowMapper . FromKey , _jsonSerializerSettings , _propertyConverters ) ;
5255 }
53- }
54- }
56+ }
0 commit comments