Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7657197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:57:54+00:00 2026-05-31T12:57:54+00:00

Using Unity, I’d like to automatically register all interface/class combinations in an assembly based

  • 0

Using Unity, I’d like to automatically register all interface/class combinations in an assembly based on the following convention:

INameOfObject > NameOfObject

StructureMap does that when the default conventions are enabled.

I wrote the following method for it:

private static IUnityContainer RegisterITypesOf(this IUnityContainer container, string assemblyName)
{
  Assembly.Load(assemblyName)
    .GetTypes()
    .Where(t => t.GetInterfaces().Any(i => i.Name == "I" + t.Name))
    .ForEach(t => container.RegisterType(t.GetInterface("I" + t.Name, false), t));
  return container;
}

My question is:

  • is there a built-in function that does the same?
  • if not, can my code be improved performance wise?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:57:56+00:00Added an answer on May 31, 2026 at 12:57 pm

    I wanted the same as you; convention based configuration ala Structuremap, and went ahead and created a library for it. You can download it on NuGet, and read some documentation on my github page

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Unity, and I register a logger like this: public class MvcApplication :
I'd like to create an instance of a class using unity where the class
I have a basic class that is trying to resolve an interface using Unity.
I am using Unity for IOC. I would like to configure the creation of
I'm using Unity to inject a context and using the following lifetime manager... public
I am using the Unity framework as IoC container. My Config looks some like
I am trying to add a dependency to a class property using Unity Configuration
Our project is using constructor-based Dependency Injection (we're using Unity as our container) and
I am using Unity for dependency injection and have the instance of a class
I'm starting my development using Unity. I'm doing something like that: if(Input.GetKey(KeyCode.A))newValues[1]-=this.turnSpeed*(float)Time.deltaTime; if(Input.GetKey(KeyCode.D))newValues[1]+=this.turnSpeed*(float)Time.deltaTime; transform.Rotate(0,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.