-
Notifications
You must be signed in to change notification settings - Fork 275
Expand file tree
/
Copy pathRuntimeExpressionAnyWrapper.cs
More file actions
83 lines (75 loc) · 2.2 KB
/
RuntimeExpressionAnyWrapper.cs
File metadata and controls
83 lines (75 loc) · 2.2 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
79
80
81
82
83
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System.Text.Json.Nodes;
using Microsoft.OpenApi.Expressions;
using Microsoft.OpenApi.Helpers;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Writers;
namespace Microsoft.OpenApi.Models
{
/// <summary>
/// The wrapper either for <see cref="JsonNode"/> or <see cref="RuntimeExpression"/>
/// </summary>
public class RuntimeExpressionAnyWrapper : IOpenApiElement
{
private JsonNode _any;
private RuntimeExpression _expression;
/// <summary>
/// Parameterless constructor
/// </summary>
public RuntimeExpressionAnyWrapper() { }
/// <summary>
/// Initializes a copy of an <see cref="RuntimeExpressionAnyWrapper"/> object
/// </summary>
public RuntimeExpressionAnyWrapper(RuntimeExpressionAnyWrapper runtimeExpressionAnyWrapper)
{
Any = JsonNodeCloneHelper.Clone(runtimeExpressionAnyWrapper?.Any);
Expression = runtimeExpressionAnyWrapper?.Expression;
}
/// <summary>
/// Gets/Sets the <see cref="JsonNode"/>
/// </summary>
public JsonNode Any
{
get
{
return _any;
}
set
{
_expression = null;
_any = value;
}
}
/// <summary>
/// Gets/Set the <see cref="RuntimeExpression"/>
/// </summary>
public RuntimeExpression Expression
{
get
{
return _expression;
}
set
{
_any = null;
_expression = value;
}
}
/// <summary>
/// Write <see cref="RuntimeExpressionAnyWrapper"/>
/// </summary>
public void WriteValue(IOpenApiWriter writer)
{
Utils.CheckArgumentNull(writer);
if (_any != null)
{
writer.WriteAny(_any);
}
else if (_expression != null)
{
writer.WriteValue(_expression.Expression);
}
}
}
}