Git Product home page Git Product logo

adita.plexnet.wpf.hosting's Introduction

Adita.PlexNet.Wpf.Hosting

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

How to use

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

         public partial class App : Application, IWpfApplication
         {
             //...
         
             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

adita.plexnet.wpf.hosting's People

Contributors

sans-eng avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.