/src/SampleLibrary/SampleOpenGenericFactory.cs
C# | 22 lines | 18 code | 4 blank | 0 comment | 0 complexity | a6bb9070fc647f6b8c10b099692ea13f MD5 | raw file
1using System; 2using LinFu.IoC.Configuration; 3using LinFu.IoC.Interfaces; 4 5namespace SampleLibrary 6{ 7 [Factory(typeof(ISampleGenericService<>))] 8 public class SampleOpenGenericFactory : IFactory 9 { 10 #region IFactory Members 11 12 public object CreateInstance(Type serviceType, IContainer container) 13 { 14 Type typeArgument = serviceType.GetGenericArguments()[0]; 15 Type actualType = typeof(SampleGenericImplementation<>).MakeGenericType(typeArgument); 16 17 return Activator.CreateInstance(actualType); 18 } 19 20 #endregion 21 } 22}