We are currently in the process of refactoring MAUIsland, but we have encountered a challenge regarding ViewModels. Our intention is to centralize these ViewModels within the core framework, allowing them to be reused across different MAUI projects in the future.
However, this has resulted in the ViewModels being in different namespaces. Renaming from MAUIsland to MAUIsland.Core has caused issues with the extension method RegisterPages not being able to register properly. As our expertise lies more in assembly, we have yet to find a solution to address this.
static MauiAppBuilder RegisterPages(this MauiAppBuilder builder, string pattern = "Page")
{
var assemblies = new Assembly[] { typeof(MauiProgram).Assembly };
var pageTypes = assemblies.SelectMany(a => a.GetTypes().Where(a => a.Name.EndsWith(pattern) && !a.IsAbstract && !a.IsInterface));
foreach (var pageType in pageTypes)
{
var viewModelFullName = $"{pageType.FullName}ViewModel";
var viewModelType = Type.GetType(viewModelFullName);
builder.Services.AddTransient(pageType);
if (viewModelType != null)
builder.Services.AddTransient(viewModelType);
if (pageType.IsAssignableTo(typeof(IGalleryPage)))
{
Routing.RegisterRoute(pageType.FullName, pageType);
}
}
return builder;
}
Could you please assist us with this matter whenever you have some free time?
Version
7.0
What platforms are you seeing the problem on?
Windows
Relevant log output
None
Code of Conduct
[X] I agree to respect and follow this project's rules
Contact Details
futurewingsstrypper@outlook.com
What happened?
We are currently in the process of refactoring MAUIsland, but we have encountered a challenge regarding ViewModels. Our intention is to centralize these ViewModels within the core framework, allowing them to be reused across different MAUI projects in the future.
However, this has resulted in the ViewModels being in different namespaces. Renaming from MAUIsland to MAUIsland.Core has caused issues with the extension method RegisterPages not being able to register properly. As our expertise lies more in assembly, we have yet to find a solution to address this.
Could you please assist us with this matter whenever you have some free time?
Version
7.0
What platforms are you seeing the problem on?
Windows
Relevant log output
Code of Conduct