Aetheria/Aetheria.State/AetheriaRuntimeEveSurfaceStateProjector.cs
2026-06-21 09:37:54 +01:00

55 lines
1.7 KiB
C#

using Aetheria.State.Documents;
using GameCult.Aetheria.State.Unity;
namespace Aetheria.State;
public static class AetheriaRuntimeEveSurfaceStateProjector
{
public static EveSurfaceState ToState(AetheriaRuntimeSurfaceDocument document)
{
return new EveSurfaceState
{
ProviderId = document.ProviderId,
ProviderKind = document.ProviderKind,
Title = document.Title,
Version = document.Version,
UpdatedAtUtc = document.UpdatedAtUtc,
Surface = ToSurface(document.Surface),
Commands = document.Commands
.Select(command => new EveCommandTemplate
{
Command = command.Command,
Label = command.Label,
Transport = command.Transport
})
.ToArray()
};
}
private static EveSurface ToSurface(AetheriaRuntimeSurfaceTree surface)
{
return new EveSurface
{
Id = surface.Id,
Root = ToComponent(surface.Root),
Styles = surface.Styles
.Select(style => new EveStyleToken
{
Name = style.Name,
Value = style.Value
})
.ToArray()
};
}
private static EveSurfaceComponent ToComponent(AetheriaRuntimeSurfaceComponent component)
{
return new EveSurfaceComponent
{
Id = component.Id,
Kind = component.Kind,
Props = new Dictionary<string, string>(component.Props, StringComparer.Ordinal),
Children = component.Children.Select(ToComponent).ToArray()
};
}
}