Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for properties dynamic import strategy #289

Open
mcdis opened this issue Mar 23, 2022 · 2 comments
Open

Add support for properties dynamic import strategy #289

mcdis opened this issue Mar 23, 2022 · 2 comments

Comments

@mcdis
Copy link

mcdis commented Mar 23, 2022

Like:

 Container = new DependencyInjectionContainer(_ =>
      {
         _.Behaviors.ConstructorSelection = ConstructorSelectionMethod.Dynamic; // < -- Like that
      });

But for property.
Locate type with [Import] attribute in sub container doesn't work

interface IDep{}
interface IFoo{}

class Dep : IDep {}
class Foo : IFoo
{
 [Import]
 public IDep Dep {get;init;}
}

// ----------------------
Container.Configure(_b=>_b.ExportAs<Dep,IDep>());

Container
  .CreateChildScope(_b=>_b
     .ExportAs<Foo,IFoo>()
     .ImportMembers(MembersThat.HaveAttribute<ImportAttribute>())
     .Lifestyle.Singleton()
  ).Locate<Foo>();
@ipjohnson
Copy link
Owner

Sorry for the late response I've been AFK this past week. I can take a look this evening.

@cmandlbaur
Copy link

@ipjohnson did you ever get around to this? I am seeing similar behaviour on latest. Thanks for the awesome work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants