forked from JSONAPIdotNET/JSONAPI.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToManyResourceLinkage.cs
More file actions
34 lines (32 loc) · 1.04 KB
/
Copy pathToManyResourceLinkage.cs
File metadata and controls
34 lines (32 loc) · 1.04 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
using System;
using Newtonsoft.Json.Linq;
namespace JSONAPI.Documents
{
/// <summary>
/// Describes linkage to a collection of resources
/// </summary>
public class ToManyResourceLinkage : IResourceLinkage
{
public JToken LinkageToken { get; private set; }
/// <summary>
/// Creates a To-many resource linkage object
/// </summary>
/// <param name="resourceIdentifiers"></param>
/// <exception cref="NotImplementedException"></exception>
public ToManyResourceLinkage(IResourceIdentifier[] resourceIdentifiers)
{
var array = new JArray();
if (resourceIdentifiers != null)
{
foreach (var resourceIdentifier in resourceIdentifiers)
{
var obj = new JObject();
obj["type"] = resourceIdentifier.Type;
obj["id"] = resourceIdentifier.Id;
array.Add(obj);
}
}
LinkageToken = array;
}
}
}