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.
Dreamine.MVVM.Core provides:
DMContainerstatic facadeDreamineContainerdefault dependency container implementation- 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
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.
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. |
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.
DMContainer.AutoRegisterAll(rootAssembly) scans candidate assemblies and registers supported concrete types.
Auto-registration is implemented through:
AutoRegistrationServiceAssemblyTypeScannerNamingConventionAutoRegistrationFilter
The current naming convention targets concrete non-generic classes whose names or full names match supported Dreamine conventions, including:
*Model*Event*Manager*ViewModel.xaml.Model.xaml.Event.xaml.ViewModel
Matched types are registered using singleton lifetime.
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
└── ServiceRegistry.cs
- .NET:
net8.0
<ItemGroup>
<ProjectReference Include="..\Dreamine.MVVM.Interfaces\Dreamine.MVVM.Interfaces.csproj" />
<ProjectReference Include="..\Dreamine.MVVM.Core\Dreamine.MVVM.Core.csproj" />
</ItemGroup>dotnet add package Dreamine.MVVM.CoreDMContainer.Register<IMyService, MyService>();DMContainer.Register<IMyService>(() => new MyService());var service = new MyService();
DMContainer.RegisterSingleton<IMyService>(service);DMContainer.RegisterSingleton<IMyService, MyService>();IMyService service = DMContainer.Resolve<IMyService>();DMContainer.AutoRegisterAll(typeof(App).Assembly);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 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 creates object instances using constructor injection.
Responsibilities:
- select a constructor through
IConstructorSelector - resolve constructor parameters through
IServiceResolver - create an object instance through reflection
AutoRegistrationService performs convention-based service registration.
Responsibilities:
- scan candidate assemblies
- filter supported concrete types
- register matched types as singleton services
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.InterfacesDreamine.MVVM.AttributesDreamine.MVVM.GeneratorsDreamine.MVVM.LocatorsDreamine.MVVM.Locators.WpfDreamine.MVVM.ViewModelsDreamine.MVVM.Wpf
MIT License