public WhenRegisteringMixedTypedFactoryServicesWithoutAContext(ITestOutputHelper output) { _container = new RegistrationSetup() // Add the simple registration, these should be superseded by the factory mappings. .Register <Service1>() .Register <Service2>() .Register <IService3, Service3>() // Register the factories .RegisterFactory(typeof(InternalService1), () => new InternalService1(), c => c.Internal()) .RegisterFactory(Service1.CreateService1WithoutContext) .RegisterFactory(typeof(Service2), Service2.CreateService2WithoutContext) .RegisterFactory <IService3, Service3>(Service3.CreateService3WithoutContext) .Register(typeof(DependentService)) .Construct(GetType().GetTypeInfo().Assembly, out string code); output.WriteLine(code); }
/// <summary> /// Constructs an <see cref="AbiocContainer"/> from the registration <paramref name="setup"/>. /// </summary> /// <param name="setup">The <see cref="RegistrationSetup"/>.</param> /// <param name="srcAssemblies">The source assemblies for the types top create.</param> /// <param name="code">The generated source code.</param> /// <returns> /// A <see cref="AbiocContainer"/> constructed from the registration <paramref name="setup"/>. /// </returns> public static AbiocContainer Construct( this RegistrationSetup setup, Assembly[] srcAssemblies, out string code) { if (setup == null) { throw new ArgumentNullException(nameof(setup)); } if (srcAssemblies == null) { throw new ArgumentNullException(nameof(srcAssemblies)); } (string generatedCode, object[] fieldValues) = setup.Compose().GenerateCode(); code = generatedCode; AbiocContainer container = CodeCompilation.Compile(setup, code, fieldValues, srcAssemblies); return(container); }