Dreamine.MVVM.Core 1.0.13

dotnet add package Dreamine.MVVM.Core --version 1.0.13
                    
NuGet\Install-Package Dreamine.MVVM.Core -Version 1.0.13
                    
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="Dreamine.MVVM.Core" Version="1.0.13" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dreamine.MVVM.Core" Version="1.0.13" />
                    
Directory.Packages.props
<PackageReference Include="Dreamine.MVVM.Core" />
                    
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 Dreamine.MVVM.Core --version 1.0.13
                    
#r "nuget: Dreamine.MVVM.Core, 1.0.13"
                    
#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 Dreamine.MVVM.Core@1.0.13
                    
#: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=Dreamine.MVVM.Core&version=1.0.13
                    
Install as a Cake Addin
#tool nuget:?package=Dreamine.MVVM.Core&version=1.0.13
                    
Install as a Cake Tool

Dreamine.MVVM.Core

Dreamine.MVVM.Core is the lightweight runtime infrastructure module of the Dreamine MVVM framework.

It provides the default dependency injection implementation used by Dreamine modules, including explicit service registration, constructor-based resolution, singleton instance handling, object activation, and convention-based auto-registration.

This package is intentionally focused on runtime infrastructure. It must remain independent from WPF-specific UI concepts such as Window, UserControl, FrameworkElement, ContentControl, and DataContext.

➡️ 한국어 문서 보기


What this library provides

Dreamine.MVVM.Core provides:

  • DMContainer static facade
  • DreamineContainer default dependency container implementation
  • thread-safe registration, resolution, and singleton creation
  • transient service registration
  • singleton service registration
  • factory-based service registration
  • constructor-based dependency resolution
  • singleton instance caching
  • circular dependency detection
  • convention-based auto-registration
  • assembly type scanning
  • object activation through IObjectActivator
  • static facade reset and container replacement APIs for test isolation

Package Role

Dreamine.MVVM.Core implements infrastructure contracts defined by Dreamine.MVVM.Interfaces.

Recommended dependency direction:

Dreamine.MVVM.Interfaces
        ↑
Dreamine.MVVM.Core
        ↑
Dreamine.MVVM.Wpf / Dreamine.MVVM.Locators / Application modules

Dreamine.MVVM.Core should not contain WPF-specific binding or navigation logic. WPF-specific behavior belongs in WPF-focused packages.


Service Lifetime Policy

Dreamine.MVVM.Core uses explicit lifetime behavior.

Registration API Lifetime Notes
Register<TImplementation>() Transient Creates a new instance when resolved.
Register<TService, TImplementation>() Transient Uses abstraction-to-implementation mapping.
Register<TService>(Func<TService>) Transient Executes the factory whenever resolved.
RegisterSingleton<TService>(TService) Singleton Stores the provided instance.
RegisterSingleton<TImplementation>() Singleton Creates and caches one instance on first resolve.
RegisterSingleton<TService, TImplementation>() Singleton Abstraction-to-implementation singleton mapping.
AutoRegisterAll(Assembly) Singleton for matched types Preserves Dreamine auto-registration behavior.
DMContainer.Reset() Static facade reset Replaces the global container with an empty DreamineContainer.
DMContainer.SetContainer(IServiceContainer) Static facade replacement Allows tests or hosts to provide an isolated container.

Important: auto-registered types are registered as singleton services by default. This keeps automatically discovered ViewModels, Models, Events, and Managers stable across repeated resolution unless the application explicitly registers another lifetime.

DreamineContainer serializes registration and resolution internally. Singleton lazy creation is guarded so concurrent first resolves produce one shared instance. Circular dependency detection is stored in a per-resolution context instead of shared container state.


Auto-Registration

DMContainer.AutoRegisterAll(rootAssembly) scans candidate assemblies and registers supported concrete types.

Auto-registration is implemented through:

  • AutoRegistrationService
  • AssemblyTypeScanner
  • NamingConventionAutoRegistrationFilter

The current naming convention targets concrete non-generic classes whose names or full names match supported Dreamine conventions, including:

  • *Model
  • *Event
  • *ViewModel
  • *Manager only when the type is under a .Managers. or .xaml. namespace
  • .xaml.Model
  • .xaml.Event
  • .xaml.ViewModel
  • types marked with an attribute named DreamineRegisterAttribute or DreamineAutoRegisterAttribute

Matched types are registered using singleton lifetime.


Project Structure

