iconDreamine
← 목록

Dreamine.MVVM.Interfaces

stablev1.0.7

IViewModel, INavigationService 등 핵심 추상화 인터페이스 모음.

#commands#di#dreamine#events#interfaces#mvvm#navigation
TFM net8.0Package Dreamine.MVVM.Interfaces

Dreamine.MVVM.Interfaces

Dreamine.MVVM.Interfaces는 Dreamine MVVM 프레임워크 전반에서 사용하는 공유 추상 계약을 정의합니다.

이 패키지는 계약만 포함합니다. 구체 의존성 컨테이너, WPF 내비게이션 구현체, ViewModel Locator 구현체, 런타임 객체 생성 로직은 제공하지 않습니다.

이 패키지의 목적은 Dreamine 모듈 간 결합도를 낮추고 프레임워크 레이어 사이의 올바른 의존성 방향을 유지하는 것입니다.

➡️ English Version


이 라이브러리가 제공하는 것

Dreamine.MVVM.Interfaces는 다음 계약을 제공합니다.

  • 의존성 등록
  • 의존성 해석
  • 서비스 컨테이너 구성
  • 생성자 선택
  • 객체 생성
  • Assembly 타입 스캔
  • 자동 등록
  • ViewModel 해석
  • 내비게이션
  • 이벤트 기본 마커
  • Window 상태 payload 계약

패키지 역할

Dreamine.MVVM.Interfaces는 가장 낮은 레벨의 공유 계약 패키지로 유지되어야 합니다.

권장 의존성 방향은 다음과 같습니다.

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

규칙:

  • Dreamine.MVVM.InterfacesDreamine.MVVM.Core에 의존하면 안 됩니다.
  • Dreamine.MVVM.Interfaces는 WPF 전용 패키지에 의존하면 안 됩니다.
  • 구현체는 상위 레벨 패키지에 위치해야 합니다.
  • 소비자는 필요한 최소 인터페이스에만 의존해야 합니다.

프로젝트 구조

Dreamine.MVVM.Interfaces
├── DependencyInjection
│   ├── IAssemblyTypeScanner.cs
│   ├── IAutoRegistrationService.cs
│   ├── IConstructorSelector.cs
│   ├── IObjectActivator.cs
│   ├── IServiceContainer.cs
│   ├── IServiceRegistry.cs
│   └── IServiceResolver.cs
├── Events
│   └── IEventBase.cs
├── Locators
│   └── IViewModelResolver.cs
├── Navigation
│   ├── INavigator.cs
│   └── IViewManager.cs
└── Windows
    ├── IWindowStateChange.cs
    ├── IWindowStateService.cs
    └── WindowStateChangedEventArgs.cs

의존성 주입 계약

IServiceRegistry

서비스 등록 작업을 정의합니다.

지원하는 등록 개념:

  • Transient 구체 타입 등록
  • Transient 추상화-구현체 등록
  • 팩토리 등록
  • 싱글턴 인스턴스 등록
  • 싱글턴 구체 타입 등록
  • 싱글턴 추상화-구현체 등록
  • 등록 여부 확인

구현체 사용 예:

registry.Register<IMyService, MyService>();
registry.RegisterSingleton<ISharedState, SharedState>();

IServiceResolver

서비스 해석 작업을 정의합니다.

TService service = resolver.Resolve<TService>();
object service = resolver.Resolve(typeof(TService));

IServiceContainer

IServiceRegistryIServiceResolver를 결합합니다.

등록과 해석이 모두 필요한 컴포넌트에서만 사용하는 것이 좋습니다.

인터페이스 분리 원칙을 유지하려면 다음 기준을 따릅니다.

  • 등록만 필요하면 IServiceRegistry에 의존
  • 해석만 필요하면 IServiceResolver에 의존

IConstructorSelector

객체 생성 시 사용할 생성자를 선택합니다.

구현체는 다음과 같은 정책을 사용할 수 있습니다.

  • 파라미터 수가 가장 많은 생성자 선택
  • 명시적 Attribute 기반 선택
  • 파라미터 해석 가능 여부 기반 선택

IObjectActivator

