-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
Copy pathLinkedServiceResource.Serialization.cs
77 lines (71 loc) · 2.69 KB
/
LinkedServiceResource.Serialization.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
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Text.Json.Serialization;
using Azure.Core;
namespace Azure.Analytics.Synapse.Artifacts.Models
{
[JsonConverter(typeof(LinkedServiceResourceConverter))]
public partial class LinkedServiceResource : IUtf8JsonSerializable
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
writer.WritePropertyName("properties");
writer.WriteObjectValue(Properties);
writer.WriteEndObject();
}
internal static LinkedServiceResource DeserializeLinkedServiceResource(JsonElement element)
{
LinkedService properties = default;
Optional<string> etag = default;
Optional<string> id = default;
Optional<string> name = default;
Optional<string> type = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("properties"))
{
properties = LinkedService.DeserializeLinkedService(property.Value);
continue;
}
if (property.NameEquals("etag"))
{
etag = property.Value.GetString();
continue;
}
if (property.NameEquals("id"))
{
id = property.Value.GetString();
continue;
}
if (property.NameEquals("name"))
{
name = property.Value.GetString();
continue;
}
if (property.NameEquals("type"))
{
type = property.Value.GetString();
continue;
}
}
return new LinkedServiceResource(id.Value, name.Value, type.Value, etag.Value, properties);
}
internal partial class LinkedServiceResourceConverter : JsonConverter<LinkedServiceResource>
{
public override void Write(Utf8JsonWriter writer, LinkedServiceResource model, JsonSerializerOptions options)
{
writer.WriteObjectValue(model);
}
public override LinkedServiceResource Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
using var document = JsonDocument.ParseValue(ref reader);
return DeserializeLinkedServiceResource(document.RootElement);
}
}
}
}