Adita.PlexNet.Wpf.Hosting 1.0.0

dotnet add package Adita.PlexNet.Wpf.Hosting --version 1.0.0                
NuGet\Install-Package Adita.PlexNet.Wpf.Hosting -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Adita.PlexNet.Wpf.Hosting" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Adita.PlexNet.Wpf.Hosting --version 1.0.0                
#r "nuget: Adita.PlexNet.Wpf.Hosting, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Adita.PlexNet.Wpf.Hosting as a Cake Addin
#addin nuget:?package=Adita.PlexNet.Wpf.Hosting&version=1.0.0

// Install Adita.PlexNet.Wpf.Hosting as a Cake Tool
#tool nuget:?package=Adita.PlexNet.Wpf.Hosting&version=1.0.0                

Adita.PlexNet.Wpf.Hosting

A WPF hosting library for PlexNet framework that targeting .NET 6

How to use

  1. Implement Adita.PlexNet.Wpf.Hosting.IApplication to your App.xaml.cs

         public partial class App : Application, IApplication
         {
             //...
    
             public IServiceProvider ServiceProvider { get; private set; } = default!;
             public IConfiguration Configuration { get; private set; } = default!;
    
             public void SetConfiguration(IConfiguration configuration)
             {
                 Configuration = configuration;
             }
    
             public void SetServiceProvider(IServiceProvider serviceProvider)
             {
                 ServiceProvider = serviceProvider;
             }
         }
    
  2. Create a class to override entry point of application with Main() method

    Example:

    	public static void Main()
        {
            IApplicationBuilder<App> builder = new ApplicationBuilder<App>();
    
            //setup configuration
            string appSettingsPath = Path.Combine(Environment.CurrentDirectory, "AppSettings.json");
    
            builder.ConfigureAppConfiguration(configBuilder =>
            {
                configBuilder.SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile(appSettingsPath, optional: false, reloadOnChange: true);
            });
    
            //add services
            builder.ConfigureServices(services =>
            {
                services.AddSingleton<MainViewModel>();
                services.Configure<TestOptions>(builder.Configuration.GetSection(nameof(TestOptions)));
            });
    
            App application = builder.Build();
    
             //if App has components such as StartupUri, subscribes event handler to event(s) or others in here need to call InitializeComponent()
            //InitializeComponent method of App class only will generated after build if any component exist.
            //Note: if you delete the StartupUri on App.xaml you need to handle Startup event, otherwise InitializeComponent will never be generated
            //and your app resource will not be initialized too, this is such as bugs of wpf!!!.
    
            application.InitializeComponent();
    
            application.Run();
        }
    
    
  3. Override StartupObject on project properties to your new entry point class

    example:

        <StartupObject>Adita.PlexNet.Wpf.Hosting.Sample.Startup</StartupObject>
    
    

Sample project

Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 256 10/26/2022

First release.