생성자 주입을 사용해 객체 인스턴스를 생성합니다.

IServiceResolver를 전달받기 때문에 구체 컨테이너에 직접 의존하지 않고 생성자 의존성을 해석할 수 있습니다.


IAssemblyTypeScanner

Assembly를 스캔하고 로드 가능한 타입을 반환합니다.

부분적으로만 로드 가능한 Assembly나 ReflectionTypeLoadException 상황을 구현체가 안전하게 처리할 수 있도록 분리된 계약입니다.


IAutoRegistrationService

규칙 기반 자동 등록 계약을 정의합니다.

구현체가 결정하는 영역:

  • 어떤 Assembly를 스캔할지
  • 어떤 타입을 등록 대상으로 볼지
  • 어떤 수명 정책을 적용할지

Locator 계약

IViewModelResolver

최소 ViewModel 해석 전략을 정의합니다.

object? viewModel = resolver.Resolve(typeof(MainWindowViewModel));

대표 구현체:

  • DI 기반 ViewModel Resolver
  • 수동 팩토리 Resolver
  • 테스트용 Resolver

INavigator

Dreamine region navigation 구현체에서 사용하는 최소 인스턴스 기반 내비게이션 계약입니다.

navigator.Navigate(viewModel);

INavigator는 WPF UI 타입에 의존하지 않도록 object ViewModel을 받습니다. 구체 내비게이션 동작은 WPF 전용 패키지에 위치해야 합니다.

IViewManager

더 넓은 View 표시 계약입니다. INavigator를 상속하고 타입 기반 ViewModel 해석을 추가합니다.

viewManager.Show<MainViewModel>();
viewManager.Show(typeof(MainViewModel));
viewManager.Navigate(existingViewModel);

애플리케이션 레벨 View 표시는 IViewManager를 사용하고, region/content-control 기반 내비게이션만 필요할 때 INavigator를 사용합니다.


Event 계약

IEventBase

Dreamine Event 클래스의 마커 인터페이스입니다.

Source Generator, Scanner, Framework Convention이 구체 의존성 없이 Event 객체를 식별하는 데 사용할 수 있습니다.

이 마커만으로 자동 생성 대상을 결정하면 안 됩니다. 현재 Dreamine 생성기는 [DreamineEvent] 같은 명시적 Attribute를 기준으로 생성 후보를 고르며, scanner도 이 마커를 Attribute, namespace, naming rule과 함께 사용해야 합니다.


Window 상태 계약

IWindowStateChange

Window open-state 변경 payload 모양을 설명합니다.

IWindowStateService

Window open/close 상태를 추적하고 WindowStateChangedEventArgs를 발생시킵니다.

WindowStateChangedEventArgsIWindowStateService 계약의 일부라 이 패키지에 남겨두되, IWindowStateChange를 구현하게 해서 필요한 소비자는 payload 추상화에 의존할 수 있게 했습니다.


설계 목표

Dreamine.MVVM.Interfaces는 다음을 우선합니다.

  • 의존성 역전
  • 인터페이스 분리
  • 모듈 간 낮은 결합도
  • 테스트 가능한 인프라 경계
  • UI 프레임워크 독립성
  • 교체 가능한 구현체
  • Core, Locators, WPF, 애플리케이션 모듈을 위한 안정적인 계약

요구사항

  • .NET: net8.0
  • WPF 의존성 없음
  • 구체 런타임 구현 의존성 없음

설치

dotnet add package Dreamine.MVVM.Interfaces

또는 프로젝트 파일에 직접 추가합니다.

<ItemGroup>
  <PackageReference Include="Dreamine.MVVM.Interfaces" Version="1.0.4" />
</ItemGroup>

관련 모듈

대표 구현체 및 소비 모듈:

  • Dreamine.MVVM.Core
  • Dreamine.MVVM.Locators
  • Dreamine.MVVM.Locators.Wpf
  • Dreamine.MVVM.Wpf
  • Dreamine.MVVM.Behaviors.Core
  • Dreamine.MVVM.Behaviors.Wpf

License

MIT License

구조 다이어그램

