This file contains hidden or 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 IShape<T> where T : class {} |
This file contains hidden or 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 Rectangle : IShape<Rectangle> | |
| { | |
| public Rectangle() { } | |
| } |
This file contains hidden or 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>, Rectangle>(); | |
| services.AddTransient<IShape<Circle>, Circle>(); |
This file contains hidden or 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)); | |
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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; } | |
| } |
OlderNewer