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

WhereTypeInheritsFrom shouldn't have side effect #5

Closed
WalkerCodeRanger opened this issue Sep 24, 2010 · 2 comments
Closed

WhereTypeInheritsFrom shouldn't have side effect #5

WalkerCodeRanger opened this issue Sep 24, 2010 · 2 comments

Comments

@WalkerCodeRanger
Copy link

We just spent half a day tracking this issue down. The WhereTypeInheritsFrom registers a Binding Convention. It should not. I know that in issue #2 you seemed to indicate that this is desired behavior, however that really doesn't work. It is quite reasonable that I might want to select types by inheritance to bind with some other convention than WhereTypeInheritsFrom. I should be allowed to specify my own binding convention.

Furthermore, the regular expression you are using is incorrect. I believe you need to add ^ to the beginning and $ to the end. Currently WhereTypeInheritsFrom<IFoo>() would cause those types to be bound to interfaces such as IFooBar and UIFoo if they also implemented them.

The code where we had this problem is:
Kernel.Scan(x =>
{
x.FromAssemblyContaining();
x.WhereTypeInheritsFrom();
x.BindWithDefaultConventions();
x.InRequestScope();
});

In this case you can see we are using WhereTypeInheritsFrom with a type that isn't even an interface which is perfectly reasonable. But it causes the types to be bound to things like IUserRepoistory becuase they contain the word Repository in the type name.

@idavis
Copy link
Member

idavis commented Sep 28, 2010

I could probably switch over to creating a filter delegate instead. That would probably be simpler. In the #2 issue, I was just trying to make it clear that there were two different calls depending on what you wanted to do.

@idavis
Copy link
Member

idavis commented Feb 14, 2011

Fixed

This issue was closed.
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

2 participants