classDiagram
    class IViewModel {
        <<interface>>
        +Initialize() void
        +Cleanup() void
    }
    class INavigationService {
        <<interface>>
        +NavigateTo~T~() void
        +GoBack() void
        +CanGoBack bool
    }
    class IDialogService {
        <<interface>>
        +ShowAsync~T~() Task
        +ConfirmAsync(string) Task~bool~
        +AlertAsync(string) Task
    }
    class IRelayCommand {
        <<interface>>
        +Execute(object) void
        +CanExecute(object) bool
        +RaiseCanExecuteChanged() void
    }
    class IAsyncRelayCommand {
        <<interface>>
        +ExecuteAsync() Task
        +IsRunning bool
    }
    class IServiceRegistry {
        <<interface>>
        +Register~T~() void
        +RegisterSingleton~T~() void
        +Resolve~T~() T
    }
    class IBusyIndicator {
        <<interface>>
        +IsBusy bool
        +StatusMessage string
    }
    IRelayCommand <|-- IAsyncRelayCommand
    IViewModel --> IBusyIndicator

API 문서

타입

IActivatable

\if KO I Activatable 기능과 관련 상태를 캡슐화합니다. \endif \if EN Encapsulates i activatable functionality and related state. \endif

IAssemblyTypeScanner

\if KO I Assembly Type Scanner 기능과 관련 상태를 캡슐화합니다. \endif \if EN Scans assemblies and returns loadable concrete types. \endif

IAutoRegistrationFilter

\if KO I Auto Registration Filter 기능과 관련 상태를 캡슐화합니다. \endif \if EN Defines a rule that determines whether a type is eligible for automatic registration. \endif

IAutoRegistrationService

\if KO I Auto Registration Service 기능과 관련 상태를 캡슐화합니다. \endif \if EN Provides automatic service registration features. \endif

IConstructorSelector

\if KO I Constructor Selector 기능과 관련 상태를 캡슐화합니다. \endif \if EN Selects a constructor for object activation. \endif

IDialogService

\if KO I Dialog Service 기능과 관련 상태를 캡슐화합니다. \endif \if EN Provides dialog presentation services for ViewModels, decoupled from WPF MessageBox. \endif

IEventBase

\if KO I Event Base 기능과 관련 상태를 캡슐화합니다. \endif \if EN Marks a type as an explicit Dreamine event contract. \endif

INavigator

\if KO I Navigator 기능과 관련 상태를 캡슐화합니다. \endif \if EN Provides instance-based navigation for an already created ViewModel. \endif

IObjectActivator

\if KO I Object Activator 기능과 관련 상태를 캡슐화합니다. \endif \if EN Creates object instances using constructor injection. \endif

IServiceContainer

\if KO I Service Container 기능과 관련 상태를 캡슐화합니다. \endif \if EN Represents a service container that supports both registration and resolution. \endif

IServiceRegistry

\if KO I Service Registry 기능과 관련 상태를 캡슐화합니다. \endif \if EN Provides service registration capabilities. \endif

IServiceResolver

\if KO I Service Resolver 기능과 관련 상태를 캡슐화합니다. \endif \if EN Provides service resolution capabilities. \endif

IViewDisplayStrategy

\if KO I View Display Strategy 기능과 관련 상태를 캡슐화합니다. \endif \if EN Defines how a resolved view is displayed for a given view type. Register custom implementations via ViewManager.RegisterDisplayStrategy to support additional view types without modifying ViewManager. \endif

IViewManager

\if KO I View Manager 기능과 관련 상태를 캡슐화합니다. \endif \if EN Provides View display operations based on ViewModel instances or ViewModel types. \endif

IViewModelResolver

\if KO 📌 ViewModel 생성 전략을 위한 DI 추상 인터페이스입니다. Dreamine의 ViewModelLocator와 함께 사용되며, DI 컨테이너 또는 수동 인스턴스화 전략을 연결하는 역할을 합니다. \endif \if EN Encapsulates i view model resolver functionality and related state. \endif

IVisibilityAware

\if KO I Visibility Aware 기능과 관련 상태를 캡슐화합니다. \endif \if EN Encapsulates i visibility aware functionality and related state. \endif

IWindowStateChange

