in src/dotnet/AspireWorker/AspireHost/ResourceExtensions.cs [111:156]
private static ResourceEnvironmentVariable ToModel(this EnvironmentVariable variable) => new(
variable.Name,
variable.HasValue ? variable.Value : null
);
private static ResourceUrl ToModel(this Url url) => new(
url.HasEndpointName ? url.EndpointName : null,
url.FullUrl,
url.IsInternal,
url.IsInactive,
url.DisplayProperties.SortOrder,
url.DisplayProperties.DisplayName
);
private static ResourceVolume ToModel(this Volume volume) => new(
volume.Source,
volume.Target,
volume.MountType,
volume.IsReadOnly
);
private static ResourceHealthReport ToModel(this HealthReport report) => new(
MapHealthStatus(report.Status),
report.Key,
report.Description,
report.Exception
);
private static ResourceCommand ToModel(this global::Aspire.DashboardService.Proto.V1.ResourceCommand command) => new(
command.Name,
command.DisplayName,
command.HasConfirmationMessage ? command.ConfirmationMessage : null,
command.IsHighlighted,
command.HasIconName ? command.IconName : null,
command.HasDisplayDescription ? command.DisplayDescription : null,
MapCommandState(command.State)
);
private static ResourceCommandState MapCommandState(
global::Aspire.DashboardService.Proto.V1.ResourceCommandState state) => state switch
{
global::Aspire.DashboardService.Proto.V1.ResourceCommandState.Enabled => ResourceCommandState.Enabled,
global::Aspire.DashboardService.Proto.V1.ResourceCommandState.Disabled => ResourceCommandState.Disabled,
global::Aspire.DashboardService.Proto.V1.ResourceCommandState.Hidden => ResourceCommandState.Hidden,
_ => throw new ArgumentOutOfRangeException(nameof(state), state, null)
};