Default Convention based registration #671
Replies: 3 comments
-
Look at RegisterMany overloads. They allow to select the imlementation and service types for the scanned assembly types. Find the usages in DryIoc repo in tests. Look at docs too. |
Beta Was this translation helpful? Give feedback.
-
I have read through the docs multiple times and have looked at the unit tests. I cannot find an example of what I am trying to replicate. In summary.... find all types that Implement IInterceptor Then register the type, as <IClassName, ClassName> I do not like how my predecessor has used CastleWindsor at all.... Its terrible. But the first step to moving everything to DryIOC is to replicate precisely how things are done now. Then send it for extensive regression testing, then start fixing things. So as much as I hate it, I need to know how to do this weird niche type of registration. |
Beta Was this translation helpful? Give feedback.
-
I can imagine the code like this: container.RegisterMany(new[] { typeof(A).Assembly },
getServiceTypes: implType => {
var serviceTypes = implType.GetImplementedServiceTypes();
if (!serviceTypes.Contains(typeof(IInterceptor)))
return null;
foreach (var st in serviceTypes)
{
if (st.IsInterface &&
st.Name[0] == "I" && st.Name[1..] == implType.Name)
return st;
}
return null;
}
); The docs for the reference: https://github.com/dadhi/DryIoc/blob/master/docs/DryIoc.Docs/RegisterResolve.md#registermany |
Beta Was this translation helpful? Give feedback.
-
I'm trying to migrate a terrible legacy application I've inherited away from CastleWindsor to DryIOC.
To do this, I need to replicate the many different types of ways that registrations are being done in this application (even if I don't like them) before I can start fixing them.
One thing I can't figure out how to do is this:
This CastleWindsor registration scans the assembly for all classes that implements IInterceptor. If then registers the type in the Container using the "DefaultInterfaces". This would be the interface that matches the name.
for example for the following class:
it would find the class because it implements IInterceptor, and then register it as IAuditingStore, because this is the interface that matches the class name.
I don't like this type of registration, but I need to replicate it in DryIOC, and get the app working as it is now, before I can start fixing things like this.
Please help this is really blocking me.
Beta Was this translation helpful? Give feedback.
All reactions