\if KO I Window State Change 기능과 관련 상태를 캡슐화합니다. \endif \if EN Describes a window open-state change without requiring consumers to depend on a concrete event args type. \endif

IWindowStateService

\if KO I Window State Service 기능과 관련 상태를 캡슐화합니다. \endif \if EN Provides window open-state tracking. \endif

WindowStateChangedEventArgs

\if KO Window State Changed Event Args 기능과 관련 상태를 캡슐화합니다. \endif \if EN Provides data for a window open-state changed event. \endif

IActivatable

Activate Method

\if KO Activate 작업을 수행합니다. \endif \if EN Performs the activate operation. \endif

Deactivate Method

\if KO Deactivate 작업을 수행합니다. \endif \if EN Performs the deactivate operation. \endif

IAssemblyTypeScanner

GetCandidateAssemblies Method

\if KO Candidate Assemblies 값을 가져옵니다. \endif \if EN Gets candidate assemblies for auto registration. \endif

rootAssembly— \if KO root Assembly에 사용할 값입니다. \endif \if EN The root assembly to prioritize. \endif

반환: \if KO Get Candidate Assemblies 작업에서 생성한 결과입니다. \endif \if EN The candidate assemblies. \endif

GetLoadableTypes Method

\if KO Loadable Types 값을 가져옵니다. \endif \if EN Gets loadable types from the specified assembly. \endif

assembly— \if KO assembly에 사용할 값입니다. \endif \if EN The assembly to scan. \endif

반환: \if KO Get Loadable Types 작업에서 생성한 결과입니다. \endif \if EN The loadable types. \endif

IAutoRegistrationFilter

IsTarget Method

\if KO Is Target 조건을 확인합니다. \endif \if EN Determines whether the specified type is eligible for automatic registration. \endif

type— \if KO type에 사용할 값입니다. \endif \if EN The type to inspect. \endif

반환: \if KO Is Target 조건이 충족되면 이고, 그렇지 않으면 입니다. \endif \if EN True if the type is eligible; otherwise false. \endif

IAutoRegistrationService

RegisterAll Method

\if KO Register All 작업을 수행합니다. \endif \if EN Registers supported types from the specified root assembly. \endif

rootAssembly— \if KO root Assembly에 사용할 값입니다. \endif \if EN The root assembly to scan first. \endif
registry— \if KO registry에 사용할 값입니다. \endif \if EN The service registry to populate. \endif

IConstructorSelector

SelectConstructor Method

\if KO Select Constructor 작업을 수행합니다. \endif \if EN Selects the constructor to use for the specified implementation type. \endif

implementationType— \if KO implementation Type에 사용할 값입니다. \endif \if EN The implementation type. \endif

반환: \if KO Select Constructor 작업에서 생성한 결과입니다. \endif \if EN The selected constructor. \endif

IDialogService

Confirm Method

\if KO Confirm 작업을 수행합니다. \endif \if EN Displays a yes/no confirmation dialog. \endif

message— \if KO 처리할 메시지입니다. \endif \if EN The question to display. \endif
title— \if KO title에 사용할 값입니다. \endif \if EN The dialog title. \endif

반환: \if KO Confirm 조건이 충족되면 이고, 그렇지 않으면 입니다. \endif \if EN true if the user confirmed; otherwise false. \endif

ConfirmAsync Method

\if KO Confirm Async 작업을 수행합니다. \endif \if EN Asynchronously displays a yes/no confirmation dialog. \endif

message— \if KO 처리할 메시지입니다. \endif \if EN The question to display. \endif
title— \if KO title에 사용할 값입니다. \endif \if EN The dialog title. \endif

반환: \if KO Confirm Async 작업에서 생성한 Task<bool> 결과입니다. \endif \if EN true if the user confirmed; otherwise false. \endif

ShowError Method

\if KO Show Error 작업을 수행합니다. \endif \if EN Displays an error message dialog. \endif

message— \if KO 처리할 메시지입니다. \endif \if EN The error message to display. \endif
title— \if KO title에 사용할 값입니다. \endif \if EN The dialog title. \endif
ShowMessage Method

