using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using StructureHelper.Infrastructure.UI.DataContexts; using StructureHelperCommon.Models.NdmPrimitives; using StructureHelperCommon.Models.Shapes; using Point = StructureHelper.Infrastructure.UI.DataContexts.Point; using Rectangle = StructureHelper.Infrastructure.UI.DataContexts.Rectangle; namespace StructureHelper.Services { public interface IPrimitiveRepository { void Add(PrimitiveBase primitive); void Delete(PrimitiveBase primitive); IEnumerable GetPoints(); IEnumerable GetRectangles(); } class PrimitiveRepository : IPrimitiveRepository { List points = new List(); List rectangles = new List(); public void Add(PrimitiveBase primitive) { switch (primitive) { case Point point: points.Add(point); break; case Rectangle rectangle: rectangles.Add(rectangle); break; } } public void Delete(PrimitiveBase primitive) { switch (primitive) { case Point point: points.Remove(point); break; case Rectangle rectangle: rectangles.Remove(rectangle); break; } } public IEnumerable GetPoints() => points; public IEnumerable GetRectangles() => rectangles; } }