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 7995547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:26:53+00:00 2026-06-04T14:26:53+00:00

I am attempting to mimic some stuff from Orchard CMS in my own app

  • 0

I am attempting to mimic some stuff from Orchard CMS in my own app using unity..

Okay so what I am trying to do is this…

Lets say I have a marker interface called IDependency..

public interface IDependency{ }

I then have several interfaces hanging off of this…

public interface ICustomerService : IDependency { }

public interface ICustomerRepository : IDependency { }

and then have some classes too…

public class CustomerService : ICustomerService {
     public CustomerService(ICustomerRepository customerRepo){ }
}

public class SomOtherCustomerService : ICustomerService {
     public CustomerService(ICustomerRepository customerRepo){ }
}

public class NicksController : Controller {
     public NicksController(IEnumerable<ICustomerService> customerServices) { }
}

 public class NicksSecondController : Controller {
     public NicksSecondController(IEnumerable<ICustomerService> customerServices) { }
}

What I have so far..

var container = new UnityContainer();

container
    .ConfigureAutoRegistration()
    .ExcludeSystemAssemblies()
    //.Include(If.Implements<IDependency>, Then.Register()
    //.As<IDependency>().UsingLifetime<PerResolveLifetimeManager>())
    .Include(t =>
        typeof(IDependency).IsAssignableFrom(t), (type, builder) =>
            {
                builder.RegisterType(type);

                foreach (var interfaceType in type.GetInterfaces()
                .Where(itf => typeof(IDependency).IsAssignableFrom(itf))) {
                    builder = builder.RegisterType(interfaceType, type);
                }
            })
    .ApplyAutoRegistration();

Im falling down on the injecting of an IEnumerable in to my NicksSecondController… Any Ideas??

Cheers, Nick

  • 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-06-04T14:26:54+00:00Added an answer on June 4, 2026 at 2:26 pm

    Out of the box Unity only knows how to resolve arrays. Have a look at the TecX project on codeplex. It contains a custom extension that teaches the container to handle IEnumerable<T>, IList<T> and ICollection<T> as well. The code can be found in TecX.Unity (folder Collections).

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

Sidebar

Related Questions

Attempting to use the data series from this example no longer passes the JSONLint
Attempting to find printers / shares in Active Directory using C#. This is my
I'm attempting to test my repository using an in-memory mock context. I implement this
Attempting to do some asynchronous programming via threads. To start with, I am trying
ATTEMPTING: I am trying to load a FLV using the FLVPlayback() component in another
I am attempting to mimic the functionality of Adium and most other chat clients
Attempting to decide on how to implement our RPC on the server side. From
Attempting to set up Samba + OpenLDAP using nss_ldap. After joining Windows7 to Samba
Attempting to generics-ify some legacy code, I'm stuck. I have a ParentObject which wraps
I'm attempting to mimic (or find a preexisting component) that mimics the zoom slider

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.