\if KO Show Message 작업을 수행합니다. \endif \if EN Displays an informational message dialog. \endif

message— \if KO 처리할 메시지입니다. \endif \if EN The message to display. \endif
title— \if KO title에 사용할 값입니다. \endif \if EN The dialog title. \endif
ShowMessageAsync Method

\if KO Show Message Async 작업을 수행합니다. \endif \if EN Asynchronously displays an informational message dialog. \endif

message— \if KO 처리할 메시지입니다. \endif \if EN The message to display. \endif
title— \if KO title에 사용할 값입니다. \endif \if EN The dialog title. \endif

반환: \if KO Show Message Async 작업에서 생성한 결과입니다. \endif \if EN The result produced by the show message async operation. \endif

INavigator

Navigate Method

\if KO Navigate 작업을 수행합니다. \endif \if EN Navigates to the View that corresponds to the specified ViewModel instance. \endif

viewModel— \if KO view Model에 사용할 값입니다. \endif \if EN The ViewModel instance to display. \endif

IObjectActivator

CreateInstance Method

\if KO Instance 값을 생성합니다. \endif \if EN Creates an instance of the specified implementation type. \endif

implementationType— \if KO implementation Type에 사용할 값입니다. \endif \if EN The implementation type. \endif
resolver— \if KO resolver에 사용할 값입니다. \endif \if EN The resolver used to resolve constructor dependencies. \endif

반환: \if KO Create Instance 작업에서 생성한 결과입니다. \endif \if EN The created object instance. \endif

IServiceRegistry

IsRegistered Method

\if KO Is Registered 조건을 확인합니다. \endif \if EN Determines whether the specified service type is registered. \endif

serviceType— \if KO service Type에 사용할 값입니다. \endif \if EN The service type. \endif

반환: \if KO Is Registered 조건이 충족되면 이고, 그렇지 않으면 입니다. \endif \if EN True if the service type is registered; otherwise false. \endif

Register``1 Method

\if KO Register 작업을 수행합니다. \endif \if EN Registers a concrete implementation type as itself with transient lifetime. \endif

Register``1 Method

\if KO Register 작업을 수행합니다. \endif \if EN Registers a factory for the specified service type using transient lifetime. \endif

factory— \if KO factory에 사용할 Func<TService> 값입니다. \endif \if EN The factory used to create the service instance. \endif
Register``2 Method

\if KO Register 작업을 수행합니다. \endif \if EN Registers a service abstraction with a concrete implementation using transient lifetime. \endif

RegisterSingleton``1 Method

\if KO Register Singleton 작업을 수행합니다. \endif \if EN Registers a singleton instance for the specified service type. \endif

instance— \if KO instance에 사용할 값입니다. \endif \if EN The singleton instance. \endif
RegisterSingleton``1 Method

\if KO Register Singleton 작업을 수행합니다. \endif \if EN Registers a concrete implementation type as itself with singleton lifetime. \endif

RegisterSingleton``2 Method

\if KO Register Singleton 작업을 수행합니다. \endif \if EN Registers a service abstraction with a concrete implementation using singleton lifetime. \endif

IServiceResolver

Resolve Method

\if KO Resolve 작업을 수행합니다. \endif \if EN Resolves an instance of the specified service type. \endif

serviceType— \if KO service Type에 사용할 값입니다. \endif \if EN The service type. \endif

반환: \if KO Resolve 작업에서 생성한 결과입니다. \endif \if EN The resolved service instance. \endif

Resolve``1 Method

\if KO Resolve 작업을 수행합니다. \endif \if EN Resolves an instance of the specified service type. \endif

반환: \if KO Resolve 작업에서 생성한 결과입니다. \endif \if EN The resolved service instance. \endif

TryResolve``1 Method

\if KO Resolve 작업을 시도하고 성공 여부를 반환합니다. \endif \if EN Attempts to resolve an instance of the specified service type without throwing. \endif

result— \if KO result에 사용할 값입니다. \endif \if EN The resolved instance, or null if not registered. \endif

반환: \if KO Try Resolve 조건이 충족되면 이고, 그렇지 않으면 입니다. \endif \if EN true if resolved successfully; otherwise false. \endif

