feat: new ValueProvider improvements and source generator.
This commit is contained in:
@@ -5,18 +5,25 @@ namespace GodotHostTest.AetherBind;
|
||||
public static class BuilderExtensions
|
||||
{
|
||||
public static Builder AddValueProvider<TValueType, TSourceScope, TDestinationScope>(this Builder builder)
|
||||
where TValueType : class
|
||||
where TSourceScope : RootScope
|
||||
where TDestinationScope : TSourceScope
|
||||
{
|
||||
var valueProvider = new ValueProvider<TValueType>();
|
||||
return builder
|
||||
// add the setter to the source scope
|
||||
.AddScoped<IValueSetter<TValueType>, IValueSetter<TValueType>, TSourceScope>(Builder.NoDependencies,
|
||||
_ => valueProvider.Setter)
|
||||
// add the getter to the destination scope
|
||||
.AddScoped<IValueGetter<TValueType>, IValueGetter<TValueType>, TDestinationScope>(Builder.NoDependencies,
|
||||
_ => valueProvider.Getter);
|
||||
_ => valueProvider.Getter)
|
||||
// add a factory to automatically extract TValueType from the IValueGetter<TValueType>
|
||||
.AddScoped<TValueType, TValueType, TDestinationScope>(_ => [typeof(IValueGetter<TValueType>)],
|
||||
provider => provider.Get<IValueGetter<TValueType>>().Value);
|
||||
}
|
||||
|
||||
public static Builder AddValueProvider<TValueType, TScope>(this Builder builder)
|
||||
where TValueType : class
|
||||
where TScope : RootScope
|
||||
{
|
||||
return builder.AddValueProvider<TValueType, TScope, TScope>();
|
||||
|
||||
Reference in New Issue
Block a user