-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from NRG-Drink/feat/file-based
Feat/file based
- Loading branch information
Showing
10 changed files
with
182 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
NRG.CalendarFinder/NRG.CalendarFinder/CalendarFinderService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
NRG.CalendarFinder/NRG.CalendarFinder/Extensions/IHostBuilderExtensionsProcessData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using NRG.CalendarFinder.Models; | ||
|
||
namespace NRG.CalendarFinder.Extensions; | ||
|
||
public static class IHostBuilderExtensionsProcessData | ||
{ | ||
public static IHostBuilder AddProcessDataFromJson(this IHostBuilder builder, Options options) | ||
{ | ||
builder.ConfigureServices((context, services) => | ||
{ | ||
var inputData = context.Configuration | ||
.GetSection(nameof(InputData.UserIdentifier)) | ||
.GetChildren() | ||
.Select(e => e.Value) | ||
.OfType<string>() | ||
.Select(e => new InputData() { UserIdentifier = e }) | ||
.ToArray(); | ||
|
||
var data = new ProcessData() | ||
{ | ||
Options = options, | ||
Inputs = inputData | ||
}; | ||
|
||
services.AddSingleton(data); | ||
}); | ||
|
||
return builder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
NRG.CalendarFinder/NRG.CalendarFinder/Models/ProcessData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace NRG.CalendarFinder.Models; | ||
|
||
public record ProcessData | ||
{ | ||
public required Options Options { get; init; } | ||
public InputData[] Inputs { get; init; } = []; | ||
} | ||
|
||
public record InputData | ||
{ | ||
public required string UserIdentifier { get; init; } | ||
} | ||
|
||
public record OutputData | ||
{ | ||
public required InputData Input { get; init; } | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public string? Error { get; init; } | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public MyUser? User { get; init; } | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public MyCalendar[]? Calendars { get; init; } | ||
} | ||
|
||
public record MyUser | ||
{ | ||
public string? DisplayName { get; init; } | ||
public string? PrincipalName { get; init; } | ||
public string? Mail { get; init; } | ||
public string? UserId { get; init; } | ||
public string? CalendarId { get; init; } | ||
} | ||
|
||
public record MyCalendar | ||
{ | ||
public string? Id { get; init; } | ||
public string? Name { get; init; } | ||
public string? Owner { get; init; } | ||
public bool? IsDefault { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,9 @@ | |
"Thumbprint": "my_thumbprint", | ||
"Scopes": null | ||
} | ||
], | ||
"UserIdentifier": [ | ||
"myUserPrincipalName", | ||
"myUserId" | ||
] | ||
} |