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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:21:35+00:00 2026-05-14T18:21:35+00:00

I have three assemblies: Framework.DataAccess, Framework.DataAccess.NHibernateProvider and Company.DataAccess. Inside the assembly Framework.DataAccess, I have

  • 0

I have three assemblies: “Framework.DataAccess”, “Framework.DataAccess.NHibernateProvider” and “Company.DataAccess”. Inside the assembly “Framework.DataAccess”, I have my factory (with the wrong implementation of discovery):

public class DaoFactory 
{
    private static readonly object locker = new object();
    private static IWindsorContainer _daoContainer;

    protected static IWindsorContainer DaoContainer
    {
        get
        {
            if (_daoContainer == null)
            {
                lock (locker)
                {
                    if (_daoContainer != null)
                        return _daoContainer;

                    _daoContainer = new WindsorContainer(new XmlInterpreter());

                    // THIS IS WRONG! THIS ASSEMBLY CANNOT KNOW ABOUT SPECIALIZATIONS!
                    _daoContainer.Register(
                        AllTypes.FromAssemblyNamed("Company.DataAccess")
                            .BasedOn(typeof(IReadDao<>)).WithService.FromInterface(),
                        AllTypes.FromAssemblyNamed("Framework.DataAccess.NHibernateProvider")
                            .BasedOn(typeof(IReadDao<>)).WithService.Base());                        
                }
            }

            return _daoContainer;
        }
    }

    public static T Create<T>()
        where T : IDao
    {
        return DaoContainer.Resolve<T>();
    }
}

This assembly also defines the base interface for data access IReadDao:

public interface IReadDao<T>
{
    IEnumerable<T> GetAll();
}

I want to keep this assembly generic and with no references. This is my base data access assembly.

Then I have the NHibernate provider’s assembly, which implements the above IReadDao using NHibernate’s approach. This assembly references the “Framework.DataAccess” assembly.

public class NHibernateDao<T> : IReadDao<T>
{
    public NHibernateDao()
    {
    }

    public virtual IEnumerable<T> GetAll()
    {
        throw new NotImplementedException();
    }
}

At last, I have the “Company.DataAccess” assembly, which can override the default implementation of NHibernate provider and references both previously seen assemblies.

public interface IProductDao : IReadDao<Product> 
{
    Product GetByName(string name);
}

public class ProductDao : NHibernateDao<Product>, IProductDao
{
    public override IEnumerable<Product> GetAll()
    {
        throw new NotImplementedException("new one!");
    }

    public Product GetByName(string name)
    {
        throw new NotImplementedException();
    }
}

I want to be able to write…

IRead<Product> dao = DaoFactory.Create<IRead<Product>>();

… and then get the ProductDao implementation. But I can’t hold inside my base data access any reference to specific assemblies! My initial idea was to read that from a xml config file.

So, my question is: How can I externally configure this factory to use a specific provider as my default implementation and my client implementation?

  • 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-14T18:21:36+00:00Added an answer on May 14, 2026 at 6:21 pm

    Got it.

    I am using IWindsorInstaller to implement packages:

    public class TestDaoInstaller : IWindsorInstaller
    {
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(
                AllTypes.FromAssemblyNamed("Company.DataAccess")
                    .BasedOn(typeof(IReadDao<>)).WithService.FromInterface(),
                AllTypes.FromAssemblyNamed("Framework.DataAccess.NHibernate")
                    .BasedOn(typeof(IReadDao<>)).WithService.Base());
        }
    }
    

    And at Framework.DataAccess, my container is now:

    protected static IWindsorContainer DaoContainer
    {
        get
        {
            if (_daoContainer == null)
            {
                lock (locker)
                {
                    if (_daoContainer != null)
                        return _daoContainer;
    
                    _daoContainer = new WindsorContainer(new XmlInterpreter());
                    IWindsorInstaller[] daoInstallers = _daoContainer.ResolveAll<IWindsorInstaller>();
                    foreach (IWindsorInstaller daoInstaller in daoInstallers)
                        _daoContainer.Install(daoInstaller); 
    
                }
            }
    
            return _daoContainer;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an net assembly that was originally written in framework 1.1. I have
I have two scenarios: There is a Framework project for the company, and for
I have a MEF (Microsoft Extension Framework) application which loads some assemblies from a
We have two Assemblies that contain their own Entity-Framework EDMX & repositoriy objects. These
I am brand new to Mono. I have a .NET Framework 3.5 assembly and
I have a C# console application with three assemblies: Main , Common and Utilities
I have following use-case: there are several assemblies decorated with ProtoContract classes and I
Have three classes User, Group and Field. Many to many relationship on User /
Have three divs in a container that I want to float over a large
i have three lists with the same number of elements in each other, i

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.