IViewDisplayStrategy

CanHandle Method

\if KO Can Handle 조건을 확인합니다. \endif \if EN Returns true when this strategy can handle the specified view instance. \endif

view— \if KO view에 사용할 값입니다. \endif \if EN The resolved view object. \endif

반환: \if KO Can Handle 조건이 충족되면 이고, 그렇지 않으면 입니다. \endif \if EN when the can handle condition is satisfied; otherwise, . \endif

Display Method

\if KO Display 작업을 수행합니다. \endif \if EN Displays the view with the given ViewModel. \endif

view— \if KO view에 사용할 값입니다. \endif \if EN The resolved view object. \endif
viewModel— \if KO view Model에 사용할 값입니다. \endif \if EN The resolved ViewModel object. \endif
viewModelType— \if KO view Model Type에 사용할 값입니다. \endif \if EN The ViewModel type (used for key resolution). \endif
useRegionNavigator— \if KO use Region Navigator에 사용할 값입니다. \endif \if EN true when display should delegate to INavigator if available. \endif

IViewManager

Show Method

\if KO Show 작업을 수행합니다. \endif \if EN Shows the View that corresponds to the specified ViewModel type. \endif

viewModelType— \if KO view Model Type에 사용할 값입니다. \endif \if EN The ViewModel type used to resolve the target View. \endif
Show``1 Method

\if KO Show 작업을 수행합니다. \endif \if EN Shows the View that corresponds to the specified ViewModel type. \endif

IViewModelResolver

Resolve Method

\if KO 지정된 ViewModel 타입을 생성하여 반환합니다. \endif \if EN Performs the resolve operation. \endif

viewModelType— \if KO 생성할 ViewModel의 Type 정보 \endif \if EN The value used for view model type. \endif

반환: \if KO ViewModel 인스턴스 또는 null \endif \if EN The result produced by the resolve operation. \endif

IVisibilityAware

OnHidden Method

\if KO Hidden 이벤트 또는 상태 변경을 처리합니다. \endif \if EN Handles the hidden event or state change. \endif

OnShown Method

\if KO Shown 이벤트 또는 상태 변경을 처리합니다. \endif \if EN Handles the shown event or state change. \endif

IWindowStateChange

IsOpen Property

\if KO Is Open 값을 가져옵니다. \endif \if EN Gets a value indicating whether the window is open. \endif

WindowKey Property

\if KO Window Key 값을 가져옵니다. \endif \if EN Gets the window key. \endif

IWindowStateService

IsOpen Method

\if KO Is Open 조건을 확인합니다. \endif \if EN Determines whether the window with the specified key is open. \endif

windowKey— \if KO window Key에 사용할 값입니다. \endif \if EN The window key. \endif

반환: \if KO Is Open 조건이 충족되면 이고, 그렇지 않으면 입니다. \endif \if EN True if the window is open; otherwise false. \endif

MarkClosed Method

\if KO Mark Closed 작업을 수행합니다. \endif \if EN Marks the window with the specified key as closed. \endif

windowKey— \if KO window Key에 사용할 값입니다. \endif \if EN The window key. \endif
MarkOpened Method

\if KO Mark Opened 작업을 수행합니다. \endif \if EN Marks the window with the specified key as opened. \endif

windowKey— \if KO window Key에 사용할 값입니다. \endif \if EN The window key. \endif
StateChanged Event

\if KO State Changed 상황이 발생할 때 알립니다. \endif \if EN Occurs when a window open-state changes. \endif

WindowStateChangedEventArgs

#ctor Method

\if KO 지정한 설정으로 클래스의 새 인스턴스를 초기화합니다. \endif \if EN Initializes a new instance of the class. \endif

windowKey— \if KO window Key에 사용할 값입니다. \endif \if EN The window key. \endif
isOpen— \if KO is Open에 사용할 값입니다. \endif \if EN A value indicating whether the window is open. \endif
IsOpen Property

\if KO Is Open 값을 가져옵니다. \endif \if EN Gets a value indicating whether the window is open. \endif

WindowKey Property

\if KO Window Key 값을 가져옵니다. \endif \if EN Gets the window key. \endif