Created
May 4, 2012 01:37
-
-
Save jasonsirota/2591117 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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