forked from LEGO/AsyncAPI.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAsyncAPIArray.cs
More file actions
54 lines (46 loc) · 1.38 KB
/
Copy pathAsyncAPIArray.cs
File metadata and controls
54 lines (46 loc) · 1.38 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
// Copyright (c) The LEGO Group. All rights reserved.
namespace LEGO.AsyncAPI.Models
{
using System;
using System.Collections.ObjectModel;
using System.Text.Json.Nodes;
using LEGO.AsyncAPI.Models.Interfaces;
using LEGO.AsyncAPI.Writers;
[Obsolete("Please use AsyncApiAny instead")]
public class AsyncApiArray : Collection<AsyncApiAny>, IAsyncApiExtension, IAsyncApiElement
{
public static explicit operator AsyncApiArray(AsyncApiAny any)
{
var a = new AsyncApiArray();
if (any.GetNode() is JsonArray arr)
{
foreach (var item in arr)
{
a.Add(new AsyncApiAny(item));
}
}
return a;
}
public static implicit operator AsyncApiAny(AsyncApiArray arr)
{
var jArray = new JsonArray();
foreach (var item in arr)
{
jArray.Add(item.GetNode());
}
return new AsyncApiAny(jArray);
}
/// <summary>
/// Serialize AsyncApiObject to writer.
/// </summary>
public void Write(IAsyncApiWriter writer)
{
writer.WriteStartArray();
foreach (var item in this)
{
writer.WriteAny(item);
}
writer.WriteEndArray();
}
}
}