24 lines
915 B
C#
24 lines
915 B
C#
using OwofGames.GodotLume;
|
|
|
|
namespace GodotHostTest.GodotDI;
|
|
|
|
public static class BuilderExtensions
|
|
{
|
|
public static Builder AddValueProvider<TValueType, TSourceScope, TDestinationScope>(this Builder builder)
|
|
where TSourceScope : RootScope
|
|
where TDestinationScope : TSourceScope
|
|
{
|
|
var valueProvider = new ValueProvider<TValueType>();
|
|
return builder
|
|
.AddScoped<IValueSetter<TValueType>, IValueSetter<TValueType>, TSourceScope>(Builder.NoDependencies,
|
|
_ => valueProvider.Setter)
|
|
.AddScoped<IValueGetter<TValueType>, IValueGetter<TValueType>, TDestinationScope>(Builder.NoDependencies,
|
|
_ => valueProvider.Getter);
|
|
}
|
|
|
|
public static Builder AddValueProvider<TValueType, TScope>(this Builder builder)
|
|
where TScope : RootScope
|
|
{
|
|
return builder.AddValueProvider<TValueType, TScope, TScope>();
|
|
}
|
|
} |