namespace Chernobyl.Creation { /// /// An that wraps an /// so that the /// can be used as if it takes an argument. This type is an implementation /// of the composite pattern (http://en.wikipedia.org/wiki/Composite_pattern). /// public class ArgumentedFactory : Builder, IFactory { /// /// Initializes a new instance of the /// class. /// /// The that is to /// be wrapped. public ArgumentedFactory(IFactory factory) { factory.ThrowIfNull("factory"); _factory = factory; _factory.Created += OnCreated; } /// public TResult Create(T1 arg1) => _factory.Create(); // Forwards creation events from the decorated factory through this instance. void OnCreated(object sender, CreationEventArgs e) => CreatedMethod?.Invoke(this, e); readonly IFactory _factory; } /// /// Extensions for the type. /// public static class ArgumentedFactoryExtensions { /// /// Converts the passed in to an /// whose /// is ignored. /// public static IFactory AsArgumented(this IFactory factory) => new ArgumentedFactory(factory); } }