-
Notifications
You must be signed in to change notification settings - Fork 6
/
CosmosResource.cs
47 lines (42 loc) · 1.55 KB
/
CosmosResource.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
namespace Atc.Cosmos
{
/// <summary>
/// Abstract base-class for Cosmos resources.
/// </summary>
/// <remarks>
/// By using this implementation of the <see cref="ICosmosResource"/>
/// interface, the public interface of the class is not polluted with
/// Cosmos specific properties, as these are implemented explicitly.
/// </remarks>
[SuppressMessage(
"Design",
"CA1033:Interface methods should be callable by child types",
Justification = "By design")]
public abstract class CosmosResource : ICosmosResource
{
[JsonIgnore]
string ICosmosResource.DocumentId => GetDocumentId();
[JsonIgnore]
string ICosmosResource.PartitionKey => GetPartitionKey();
[JsonIgnore]
string? ICosmosResource.ETag { get; set; }
/// <summary>
/// Method for getting the id used for the document.
/// </summary>
/// <remarks>
/// Implement this by returning the property used as the document id.
/// </remarks>
/// <returns>The document id.</returns>
protected abstract string GetDocumentId();
/// <summary>
/// Method for getting the partition key used for the document.
/// </summary>
/// <remarks>
/// Implement this by returning the property used as the partition key.
/// </remarks>
/// <returns>The partition key.</returns>
protected abstract string GetPartitionKey();
}
}