using System; namespace Chernobyl.Creation { /// /// Converts the result from a /// to a /// result. /// /// The type of from result. /// The type of to result. /// The type of the 1. public class ResultConversionFactory : Builder, IFactory { /// The instance whose result is to be converted. /// The instance that converts the result from /// a factory from one type to another. public ResultConversionFactory(IFactory fromFactory, Func converter) { fromFactory.ThrowIfNull("fromFactory"); _fromFactory = fromFactory; converter.ThrowIfNull("converter"); _converter = converter; } /// public TToResult Create(T1 arg1) { var result = _converter(_fromFactory.Create(arg1)); ReportCreation(result); return result; } /// /// The instance whose result is to be converted. /// readonly IFactory _fromFactory; /// /// The instance that converts the /// result from a to a /// result. /// readonly Func _converter; } }