How to change naming rule for interface-class match?

Jun 26, 2012 at 10:59 PM

AutoRegistration works fine when a type name matches an interface name, for example, TClass and ITClass. I want interface names go without prefix "T", like IClass and need that IClass to match TClass.

But when I rename the interface, the auto-registration fails. Do I have to match the type/interface names, or is there a way to accomplish my need?

Jun 26, 2012 at 11:26 PM

Could you please post a sample of registration code you're using?

Jun 26, 2012 at 11:32 PM
Here it is:

UContainer .ConfigureAutoRegistration() .LoadAssemblyFrom(Assembly.GetEntryAssembly().Location) .ExcludeSystemAssemblies() .Include(If.ImplementsITypeName, Then.Register()) .Include(If.ImplementsSingleInterface, Then.Register()) .ApplyAutoRegistration();
Jun 26, 2012 at 11:51 PM
Edited Jun 26, 2012 at 11:52 PM

Try something like

UContainer
    .ConfigureAutoRegistration()
    .LoadAssemblyFrom(Assembly.GetEntryAssembly().Location)
    .ExcludeSystemAssemblies()
    .Include(type => type.GetInterfaces().Any(i => i.Name.StartsWith("I") && i.Name.Remove(0, 1) == type.Name.Remove(0, 1)), Then.Register())
    .Include(If.ImplementsSingleInterface, Then.Register())
    .ApplyAutoRegistration();
Jun 27, 2012 at 12:11 AM

That works, thanks.