Skip to content
This repository was archived by the owner on Jan 27, 2022. It is now read-only.

Commit 891a0a8

Browse files
authored
Use editorconfig. (#20)
1 parent 5ac3d37 commit 891a0a8

23 files changed

Lines changed: 1898 additions & 323 deletions

.editorconfig

Lines changed: 1749 additions & 0 deletions
Large diffs are not rendered by default.

Winton.DomainModelling.DocumentDb.sln

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27703.2026
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29613.14
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{90869527-D332-48C8-9D75-FF16E8E72973}"
77
ProjectSection(SolutionItems) = preProject
8+
.editorconfig = .editorconfig
89
.gitignore = .gitignore
910
.travis.yml = .travis.yml
1011
appveyor.yml = appveyor.yml
@@ -14,6 +15,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1415
LICENSE = LICENSE
1516
README.md = README.md
1617
stylecop.json = stylecop.json
18+
Winton.DomainModelling.DocumentDb.sln.DotSettings = Winton.DomainModelling.DocumentDb.sln.DotSettings
1719
EndProjectSection
1820
EndProject
1921
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B70E1756-208C-4D97-9C84-CFE1625977FF}"

Winton.DomainModelling.DocumentDb.sln.DotSettings

Lines changed: 5 additions & 129 deletions
Large diffs are not rendered by default.

src/Winton.DomainModelling.DocumentDb/EntityDocument.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,8 @@ private EntityDocument(string id, string type, T entity)
2323
public string Type { get; }
2424

2525
internal static EntityDocument<T> Create(string id, string type, T entity)
26-
{
27-
return new EntityDocument<T>(CreateId(id, type), type, entity);
28-
}
26+
=> new EntityDocument<T>(CreateId(id, type), type, entity);
2927

30-
internal static string CreateId(string id, string type)
31-
{
32-
return $"{type}_{id}";
33-
}
28+
internal static string CreateId(string id, string type) => $"{type}_{id}";
3429
}
35-
}
30+
}

src/Winton.DomainModelling.DocumentDb/EntityRepository.cs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public async Task Delete(string id)
4646

4747
public async Task Put(T entity)
4848
{
49-
string id = _idSelector(entity);
49+
var id = _idSelector(entity);
5050
if (string.IsNullOrWhiteSpace(id))
5151
{
5252
throw new NotSupportedException("An id must be specified to put.");
@@ -56,19 +56,17 @@ public async Task Put(T entity)
5656
}
5757

5858
public IEnumerable<T> Query(Expression<Func<T, bool>> predicate = null)
59-
{
60-
return _documentClient
59+
=> _documentClient
6160
.CreateDocumentQuery<EntityDocument<T>>(GetUri())
6261
.Where(x => x.Type == _entityType)
6362
.Select(x => x.Entity)
6463
.Where(predicate ?? (x => true));
65-
}
6664

6765
public async Task<T> Read(string id)
6866
{
6967
try
7068
{
71-
ResourceResponse<Document> response = await _documentClient.ReadDocumentAsync(GetUri(id));
69+
var response = await _documentClient.ReadDocumentAsync(GetUri(id));
7270
EntityDocument<T> responseDocument = (dynamic)response.Resource;
7371
return responseDocument.Entity;
7472
}
@@ -78,17 +76,11 @@ public async Task<T> Read(string id)
7876
}
7977
}
8078

81-
private Uri GetUri()
82-
{
83-
return UriFactory.CreateDocumentCollectionUri(_database.Id, _documentCollection.Id);
84-
}
79+
private Uri GetUri() => UriFactory.CreateDocumentCollectionUri(_database.Id, _documentCollection.Id);
8580

86-
private Uri GetUri(string id)
87-
{
88-
return UriFactory.CreateDocumentUri(
89-
_database.Id,
90-
_documentCollection.Id,
91-
EntityDocument<T>.CreateId(id, _entityType));
92-
}
81+
private Uri GetUri(string id) => UriFactory.CreateDocumentUri(
82+
_database.Id,
83+
_documentCollection.Id,
84+
EntityDocument<T>.CreateId(id, _entityType));
9385
}
94-
}
86+
}

src/Winton.DomainModelling.DocumentDb/EntityRepositoryFactory.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@ public async Task<IEntityRepository<T>> Create<T>(
2020
Database database,
2121
DocumentCollection documentCollection,
2222
string entityType,
23-
Func<T, string> idSelector)
24-
{
25-
return new EntityRepository<T>(
23+
Func<T, string> idSelector) => new EntityRepository<T>(
2624
await _documentClientFactory(),
2725
database,
2826
documentCollection,
2927
entityType,
3028
idSelector);
31-
}
3229
}
33-
}
30+
}

