Unity Auto Registration (convention over configuration registration)(autoregistration.codeplex.com)

submitted by NextenderNextender(20) 2 years, 7 months ago

Unity Auto Registration extends Unity IoC container and provides nice fluent syntax to configure rules for automatic types registration. In a couple of code lines you can scan specified assemblies and register all types implementing certain interface or decorated with certain attribute (or satisfy your own predicate) with certain lifetime managers and names. For example: var container = new UnityContainer(); container .ConfigureAutoRegistration() .LoadAssemblyFrom("Plugin.dll") .IncludeAllLoadedAssemblies() .ExcludeSystemAssemblies() .ExcludeAssemblies(a => a.GetName().FullName.Contains("Test")) .Include(If.Implements<ILogger>, Then.Register().UsingPerCallMode()) .Include(If.ImplementsITypeName, Then.Register().WithTypeName()) .Include(If.Implements<ICustomerRepository>, Then.Register().WithName("Sample")) .Include(If.Implements<IOrderRepository>, Then.Register().AsSingleInterfaceOfType().UsingPerCallMode()) .Include(If.DecoratedWith<LoggerAttribute>, Then.Register() .AsInterface<IDisposable>() .WithTypeName() .UsingLifetime<MyLifetimeManager>()) .Exclude(t => t.Name.Contains("Trace")) .ApplyAutoRegistration();

add a comment |category: |Views: 145

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

No comments so far

information Login or create an account to comment on this story