This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Machine | |
{ | |
public Machine() | |
{ | |
} | |
private string Components { get; set; } | |
public List<string> GetComponents() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private readonly ICustomers _service; | |
public Client() | |
{ | |
//Al estar accesibles de forma pública las implementaciones, un programador "despistado" | |
//podría saltarse el flujo de inversión de control y crear los objetos "a mano" mediante new | |
this._service = new Customers(new CustomerRepository()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services.AddTransient<IShapeFactory<Rectangle>, RectangleFactory>(); | |
services.AddTransient<IShapeFactory<Circle>, CircleFactory>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RectangleParameters : IShapeParameters | |
{ | |
public double width { get; set; } | |
public double height { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private readonly IShape _rectangle; | |
private readonly IShape _circle; | |
public WindowManager(IShape rectangle, IShape circle) | |
{ | |
this._rectangle = rectangle ?? throw new ArgumentNullException(nameof(rectangle)); | |
this._circle = cirlce ?? throw new ArgumentNullException(nameof(circle)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services.AddTransient<IShape, Rectangle>(); | |
services.AddTransient<IShape, Circle>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IShapeParameters { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WindowManager | |
{ | |
private readonly IShapeFactory<Rectangle> _rectangleFactory; | |
private readonly IShapeFactory<Cirlce> _CircleFactory; | |
public WindowManager(IShapeFactory<Rectangle> rectangleFactory, IShapeFactory<Cirlce> CirlceFactory) | |
{ | |
this._rectangleFactory = rectangleFactory ?? throw new ArgumentNullException(nameof(rectangleFactory)); | |
this._CircleFactory = CirlceFactory ?? throw new ArgumentNullException(nameof(CirlceFactory)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IShapeFactory<T> where T : IShape | |
{ | |
IShape CreateShape(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private readonly IShape<Rectangle> _rectangle; | |
private readonly IShape<Circle> _circle; | |
public WindowManager(IShape<Rectangle> rectangle, IShape<Circle> circle) | |
{ | |
this._rectangle = rectangle ?? throw new ArgumentNullException(nameof(rectangle)); | |
this._circle = circle ?? throw new ArgumentNullException(nameof(circle)); | |
} |
NewerOlder