I have developed utility source code to work with WebView2 component, and I want to use it in 2 different projects, one is WPF, the other WinForms.
The problem is that WebView2 asks for different "using", one for each project.
In the WPF class, I have to set the "using" this way:
using Microsoft.Web.WebView2.Wpf; // NOTE!!!
namespace Utility
{
public static class WebView2_Helper
{
...
(code here, using the WebView2 component)
...
}
}
And for the WinForms, I have to create another file and duplicate all the code, just to change the "using"...:
using Microsoft.Web.WebView2.WinForms; // NOTE!!!
namespace Utility
{
public static class WebView2_Helper
{
...
(code here... same as above!)
...
}
}
The code after the "using" is the same, in both cases.
In C/C++, a solution could be saving the common code to a file, and then include it inside both classes.
What should be the solution in C#?