/src/SampleLibrary/IOC/SampleFactoryWithConstructorArguments.cs

http://github.com/philiplaureano/LinFu · C# · 26 lines · 21 code · 5 blank · 0 comment · 2 complexity · 60df036951024cc7846dafc833e490af MD5 · raw file

  1. using System;
  2. using LinFu.IoC.Configuration;
  3. using LinFu.IoC.Interfaces;
  4. namespace SampleLibrary.IOC
  5. {
  6. [Factory(typeof(string), ServiceName = "SampleFactoryWithConstructorArguments")]
  7. public class SampleFactoryWithConstructorArguments : IFactory
  8. {
  9. public ISampleService _sample;
  10. public SampleFactoryWithConstructorArguments(ISampleService service)
  11. {
  12. if (service == null)
  13. throw new ArgumentNullException("service");
  14. _sample = service;
  15. }
  16. public object CreateInstance(IFactoryRequest request)
  17. {
  18. return "42";
  19. }
  20. }
  21. }