Skip to content

Instantly share code, notes, and snippets.

@jasonsirota
Created May 4, 2012 01:37
Show Gist options
  • Save jasonsirota/2591117 to your computer and use it in GitHub Desktop.
Save jasonsirota/2591117 to your computer and use it in GitHub Desktop.
//Assembly 1: Example.Entities.dll (no assembly references at all)
namespace Example.Entities
{
//Customer does not implement interface
public class Customer
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
}
//Assembly 2: Example.Logic.dll (no assembly reference except IoC container)
using System.Reflection;
namespace Example.Logic
{
public interface ICustomer
{
public string FirstName { get; set;}
public string LastName { get; set;}
}
public class BusinessLogic
{
public BusinessLogic()
{
var asm = Assembly.Load("Example.Entities");
var concrete = asm.CreateInstance("Customer");
//container maps via reflection or other duck typing magic?
Container.For<ICustomer>().Use(() => concrete);
}
public void DoSomethingWithCustomer()
{
ICustomer customer = Container.GetInstance<ICustomer>();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment