-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathIResourceTypeRegistration.cs
More file actions
78 lines (68 loc) · 2.34 KB
/
IResourceTypeRegistration.cs
File metadata and controls
78 lines (68 loc) · 2.34 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Linq.Expressions;
using System.Net.Http;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using JSONAPI.Documents;
using JSONAPI.Http;
namespace JSONAPI.Core
{
/// <summary>
/// Represents a registered resource type
/// </summary>
public interface IResourceTypeRegistration
{
/// <summary>
/// The resource type's runtime type
/// </summary>
Type Type { get; }
/// <summary>
/// The property to use to get the ID
/// </summary>
PropertyInfo IdProperty { get; }
/// <summary>
/// The JSON API name of the resource type
/// </summary>
string ResourceTypeName { get; }
/// <summary>
/// Gets the attribute fields for the resource type
/// </summary>
/// <returns></returns>
ResourceTypeAttribute[] Attributes { get; }
/// <summary>
/// Gets the relationship fields for the resource type
/// </summary>
/// <returns></returns>
ResourceTypeRelationship[] Relationships { get; }
/// <summary>
/// Gets the ID for a resource belonging to this resource type
/// </summary>
/// <param name="resource"></param>
/// <returns></returns>
string GetIdForResource(object resource);
/// <summary>
/// Sets the ID for a resource belonging to this resource type
/// </summary>
/// <param name="resource"></param>
/// <param name="id"></param>
void SetIdForResource(object resource, string id);
/// <summary>
/// Returns an expression that can be used to allow getting an instance of this resource
/// by ID
/// </summary>
/// <returns></returns>
BinaryExpression GetFilterByIdExpression(ParameterExpression parameter, string id);
/// <summary>
/// Returns an expression that can be used to allow sorting this resource by ID.
/// </summary>
/// <returns></returns>
Expression GetSortByIdExpression(ParameterExpression parameter);
/// <summary>
/// Gets a field by its JSON API-normalized name
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
ResourceTypeField GetFieldByName(string name);
}
}