Skip to content

Commit 8658561

Browse files
committed
Added documentation for most types and members
1 parent 40ddd29 commit 8658561

31 files changed

+718
-13
lines changed

src/LightningDB/Converters/ConvertFromBytesInstance.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,34 @@
22

33
namespace LightningDB.Converters
44
{
5+
/// <summary>
6+
/// Class for converting from a byte array to a concrete type using specified lambda
7+
/// </summary>
8+
/// <typeparam name="TTo"></typeparam>
59
public class ConvertFromBytesInstance<TTo> : IConvertFromBytes<TTo>
610
{
711
private readonly Func<LightningDatabase, byte[], TTo> _convert;
812

13+
/// <summary>
14+
/// Creates new instance of ConvertFromBytesInstance
15+
/// </summary>
16+
/// <param name="convert">Conversion lambda</param>
917
public ConvertFromBytesInstance(Func<LightningDatabase, byte[], TTo> convert)
1018
{
1119
_convert = convert;
1220
}
1321

14-
public Type ConvertFromType
15-
{
16-
get { return typeof(TTo); }
17-
}
22+
/// <summary>
23+
/// Destination type
24+
/// </summary>
25+
public Type ConvertFromType { get { return typeof(TTo); } }
1826

27+
/// <summary>
28+
/// Converts a byte array to a destination type.
29+
/// </summary>
30+
/// <param name="db">Database</param>
31+
/// <param name="bytes">Byte array.</param>
32+
/// <returns>Converted value.</returns>
1933
public TTo Convert(LightningDatabase db, byte[] bytes)
2034
{
2135
return bytes == null ? default(TTo) : _convert(db, bytes);

src/LightningDB/Converters/ConvertToBytesInstance.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,34 @@
22

33
namespace LightningDB.Converters
44
{
5+
/// <summary>
6+
/// Class for conversion using a specified lambda from .NET type to byte array.
7+
/// </summary>
8+
/// <typeparam name="TFrom">Source type to convert from.</typeparam>
59
public class ConvertToBytesInstance<TFrom> : IConvertToBytes<TFrom>
610
{
711
private readonly Func<LightningDatabase, TFrom, byte[]> _convert;
812

13+
/// <summary>
14+
/// Creates a new instance of ConvertToBytesInstance.
15+
/// </summary>
16+
/// <param name="convert">Conversion lambda</param>
917
public ConvertToBytesInstance(Func<LightningDatabase, TFrom, byte[]> convert)
1018
{
1119
_convert = convert;
1220
}
1321

14-
public Type ConvertFromType
15-
{
16-
get { return typeof(TFrom); }
17-
}
22+
/// <summary>
23+
/// Source type.
24+
/// </summary>
25+
public Type ConvertFromType { get { return typeof(TFrom); } }
1826

27+
/// <summary>
28+
/// Converts from source type to a byte array.
29+
/// </summary>
30+
/// <param name="db">Database.</param>
31+
/// <param name="instance">Source value.</param>
32+
/// <returns>Value converted to a byte array.</returns>
1933
public byte[] Convert(LightningDatabase db, TFrom instance)
2034
{
2135
return _convert(db, instance);

src/LightningDB/Converters/ConverterExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
namespace LightningDB.Converters
55
{
6+
/// <summary>
7+
/// Extension methods for converters and ConverterStore
8+
/// </summary>
69
public static class ConverterExtensions
710
{
811
public static void AddConvertToBytes<TFrom>(this ConverterStore store, Func<LightningDatabase, TFrom, byte[]> convert)

src/LightningDB/Converters/ConverterNotFoundException.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22

33
namespace LightningDB.Converters
44
{
5+
/// <summary>
6+
/// Thrown when a converter wasn't fount
7+
/// </summary>
58
public class ConverterNotFoundException : Exception
69
{
10+
/// <summary>
11+
/// Creates a new instance of ConverterNotFoundException
12+
/// </summary>
13+
/// <param name="type">Type for which the converter wasn't found</param>
714
public ConverterNotFoundException(Type type)
815
: base(string.Format("Unable to find converter for {0}", type.FullName))
916
{

src/LightningDB/Converters/ConverterStore.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
namespace LightningDB.Converters
66
{
7+
/// <summary>
8+
/// Encapsulates collections to store converters used by LightningEnvironment.
9+
/// </summary>
710
public class ConverterStore
811
{
912
private readonly IDictionary<Type, object> _convertToBytes = new ConcurrentDictionary<Type, object>();

src/LightningDB/Converters/DefaultConverters.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22

33
namespace LightningDB.Converters
44
{
5+
/// <summary>
6+
/// Class to setup default converters for LightningEnvironment
7+
/// </summary>
58
public class DefaultConverters
69
{
10+
/// <summary>
11+
/// Registers predefined list of converters.
12+
/// </summary>
13+
/// <param name="environment">Environment to register converters in.</param>
714
public void RegisterDefault(LightningEnvironment environment)
815
{
916
var store = environment.ConverterStore;

src/LightningDB/Converters/IConvertFromBytes.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,23 @@
22

33
namespace LightningDB.Converters
44
{
5+
/// <summary>
6+
/// Interface for converters from a byte array to a .NET type
7+
/// </summary>
8+
/// <typeparam name="TTo">Type to convert to</typeparam>
59
public interface IConvertFromBytes<TTo>
610
{
11+
/// <summary>
12+
/// Destination type.
13+
/// </summary>
714
Type ConvertFromType { get; }
15+
16+
/// <summary>
17+
/// Convertes from a byte array to a .NET type
18+
/// </summary>
19+
/// <param name="db">Database</param>
20+
/// <param name="bytes">Value bytes</param>
21+
/// <returns>Converted value</returns>
822
TTo Convert(LightningDatabase db, byte[] bytes);
923
}
1024
}

src/LightningDB/Converters/IConvertToBytes.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,23 @@
22

33
namespace LightningDB.Converters
44
{
5+
/// <summary>
6+
/// Interface for converter from .NET type to a byte array.
7+
/// </summary>
8+
/// <typeparam name="TConvertFrom">Type to convert from/</typeparam>
59
public interface IConvertToBytes<TConvertFrom>
610
{
11+
/// <summary>
12+
/// Source type
13+
/// </summary>
714
Type ConvertFromType { get; }
15+
16+
/// <summary>
17+
/// Converts value from .NET type to a byte array
18+
/// </summary>
19+
/// <param name="db">Database</param>
20+
/// <param name="instance">Value</param>
21+
/// <returns>Value as a byte array.</returns>
822
byte[] Convert(LightningDatabase db, TConvertFrom instance);
923
}
1024
}

src/LightningDB/CursorDeleteOption.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
namespace LightningDB
22
{
3+
/// <summary>
4+
/// Cursor delete operation options
5+
/// </summary>
36
public enum CursorDeleteOption
47
{
8+
/// <summary>
9+
/// No special behavior
10+
/// </summary>
511
None = 0,
612

713
/// <summary>

src/LightningDB/CursorGetByOperation.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,28 @@
22
using System.Collections.Generic;
33
namespace LightningDB
44
{
5+
/// <summary>
6+
/// Converter class for pairs obtained via cursor
7+
/// </summary>
58
public class CursorGetByOperation
69
{
710
private readonly LightningCursor _cur;
811
private readonly KeyValuePair<byte[], byte[]>? _pair;
912

13+
/// <summary>
14+
/// Creates new instance of CursorGetByOperation.
15+
/// </summary>
16+
/// <param name="cur">Cursor.</param>
17+
/// <param name="pair">Key-value byte arrays pair</param>
1018
public CursorGetByOperation(LightningCursor cur, KeyValuePair<byte[], byte[]>? pair)
1119
{
1220
_cur = cur;
1321
_pair = pair;
1422
}
1523

24+
/// <summary>
25+
/// Does key-value pair exist in database.
26+
/// </summary>
1627
public bool PairExists { get { return _pair.HasValue; } }
1728

1829
private void EnsurePairExists()
@@ -21,20 +32,36 @@ private void EnsurePairExists()
2132
throw new InvalidOperationException("Pair doesn't exist");
2233
}
2334

35+
/// <summary>
36+
/// Converts database key to a concrete type
37+
/// </summary>
38+
/// <typeparam name="TKey">Type to convert key to</typeparam>
39+
/// <returns>Converted key value.</returns>
2440
public TKey Key<TKey>()
2541
{
2642
this.EnsurePairExists();
2743

2844
return _cur.FromBytes<TKey>(_pair.Value.Key);
2945
}
3046

47+
/// <summary>
48+
/// Converts database value to a concrete type.
49+
/// </summary>
50+
/// <typeparam name="TValue">Type to convert value to.</typeparam>
51+
/// <returns>Converted value.</returns>
3152
public TValue Value<TValue>()
3253
{
3354
this.EnsurePairExists();
3455

3556
return _cur.FromBytes<TValue>(_pair.Value.Value);
3657
}
3758

59+
/// <summary>
60+
/// Convert key-value pair to concrete types
61+
/// </summary>
62+
/// <typeparam name="TKey">Key type.</typeparam>
63+
/// <typeparam name="TValue">Value type.</typeparam>
64+
/// <returns>Pair of converted key and value.</returns>
3865
public KeyValuePair<TKey, TValue> Pair<TKey, TValue>()
3966
{
4067
return new KeyValuePair<TKey, TValue>(this.Key<TKey>(), this.Value<TValue>());

0 commit comments

Comments
 (0)