/src/LinFu.IoC/FactoryExtensions.cs
http://github.com/philiplaureano/LinFu · C# · 32 lines · 19 code · 2 blank · 11 comment · 0 complexity · c37d6ba90a2821543f29e69bc5714011 MD5 · raw file
- using System;
- using LinFu.IoC.Interfaces;
- namespace LinFu.IoC
- {
- /// <summary>
- /// Extends the <see cref="IFactory" /> instance with a few helper methods.
- /// </summary>
- public static class FactoryExtensions
- {
- /// <summary>
- /// Creates an object instance.
- /// </summary>
- /// <param name="factory">The target factory.</param>
- /// <param name="serviceType">The requested service type.</param>
- /// <param name="container">The target service contaienr.</param>
- /// <param name="additionalArguments">The additional arguments that will be used to create the service instance.</param>
- /// <returns>A service instance.</returns>
- public static object CreateInstance(this IFactory factory, Type serviceType,
- IServiceContainer container, params object[] additionalArguments)
- {
- var request = new FactoryRequest
- {
- ServiceName = null,
- ServiceType = serviceType,
- Arguments = additionalArguments
- };
- return factory.CreateInstance(request);
- }
- }
- }