Skip to content

Commit 980c19a

Browse files
committed
refactoring
1 parent 6db0747 commit 980c19a

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/TableStorage.Abstractions.POCO/IKeysConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace TableStorage.Abstractions.POCO
55
{
6-
public interface IKeysConverter<T, TPartitionKey, TRowKey>
6+
public interface IKeysConverter<T, in TPartitionKey, in TRowKey>
77
{
88
DynamicTableEntity ToEntity(T obj);
99
T FromEntity(DynamicTableEntity entity);

src/TableStorage.Abstractions.POCO/KeyMapper.cs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,19 @@ namespace TableStorage.Abstractions.POCO
55
{
66
public class KeyMapper<T, TKey>
77
{
8-
private Func<T, string> _toKey;
9-
private Func<TKey, string> _toKeyFromParameter;
10-
private Func<string, TKey> _fromKey;
11-
private Expression<Func<T, object>> _keyProperty;
8+
private readonly Func<T, string> _toKey;
9+
private readonly Func<TKey, string> _toKeyFromParameter;
10+
private readonly Func<string, TKey> _fromKey;
11+
1212
public KeyMapper(Func<T, string> toKey, Func<string, TKey> fromKey, Expression<Func<T, object>> keyProperty, Func<TKey, string> toKeyFromParameter)
1313
{
14-
if (toKey == null) throw new ArgumentNullException(nameof(toKey));
15-
//if (fromKey == null) throw new ArgumentNullException(nameof(fromKey));
16-
17-
this._toKey = toKey;
14+
this._toKey = toKey ?? throw new ArgumentNullException(nameof(toKey));
1815
_fromKey = fromKey;
19-
_keyProperty = keyProperty;
16+
KeyProperty = keyProperty;
2017
_toKeyFromParameter = toKeyFromParameter;
2118
}
2219

23-
public Expression<Func<T, object>> KeyProperty
24-
{
25-
get { return _keyProperty; }
26-
}
20+
public Expression<Func<T, object>> KeyProperty { get; }
2721

2822
public string ToKey(T obj)
2923
{

0 commit comments

Comments
 (0)