/src/SampleLibrary/IOC/SampleOpenGenericFactory.cs
http://github.com/philiplaureano/LinFu · C# · 19 lines · 17 code · 2 blank · 0 comment · 0 complexity · 6ea101046044165d351ec7c62bd64d48 MD5 · raw file
- using System;
- using LinFu.IoC.Configuration;
- using LinFu.IoC.Interfaces;
- namespace SampleLibrary
- {
- [Factory(typeof(ISampleGenericService<>))]
- public class SampleOpenGenericFactory : IFactory
- {
- public object CreateInstance(IFactoryRequest request)
- {
- var serviceType = request.ServiceType;
- var typeArgument = serviceType.GetGenericArguments()[0];
- var resultType = typeof(SampleGenericImplementation<>).MakeGenericType(typeArgument);
- return Activator.CreateInstance(resultType);
- }
- }
- }