title: Castle Windsor: How do I register a factory method, when the underlying type isn't accessible to my assembly?
body: <p>I have a project where my business layer is constructed using DI, but I'm trying to go an additional step and use Windsor to manage object construction.</p>
  
  <p>Let's just say I have a pre-existing data layer (that I don't want to modify), that can be accessed via the following interface:</p>
  
  <pre><code>interface IDataFactory {
     IDataService Service { get; }
  }
  </code></pre>
  
  <p>A series of classes in my business layer depend on the services exposed through IDataFactory:</p>
  
  <pre><code>IFactory factory = DataFactory.NewFactory();
  IBusinessService service = new ConcreteBusinessService(factory.Service);
  </code></pre>
  
  <p>I understand that in order to register IBusinessService to the Castle Windsor container, I'd use code similar to this:</p>
  
  <pre><code>IWindsorContainer container = new WindsorContainer();
  container.AddComponent("businessService", typeof(IBusinessService), typeof(ConcreteBusinessService));
  </code></pre>
  
  <p>But for the life of me, I can't figure out how to register services from my data layer, using the my existing factory object.  In essence, I'd like to say:</p>
  
  <pre><code>container.AddComponent("dataService", typeof(IDataService), factory.service);
  </code></pre>
  
  <p>Windsor seems to want me to say <strong>container.AddComponent("dataService", typeof(IDataService), typeOf(SomeConcreteDataService)</strong>), but in this instance, ConcreteDataService is internal to that assembly, and thus not accessible in mine.</p>
  
  <p>How would I go about wiring up the data service, given that SomeConcreteDataService isn't known to my assembly?</p>
  
  <hr>
  
  <p><a href="https://stackoverflow.com/questions/64238/castle-windsor-how-do-you-add-a-call-to-a-factory-facility-not-in-xml">This question</a> is very similar to my own, except in my case, the AddComponent("calculator", typeof(ICalcService), typeof(CalculatorService), "Create"); call wouldn't work -- CalculatorService would be internal to another assembly, not available to the assembly wiring up the container.</p>