Oakrey.Applications.Base 4.0.3

dotnet add package Oakrey.Applications.Base --version 4.0.3
                    
NuGet\Install-Package Oakrey.Applications.Base -Version 4.0.3
                    
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="Oakrey.Applications.Base" Version="4.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Oakrey.Applications.Base" Version="4.0.3" />
                    
Directory.Packages.props
<PackageReference Include="Oakrey.Applications.Base" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Oakrey.Applications.Base --version 4.0.3
                    
#r "nuget: Oakrey.Applications.Base, 4.0.3"
                    
#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.
#:package Oakrey.Applications.Base@4.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Oakrey.Applications.Base&version=4.0.3
                    
Install as a Cake Addin
#tool nuget:?package=Oakrey.Applications.Base&version=4.0.3
                    
Install as a Cake Tool

Oakrey.Applications.Base

A foundational .NET library for building modular WPF applications. It provides application lifecycle management, structured logging and telemetry, MVVM ViewModel resolution, service preloading with error diagnostics, and a set of WPF utilities.

Main features

  • Application base classOakreyApplication extends System.Windows.Application and wires up DI, logging, telemetry, and all unhandled-exception handlers in one place.
  • Application metadataIApplicationInfo / AppInfoBase expose name, version, log paths, settings paths, deployment URL, and application logo.
  • ViewModel resolutionViewModelProvider is a XAML markup extension that resolves ViewModels from the DI container, creates a scoped lifetime per FrameworkElement, and disposes it on Unloaded.
  • Service preloadingIPreLoadable contract with observable error propagation. Sequential (TryPreloadServices) and parallel (TryPreloadServicesParallel) strategies. Aggregates errors and shuts down gracefully if preloading fails.
  • Logging and telemetry � integrates Oakrey.Log (file + WPF queue loggers) and Oakrey.Telemetry tracing. Debug builds automatically lower the log threshold to Trace.
  • WPF behaviors and extensionsBindableSelectedItemBehavior for two-way binding of TreeView.SelectedItem; KeyboardExtension for detecting keyboard shortcut combinations.
  • Path helpersPathsAndNames centralises assembly name, default settings directory, and per-user %AppData% settings path resolution.

Architecture

classDiagram
    class OakreyApplication {
        +IServiceProvider Services
        +GetService~T~()
        #App_Startup()
        #AppStartup(CancellationToken) Task
        #SetLoggers()
        #TryPreloadServices(CancellationToken, Type[]) Task
        #TryPreloadServicesParallel(CancellationToken, Type[]) Task
    }

    class IApplicationInfo {
        +Name : string
        +Version : string
        +LogFilePath : FileInfo
        +LogDirectoryPath : DirectoryInfo
        +UserSettingsPath : string
        +DefaultSettingsPath : string
        +DeploymentUrl : string
        +Logo : BitmapImage
    }

    class AppInfoBase {
        <<abstract>>
    }

    class IPreLoadable {
        <<interface>>
        +Preload(CancellationToken) Task
    }

    class ViewModelProvider {
        <<MarkupExtension>>
        +ViewModelType : Type
        +ProvideValue() object
    }

    class PreLoadingException {
        +Details : string
    }

    OakreyApplication --> IApplicationInfo : resolves
    OakreyApplication --> IPreLoadable : preloads
    OakreyApplication ..> PreLoadingException : observes
    AppInfoBase ..|> IApplicationInfo
    IPreLoadable ..> PreLoadingException : publishes
    ViewModelProvider --> IServiceProvider : resolves from

Requirements

  • .NET 10 or higher
  • Windows (WPF target: net10.0-windows)

Installation

NuGet Package Manager

  1. Open Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
  2. Search for Oakrey.Applications.Base and click Install.

.NET CLI

dotnet add package Oakrey.Applications.Base

Package Manager Console

Install-Package Oakrey.Applications.Base

Usage

1. Implement application metadata

public class MyAppInfo : AppInfoBase, IApplicationInfo
{
    public override string DeploymentUrl => "https://deploy.example.com/";
}

2. Register services and subclass OakreyApplication

public partial class App : OakreyApplication
{
    public App() : base(ConfigureServices) { }

    private static void ConfigureServices(IServiceCollection services)
    {
        services.AddSingleton<IApplicationInfo, MyAppInfo>();
        services.AddSingleton<WpfQueueLogger>();
        // register your own services here
    }

