title: How to use Castle Windsor typed factory in this case?
body: <p>Simple DI example:</p>
  
  
  
  <pre><code>public interface INumberToWordConverter
  {
      string ConvertNumber(int number);
  }
  
  public interface IOutputManager
  {
      void Write&lt;T&gt;(string who, T what);
  }
  
  public interface INumberProvider
  {
      int GenerateNumber();
  }
  
  public class PlayWithDI
  {
      private IOutputManager _outputManagerService;
      private INumberProvider _numberProviderService;
      private INumberToWordConverter _numberToWordConverterService;
  
      private PlayWithDI() { }
      public PlayWithDI(
          IOutputManager outputManagerService,
          INumberProvider numberProviderService,
          INumberToWordConverter numberToWordConverterService)
      {
          if (outputManagerService == null)
              throw new ArgumentNullException(nameof(outputManagerService));
          if (numberProviderService == null)
              throw new ArgumentNullException(nameof(numberProviderService));
          if (numberToWordConverterService == null)
              throw new ArgumentNullException(nameof(numberToWordConverterService));
  
          _outputManagerService = outputManagerService;
          _numberProviderService = numberProviderService;
          _numberToWordConverterService = numberToWordConverterService;
      }
  
      public void Execute()
      {
          int number = _numberProviderService.GenerateNumber();
          string wordOfNumber = _numberToWordConverterService.ConvertNumber(number);
          _outputManagerService.Write(nameof(PlayWithDI), wordOfNumber);
      }
  </code></pre>
  
  <p>Example implementations (just ctors):</p>
  
  <pre><code>// Implements INumberProvider
  public RandomNumberProvider(
          int min, int max,
          IOutputManager outputManagerService)
  {
      ...
  }
  
  // Implements INumberToWordConverter
  public ItalianNumberToWordConverter(
        IOutputManager outputManagerService)
  {
      ...
  }
  
  // Implements IConsoleManager
  public ConsoleOutputManager()
  {
      ...
  }
  </code></pre>
  
  <p>If I know which <code>min</code> and <code>max</code> give to <code>RandomNumberProvider</code>, I would just resolve like this:</p>
  
  <pre><code>    public void Install(
          IWindsorContainer container, 
          IConfigurationStore store)
      {
          container.Register(
              Component.For&lt;PlayWithDI&gt;());
  
          container.Register(
              Component.For&lt;IOutputManager&gt;()
              .ImplementedBy&lt;ConsoleOutputManager&gt;());
  
          container.Register(
              Component.For&lt;INumberProvider&gt;()
              .ImplementedBy&lt;RandomNumberProvider&gt;()
              .DependsOn(
                  Dependency.OnValue("min", 2),
                  Dependency.OnValue("max", 20)));
  
          container.Register(
              Component.For&lt;INumberToWordConverter&gt;()
              .ImplementedBy&lt;ItalianNumberToWordConverter&gt;());
      }
  
  ...
  container.Install(new DependenciesConfiguration1());
  var testDI = container.Resolve&lt;PlayWithDI&gt;();
  testDI.Execute();
  </code></pre>
  
  <p>The problem arises when I want to give custom parameters to <code>RandomNumberProvider</code> at runtime.</p>
  
  <p>I took a look at <code>TypedFactory</code>, but I don't really understand it in this example, because if I resolve a factory first, how should I then resolve PlayWithDi? Should I pass to its constructor an INumberProviderFactory instead of an INumberProvider? </p>
  
  <p>In this case I thought about a factory like this:</p>
  
  <pre><code>public interface INumberProviderFactory
  {
      INumberProvider Create(
          IOutputManager outputManager, 
          int min, int max);
  }
  </code></pre>
  
  <p>When I'll then call <code>Create</code>, how should I resolve the <code>outputManager</code> then? I'm confused.</p>