Jamesnet.Foundation
is a core library that provides common functionality across various platforms. It is referenced by several platform-specific projects, which utilize its essential features.
Note: NuGet publish date information is not available, so it is not included.
- Jamesnet.Platform.OpenSilver
- Jamesnet.Platform.Wpf
- Jamesnet.Platform.Uno
- Jamesnet.Platform.Uwp
- Jamesnet.Platform.WinUI3
Install the package using the NuGet Package Manager:
Install-Package Jamesnet.Foundation
For WPF projects, you should also install the following package:
Install-Package Jamesnet.Platform.Wpf
Jamesnet.Foundation
supports application initialization through the AppBootstrapper
class. The following example demonstrates how to extend AppBootstrapper
in a WPF project for initialization.
Note: There is no need to explain the
virtual
keyword or the oldSetMainWindow
approach.
using Jamesnet.Foundation;
using Jamesnet.Platform.Wpf; // WPF platform package reference
namespace MyApp
{
public class MyAppBootstrapper : AppBootstrapper
{
protected override void RegisterViewModels()
{
// Map the view to the view model.
ViewModelMapper.Register<MainContent, MainViewModel>();
}
protected override void RegisterDependencies(IContainer container)
{
// Register MainContent as the IView implementation with the key "MainContent".
Container.RegisterSingleton<IView, MainContent>("MainContent");
}
protected override void SettingsLayer(ILayerManager layer, IContainer container)
{
// Perform mapping using the "Main" key.
Mapping("Main", container.Resolve<IView>("MainContent"));
}
}
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var bootstrapper = new MyAppBootstrapper();
bootstrapper.Run(); // Execute application initialization
}
}
}
In this example:
- Dependency Registration:
Container.RegisterSingleton<IView, MainContent>("MainContent");
registersMainContent
as an implementation of theIView
interface with the key"MainContent"
. - View-ViewModel Mapping:
ViewModelMapper.Register<MainContent, MainViewModel>();
maps theMainContent
view to theMainViewModel
. - Layer Settings:
Mapping("Main", container.Resolve<IView>("MainContent"));
sets up the mapping for the "Main" layer using the registered view.