I would add the Draw() method to the interface and implement it in each of your classes.
The advantage of this is that your View doesn't care what the actual type is.
public interface IDrawing { void Draw(); } public class TextDrawing : IDrawing { public void Draw() {
UPDATE - drop SkiaSharp addiction
You will need to create a wrapper for SkiaSharp or any external dependency that actually does the drawing. This should exist in the same assembly as your IDrawing interface and derived classes.
public interface IDrawingContext {
In addition to the specific implementation of SkiaSharp
public class SkiaSharpDrawingContext IDrawingContext {
Update the IDrawing interface to
public interface IDrawing { void Draw(IDrawingContext drawingContext); }
Updating your classes to reflect this change. Your classes will call IDrawingContext implementation methods to draw the drawing.
Create a specific dependency implementation in your applications and update your View class to use the new SkiaSharpDrawingContext
public class View { public void Draw(IDrawing drawing) {
phuzi source share