Skip to content

Commit cf5ad1a

Browse files
authored
Merge pull request #112 from microsoftgraph/dependabot/nuget/src/Microsoft.Graph-6.8.0
Bump Microsoft.Graph from 5.55.0 to 6.8.0
2 parents 802c771 + 73085b5 commit cf5ad1a

2 files changed

Lines changed: 28 additions & 8 deletions

File tree

‎src/GitHubConnector.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
3131
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.1" />
3232
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.0" />
33-
<PackageReference Include="Microsoft.Graph" Version="5.55.0" />
33+
<PackageReference Include="Microsoft.Graph" Version="6.8.0" />
3434
<PackageReference Include="Octokit" Version="14.0.0" />
3535
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
3636
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

‎src/Services/SearchConnectorService.cs‎

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.Graph;
88
using Microsoft.Graph.External.Connections.Item.Items.Item.MicrosoftGraphExternalConnectorsAddActivities;
99
using Microsoft.Graph.Models.ExternalConnectors;
10+
using Microsoft.Kiota.Abstractions.Serialization;
1011
using Microsoft.Kiota.Authentication.Azure;
1112

1213
namespace GitHubConnector.Services;
@@ -149,10 +150,7 @@ public SearchConnectorService(AppSettings settings)
149150
{
150151
Id = itemType == "issues" ? "issueDisplay" : "repoDisplay",
151152
Priority = 1,
152-
Layout = new()
153-
{
154-
AdditionalData = await GetResultTemplateAsync(resultCardJsonFile),
155-
},
153+
Layout = await GetResultTemplateAsync(resultCardJsonFile),
156154
},
157155
],
158156
},
@@ -280,10 +278,32 @@ public Task<Identity> GetIdentityForGitHubUserAsync(string? gitHubLogin)
280278
});
281279
}
282280

283-
private static async Task<Dictionary<string, object>> GetResultTemplateAsync(string resultCardJsonFile)
281+
private static async Task<UntypedNode> GetResultTemplateAsync(string resultCardJsonFile)
284282
{
285283
var cardContents = await File.ReadAllTextAsync(resultCardJsonFile);
286-
return JsonSerializer.Deserialize<Dictionary<string, object>>(cardContents) ??
287-
throw new Exception($"Could not deserialize contents of {resultCardJsonFile}");
284+
using var cardJson = JsonDocument.Parse(cardContents);
285+
return ToUntypedNode(cardJson.RootElement);
286+
}
287+
288+
private static UntypedNode ToUntypedNode(JsonElement element)
289+
{
290+
return element.ValueKind switch
291+
{
292+
JsonValueKind.Object => new UntypedObject(element.EnumerateObject()
293+
.ToDictionary(property => property.Name, property => ToUntypedNode(property.Value))),
294+
JsonValueKind.Array => new UntypedArray(element.EnumerateArray().Select(ToUntypedNode)),
295+
JsonValueKind.String => new UntypedString(element.GetString()!),
296+
JsonValueKind.Number => element.TryGetInt32(out var intValue) ?
297+
new UntypedInteger(intValue) :
298+
element.TryGetInt64(out var longValue) ?
299+
new UntypedLong(longValue) :
300+
element.TryGetDecimal(out var decimalValue) ?
301+
new UntypedDecimal(decimalValue) :
302+
new UntypedDouble(element.GetDouble()),
303+
JsonValueKind.True => new UntypedBoolean(true),
304+
JsonValueKind.False => new UntypedBoolean(false),
305+
JsonValueKind.Null => new UntypedNull(),
306+
_ => throw new JsonException($"Unsupported JSON value: {element.ValueKind}"),
307+
};
288308
}
289309
}

0 commit comments

Comments
 (0)