Skip to content

Commit

Permalink
Fix externally owned
Browse files Browse the repository at this point in the history
  • Loading branch information
asdacap committed Oct 29, 2024
1 parent ef62cb8 commit ddcc974
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,16 @@ public static ContainerBuilder AddPropertiesFrom<T>(this ContainerBuilder config
ComponentKeyAttribute? componentKeyAttribute = propertyInfo.GetCustomAttribute<ComponentKeyAttribute>();
if (componentKeyAttribute != null)
{
configuration.RegisterInstance(val).Keyed(componentKeyAttribute.Key, propertyInfo.PropertyType);
configuration
.RegisterInstance(val)
.Keyed(componentKeyAttribute.Key, propertyInfo.PropertyType)
.ExternallyOwned();
}
else
{
configuration.RegisterInstance(val).As(propertyInfo.PropertyType);
configuration.RegisterInstance(val)
.As(propertyInfo.PropertyType)
.ExternallyOwned();
}
}
}
Expand All @@ -63,7 +68,8 @@ public static ContainerBuilder AddInstance<T>(this ContainerBuilder builder, T i
{
builder.RegisterInstance(instance)
.As<T>()
.SingleInstance();
.SingleInstance()
.ExternallyOwned();

return builder;
}
Expand Down Expand Up @@ -132,7 +138,8 @@ public static ContainerBuilder RegisterNamedComponentInItsOwnLifetime<T>(this Co
public static ContainerBuilder Bind<TImpl, TAs>(this ContainerBuilder builder) where TImpl : notnull where TAs : notnull
{
builder.Register(ctx => ctx.Resolve<TImpl>())
.As<TAs>();
.As<TAs>()
.ExternallyOwned();

return builder;
}
Expand Down

0 comments on commit ddcc974

Please sign in to comment.