using OwofGames.GodotLume; namespace GodotHostTest.AetherBind; public static class BuilderExtensions { public static Builder AddValueProvider(this Builder builder) where TValueType : class where TSourceScope : RootScope where TDestinationScope : TSourceScope { var valueProvider = new ValueProvider(); return builder // add the setter to the source scope .AddScoped, IValueSetter, TSourceScope>(Builder.NoDependencies, _ => valueProvider.Setter) // add the getter to the destination scope .AddScoped, IValueGetter, TDestinationScope>(Builder.NoDependencies, _ => valueProvider.Getter) // add a factory to automatically extract TValueType from the IValueGetter .AddScoped(_ => [typeof(IValueGetter)], provider => provider.Get>().Value); } public static Builder AddValueProvider(this Builder builder) where TValueType : class where TScope : RootScope { return builder.AddValueProvider(); } }