ForNeVeR / xaml-math

A collection of .NET libraries for rendering mathematical formulae using the LaTeX typesetting style, for the WPF and Avalonia XAML-based frameworks
MIT License
641 stars 102 forks source link

Investigate generic-based approach instead of marker interfaces #342

Open ForNeVeR opened 1 year ago

ForNeVeR commented 1 year ago

Since #327, we have several marker interfaces in our code, such as:

They work in a similar way: an implementation (say, WPF) creates them from a platform-specific wrappers (say, WpfBrush that wraps a WPF Brush instance), and then an implementation-issued renderer casts them back to these types to unpack and use.

This involves a lot of unsafe casting, and it's possible to imagine this all getting messed up in a multiplatform application.

We could investigate using more generics instead. For example, it could be possible to parametrize the IElementRenderer with <TBrush, TFontTypeface>.

I'm not sure that storing and passing around a lot of generic parameters is such a good idea. But still, I'd like to investigate this approach.