    protected override async Task AppStartup(CancellationToken cancellationToken)
    {
        await TryPreloadServices(cancellationToken, typeof(IMyPreloadable));
        Current.MainWindow = new MainWindow();
        Current.MainWindow.Show();
    }
}

In App.xaml set x:Class="MyApp.App" and remove the default StartupUri. Wire the startup event:

<local:App x:Class="MyApp.App"
           xmlns:local="clr-namespace:MyApp"
           Startup="App_Startup">
</local:App>

3. Resolve ViewModels in XAML

<Window xmlns:app="clr-namespace:Oakrey.Applications;assembly=Oakrey.Applications.Base"
        DataContext="{app:ViewModelProvider viewModelType={x:Type local:MainViewModel}}">

The ViewModel is resolved from the DI container in a new scope. The scope is disposed automatically when the Window unloads.

4. Implement a preloadable service

public class MyStartupService : IPreLoadable
{
    private readonly Subject<PreLoadingException> _errors = new();

    public IDisposable Subscribe(IObserver<PreLoadingException> observer)
        => _errors.Subscribe(observer);

    public async Task Preload(CancellationToken cancellationToken)
    {
        // perform startup work; publish to _errors on failure
        await Task.CompletedTask;
    }
}

Register it with the DI container and pass its interface to TryPreloadServices.

5. Bind TreeView selected item

<TreeView>
    <i:Interaction.Behaviors>
        <app:BindableSelectedItemBehavior SelectedItem="{Binding SelectedNode, Mode=TwoWay}" />
    </i:Interaction.Behaviors>
</TreeView>

Configuration

Setting Location Description
Default settings AppInfoBase.DefaultSettingsPath <app base dir>/DefaultSettings.json
User settings AppInfoBase.UserSettingsPath %AppData%/<AppName>/Settings.json
Log files AppInfoBase.LogFilePath %LocalAppData%/<AppName>/Logs/LOG-<timestamp>.txt
Log threshold LoggerFactory.GlobalThreshold Set to Trace automatically when a debugger is attached

Development notes

  • The library targets net10.0-windows and has a hard dependency on WPF; it cannot be used in non-Windows or non-WPF projects.
  • PathsAndNames reads from the entry assembly. In unit test hosts this may throw InvalidOperationException; mock IApplicationInfo instead of relying on AppInfoBase directly in tests.
  • Unhandled exceptions from the UI thread, TaskScheduler, and AppDomain are all caught, logged, and marked as handled. Override the relevant handlers in a subclass to add custom recovery logic.
  • The DI container is built once in the constructor and is available via Services. CommunityToolkit Ioc.Default is also configured during startup for XAML-friendly access.

License

MIT. Copyright (c) Oakrey 2016-present.

Repository: https://dev.azure.com/oakrey/OpenPackages/_git/ApplicationServices

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

NuGet packages (9)

Showing the top 5 NuGet packages that depend on Oakrey.Applications.Base:

Package Downloads
Oakrey.Applications.Settings

WPF-only (.NET 10 Windows) library providing ISettingsService with persistent and volatile typed key-value settings, SettingsBase for bindable ViewModelBase-derived settings classes, CallerMemberName key inference, built-in window bounds restore via RestoreBounds, and a one-call ConfigureSettingService DI extension.

Oakrey.Applications.SplashScreen

Windows (.NET 10, WPF) library for async splash screens with parallel preload tasks and MSI update flow. Generic SplashScreenService<T> integrates IApplicationInfo metadata, Oakrey.Log, and Oakrey.Telemetry; registers via a single IServiceCollection extension.

Oakrey.Applications.Help

A WPF/.NET library for loading, navigating, and displaying hierarchical Markdown-based help content, with ViewModel integration, navigation history, and logging support.

Oakrey.Applications.About

A WPF/.NET library providing an About dialog with application name and version display, loaded assembly/module version listing, RTF EULA rendering, and a Report Issue form with log folder access.

Oakrey.Applications.Git

A .NET library for managing Git repositories programmatically. Supports multi-repository management, credential handling, branch discovery, commit operations, reactive error streams, and WPF binding via INotifyPropertyChanged. Integrates with Oakrey logging and telemetry.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.3 62 5/15/2026
4.0.2 137 3/13/2026
4.0.1 148 2/11/2026
4.0.0 457 11/18/2025
3.0.2 199 10/10/2025
3.0.1 274 9/29/2025
3.0.0 234 9/5/2025
2.1.0 190 8/15/2025
2.0.1 295 8/6/2025
2.0.0 352 6/9/2025
1.0.0 302 4/17/2025