src/Winton.DomainModelling.DocumentDb/IEntityRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ public interface IEntityRepository<T>
5353
/// <returns>The entity for the given id, if it exists, otherwise <c>default(T)</c>.</returns>
5454
Task<T> Read(string id);
5555
}
56-
}
56+
}

src/Winton.DomainModelling.DocumentDb/IEntityRepositoryFactory.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ public interface IEntityRepositoryFactory
2020
/// it can be serialised as JSON using Newtonsoft.Json.
2121
/// The <paramref name="entityType" /> acts as a namespace to differentiate between objects in the
2222
/// collection.
23-
/// It is used to lookup the objects of type <typeparamref name="T"/> in the collection
23+
/// It is used to lookup the objects of type <typeparamref name="T" /> in the collection
2424
/// and so would require a data migration if it was ever modified.
2525
/// For that reason it is recommended to use a string literal rather than reflecting on
26-
/// <typeparamref name="T"/> as the latter is not safe against refactoring.
26+
/// <typeparamref name="T" /> as the latter is not safe against refactoring.
2727
/// </remarks>
2828
/// <typeparam name="T">The type of object to be stored in the collection.</typeparam>
29-
/// <param name="database">The <see cref="Database"/>.</param>
30-
/// <param name="documentCollection">The <see cref="DocumentCollection"/>.</param>
29+
/// <param name="database">The <see cref="Database" />.</param>
30+
/// <param name="documentCollection">The <see cref="DocumentCollection" />.</param>
3131
/// <param name="entityType">The type name of the entity that is being persisted.</param>
3232
/// <param name="idSelector">A function that selects the id from the object.</param>
3333
/// <returns>The created <see cref="IEntityRepository{T}" />.</returns>
@@ -37,4 +37,4 @@ Task<IEntityRepository<T>> Create<T>(
3737
string entityType,
3838
Func<T, string> idSelector);
3939
}
40-
}
40+
}

src/Winton.DomainModelling.DocumentDb/IValueRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ public interface IValueRepository<T>
4040
/// <returns>An <see cref="IEnumerable{T}" /> of the value objects that match the predicate.</returns>
4141
IEnumerable<T> Query(Expression<Func<T, bool>> predicate = null);
4242
}
43-
}
43+
}

src/Winton.DomainModelling.DocumentDb/IValueRepositoryFactory.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ public interface IValueRepositoryFactory
1717
/// </summary>
1818
/// <remarks>
1919
/// The created <see cref="IValueRepository{T}" /> can be used to persist any type of object providing
20-
/// it can be serialised as JSON using Newtonsoft.Json and it is <see cref="IEquatable{T}"/>.
20+
/// it can be serialised as JSON using Newtonsoft.Json and it is <see cref="IEquatable{T}" />.
2121
/// The <paramref name="valueType" /> acts as a namespace to differentiate between objects in the
2222
/// collection.
23-
/// It is used to lookup the objects of type <typeparamref name="T"/> in the collection
23+
/// It is used to lookup the objects of type <typeparamref name="T" /> in the collection
2424
/// and so would require a data migration if it was ever modified.
2525
/// For that reason it is recommended to use a string literal rather than reflecting on
26-
/// <typeparamref name="T"/> as the latter is not safe against refactoring.
26+
/// <typeparamref name="T" /> as the latter is not safe against refactoring.
2727
/// </remarks>
2828
/// <typeparam name="T">The type of the Value Object.</typeparam>
29-
/// <param name="database">The <see cref="Database"/>.</param>
30-
/// <param name="documentCollection">The <see cref="DocumentCollection"/>.</param>
29+
/// <param name="database">The <see cref="Database" />.</param>
30+
/// <param name="documentCollection">The <see cref="DocumentCollection" />.</param>
3131
/// <param name="valueType">The type name of the value that is being persisted.</param>
3232
/// <returns>The created <see cref="IValueRepository{T}" />.</returns>
3333
Task<IValueRepository<T>> Create<T>(
@@ -36,4 +36,4 @@ Task<IValueRepository<T>> Create<T>(
3636
string valueType)
3737
where T : IEquatable<T>;
3838
}
39-
}
39+
}

0 commit comments

Comments
 (0)