Dreamine.MVVM.Core
├── DMContainer.cs
├── AutoRegistration
│   ├── AssemblyTypeScanner.cs
│   ├── AutoRegistrationService.cs
│   └── NamingConventionAutoRegistrationFilter.cs
└── DependencyInjection
    ├── ConstructorActivator.cs
    ├── ConstructorSelector.cs
    ├── DreamineContainer.cs
    ├── ResolutionContext.cs
    ├── ServiceDescriptor.cs
    └── ServiceLifetime.cs

Requirements

  • .NET: net8.0

Installation

Project Reference

<ItemGroup>
  <ProjectReference Include="..\Dreamine.MVVM.Interfaces\Dreamine.MVVM.Interfaces.csproj" />
  <ProjectReference Include="..\Dreamine.MVVM.Core\Dreamine.MVVM.Core.csproj" />
</ItemGroup>

NuGet

dotnet add package Dreamine.MVVM.Core

Quick Start

Register a transient service

DMContainer.Register<IMyService, MyService>();

Register a factory

DMContainer.Register<IMyService>(() => new MyService());

Register a singleton instance

var service = new MyService();
DMContainer.RegisterSingleton<IMyService>(service);

Register a singleton type

DMContainer.RegisterSingleton<IMyService, MyService>();

Resolve a service

IMyService service = DMContainer.Resolve<IMyService>();

Auto-register Dreamine application types

DMContainer.AutoRegisterAll(typeof(App).Assembly);

Reset the static facade in tests

DMContainer.Reset();

Replace the static facade container

DMContainer.SetContainer(new DreamineContainer());

Component Reference

DMContainer

DMContainer is a static facade over the default DreamineContainer instance.

Its role is to preserve simple application-level usage while delegating actual behavior to focused infrastructure components.

DMContainer should remain thin. It should not directly contain assembly scanning, constructor selection, object activation, or lifetime-management logic.


DreamineContainer

DreamineContainer is the default dependency container implementation.

Responsibilities:

  • store service descriptors
  • resolve registered services
  • resolve constructor dependencies
  • cache singleton instances
  • create transient instances
  • detect circular dependencies during resolution
  • delegate object creation to IObjectActivator

ConstructorActivator

ConstructorActivator creates object instances using constructor injection.

Responsibilities:

  • select a constructor through IConstructorSelector
  • resolve constructor parameters through IServiceResolver
  • create an object instance through reflection

AutoRegistrationService

AutoRegistrationService performs convention-based service registration.

Responsibilities:

  • scan candidate assemblies
  • filter supported concrete types
  • register matched types as singleton services

Design Goals

Dreamine.MVVM.Core prioritizes:

  • explicit behavior over hidden runtime magic
  • low dependency surface
  • constructor-based composition
  • interface-driven infrastructure
  • predictable service lifetime behavior
  • compatibility with Dreamine auto-registration
  • separation between contracts and implementations
  • independence from WPF-specific UI concerns

Typical composition with other Dreamine packages:

  • Dreamine.MVVM.Interfaces
  • Dreamine.MVVM.Attributes
  • Dreamine.MVVM.Generators
  • Dreamine.MVVM.Locators
  • Dreamine.MVVM.Locators.Wpf
  • Dreamine.MVVM.ViewModels
  • Dreamine.MVVM.Wpf

License

MIT License

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on Dreamine.MVVM.Core:

Package Downloads
Dreamine.MVVM.FullKit

All-in-one package for Dreamine MVVM on WPF. Includes core MVVM modules and automatic source generator integration.

Dreamine.MVVM.Wpf

WPF-specific bootstrap and runtime integration layer for the Dreamine MVVM framework.

Dreamine.Logging

WPF logging UI for Dreamine applications: log panel view and view model with bounded display capacity, batched UI dispatcher to coalesce high-frequency log updates, and AutoScroll/EntryAppended hooks.

Dreamine.Threading.Wpf

WPF monitoring UI components for Dreamine threading infrastructure.

Dreamine.Threading.Windows

Windows-specific threading services for Dreamine, including CPU affinity and timer resolution integration.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.13 210 7/8/2026
1.0.12 220 5/9/2026
1.0.11 118 4/30/2026
1.0.10 122 4/29/2026
1.0.9 131 3/24/2026
1.0.8 126 3/21/2026
1.0.7 119 2/20/2026
1.0.6 120 2/18/2026
1.0.5 208 6/6/2025
1.0.4 178 5/31/2025
1.0.3 220 5/29/2025
1.0.2 226 5/26/2025
1.0.1 218 5/25/2025
1.0.0 217 5/25/2025