Dreamine.MVVM.ViewModels
Dreamine MVVM 프레임워크에서 사용하는 ViewModel 기반 인프라 패키지입니다.
이 패키지는 Dreamine MVVM 아키텍처에서 ViewModel을 구현하기 위한 기본 구조를 제공합니다.
목적
Dreamine.MVVM.ViewModels는 Dreamine 생태계에서 ViewModel을 작성할 때 사용하는 기본 구조를 정의합니다.
이 레이어는 MVVM 패턴에서 ViewModel 역할을 담당하는 핵심 구성 요소입니다.
주요 역할:
- 기본 ViewModel 구조 제공
- MVVM 패턴 지원
- Command 시스템과의 연동
- Property 변경 알림 구조 지원
설계 목표
Dreamine 프레임워크 전반에서 사용하는 설계 원칙을 따릅니다.
설계 목표:
- 최소 의존성
- 명확한 MVVM 계층 분리
- 가벼운 기본 클래스
- Source Generator 및 Command 시스템과의 호환
ViewModel을 단순하게 유지하면서 프레임워크 기능을 확장할 수 있도록 설계되었습니다.
Dreamine MVVM 구조 내 위치
Dreamine.MVVM.Interfaces
↑
Dreamine.MVVM.Commands
↑
Dreamine.MVVM.ViewModels
↑
Application ViewModels
실제 애플리케이션의 ViewModel은 이 패키지의 기본 클래스를 기반으로 작성됩니다.
설치
dotnet add package Dreamine.MVVM.ViewModels
또는 프로젝트 파일에 직접 추가합니다.
<PackageReference Include="Dreamine.MVVM.ViewModels" Version="1.0.0" />
요구 사항
- .NET 8.0
License
MIT License
구조 다이어그램
classDiagram
class INotifyPropertyChanged {
<<interface>>
+PropertyChanged event
}
class IViewModel {
<<interface>>
+Initialize() void
+Cleanup() void
}
class ObservableBase {
<<abstract>>
#SetProperty~T~(ref T, T, string) bool
#OnPropertyChanged(string) void
+PropertyChanged event
}
class ViewModelBase {
<<abstract>>
+bool IsBusy
+string StatusMessage
+string Title
+Initialize() void
+Cleanup() void
#RunBusyAsync~T~(Func~Task~T~~) Task~T~
}
class EditableViewModelBase {
<<abstract>>
+bool HasChanges
+Save() void
+Discard() void
}
INotifyPropertyChanged <|.. ObservableBase
IViewModel <|.. ViewModelBase
ObservableBase <|-- ViewModelBase
ViewModelBase <|-- EditableViewModelBaseAPI 문서
타입
\if KO Async Relay Command 기능과 관련 상태를 캡슐화합니다. \endif \if EN Provides an asynchronous implementation that prevents re-entrant execution and exposes failure information. \endif
\if KO 매개변수가 없는 기본 RelayCommand 구현입니다. ViewModel에서 ICommand 바인딩용으로 사용됩니다. \endif \if EN Encapsulates relay command functionality and related state. \endif
\if KO 제네릭 RelayCommand 구현입니다. 매개변수를 사용하는 경우 사용됩니다. \endif \if EN Encapsulates relay command functionality and related state. \endif
\if KO Dreamine MVVM의 모든 ViewModel이 상속하는 기본 클래스입니다. INotifyPropertyChanged 및 INotifyPropertyChanging을 구현하며, 속성 변경 알림 기능을 제공합니다. \endif \if EN Encapsulates view model base functionality and related state. \endif
AsyncRelayCommand
\if KO 지정한 설정으로 클래스의 새 인스턴스를 초기화합니다. \endif \if EN Initializes a new instance of the class. \endif
execute— \if KO execute에 사용할 Func<Task> 값입니다. \endif \if EN The asynchronous execute delegate. \endifcanExecute— \if KO can Execute에 사용할 Func<bool> 값입니다. \endif \if EN The optional can-execute delegate. \endif\if KO Can Execute 조건을 확인합니다. \endif \if EN Determines whether can execute. \endif
parameter— \if KO parameter에 사용할 값입니다. \endif \if EN The value used for parameter. \endif반환: \if KO Can Execute 조건이 충족되면 이고, 그렇지 않으면 입니다. \endif \if EN when the can execute condition is satisfied; otherwise, . \endif
\if KO Execute 작업을 수행합니다. \endif \if EN Performs the execute operation. \endif
parameter— \if KO parameter에 사용할 값입니다. \endif \if EN The value used for parameter. \endif\if KO Raise Can Execute Changed 작업을 수행합니다. \endif \if EN Raises the event. \endif
\if KO Last Exception 값을 가져옵니다. \endif \if EN Gets the last exception thrown by the asynchronous delegate, or null. \endif
\if KO can Execute 값을 보관합니다. \endif \if EN Stores the can execute value. \endif
\if KO execute 값을 보관합니다. \endif \if EN Stores the execute value. \endif
\if KO is Executing 값을 보관합니다. \endif \if EN Stores the is executing value. \endif
\if KO last Exception 값을 보관합니다. \endif \if EN Stores the last exception value. \endif
\if KO Can Execute Changed 상황이 발생할 때 알립니다. \endif \if EN Occurs when can execute changed takes place. \endif
\if KO Execution Failed 상황이 발생할 때 알립니다. \endif \if EN Occurs when the asynchronous delegate throws an exception. \endif
RelayCommand
\if KO RelayCommand 생성자 \endif \if EN Initializes a new instance of the class with the specified settings. \endif
execute— \if KO 실행 메서드 \endif \if EN The value used for execute. \endifcanExecute— \if KO 실행 가능 여부 판단 메서드 (선택) \endif \if EN The Func<bool> value used for can execute. \endif\if KO 현재 명령이 실행 가능한지를 나타냅니다. \endif \if EN Determines whether can execute. \endif
parameter— \if KO 명령 실행에 사용될 파라미터 (사용하지 않음) \endif \if EN The value used for parameter. \endif반환: \if KO 명령이 실행 가능한 경우 true, 그렇지 않으면 false \endif \if EN when the can execute condition is satisfied; otherwise, . \endif
\if KO 명령을 실행합니다. \endif \if EN Performs the execute operation. \endif
parameter— \if KO 명령 실행에 사용될 파라미터 (사용하지 않음) \endif \if EN The value used for parameter. \endif\if KO CanExecute 상태를 수동으로 갱신합니다. UI 스레드가 아닌 스레드에서 호출되더라도 UI 스레드로 안전하게 마샬링합니다. \endif \if EN Performs the raise can execute changed operation. \endif
\if KO can Execute 값을 보관합니다. \endif \if EN Stores the can execute value. \endif
\if KO execute 값을 보관합니다. \endif \if EN Stores the execute value. \endif
\if KO sync Context 값을 보관합니다. \endif \if EN Stores the sync context value. \endif
\if KO 명령의 실행 가능 상태가 변경될 때 발생하는 이벤트입니다. \endif \if EN Occurs when can execute changed takes place. \endif
RelayCommand`1
\if KO RelayCommand 생성자 \endif \if EN Initializes a new instance of the class with the specified settings. \endif
execute— \if KO 실행 메서드 \endif \if EN The value used for execute. \endifcanExecute— \if KO 실행 가능 여부 판단 메서드 (선택) \endif \if EN The Func<T, bool> value used for can execute. \endif\if KO 명령이 현재 실행 가능한지를 결정합니다. \endif \if EN Determines whether can execute. \endif
parameter— \if KO 명령 실행에 전달된 파라미터. 로 변환됩니다. \endif \if EN The value used for parameter. \endif반환: \if KO 명령이 실행 가능하면 true, 그렇지 않으면 false \endif \if EN when the can execute condition is satisfied; otherwise, . \endif
\if KO 명령을 실행합니다. \endif \if EN Performs the execute operation. \endif
parameter— \if KO 명령 실행에 전달된 파라미터. 로 변환됩니다. \endif \if EN The value used for parameter. \endif\if KO CanExecute 상태를 수동으로 갱신합니다. UI 스레드가 아닌 스레드에서 호출되더라도 UI 스레드로 안전하게 마샬링합니다. \endif \if EN Performs the raise can execute changed operation. \endif
\if KO ICommand parameter를 로 안전하게 변환합니다. \endif \if EN Attempts to get parameter and returns whether the operation succeeds. \endif
parameter— \if KO 원본 파라미터 \endif \if EN The value used for parameter. \endifvalue— \if KO 변환 결과 \endif \if EN The value to apply. \endif반환: \if KO 변환 성공 시 true, 실패 시 false \endif \if EN when the try get parameter condition is satisfied; otherwise, . \endif
\if KO can Execute 값을 보관합니다. \endif \if EN Stores the can execute value. \endif
\if KO execute 값을 보관합니다. \endif \if EN Stores the execute value. \endif
\if KO sync Context 값을 보관합니다. \endif \if EN Stores the sync context value. \endif
\if KO 명령의 실행 가능 상태가 변경되었음을 알리는 이벤트입니다. UI 바인딩 요소는 이 이벤트를 통해 CanExecute 상태를 다시 평가합니다. \endif \if EN Occurs when can execute changed takes place. \endif
ViewModelBase
\if KO 지정된 속성 이름으로 PropertyChanged 이벤트를 발생시킵니다. \endif \if EN Handles the property changed event or state change. \endif
propertyName— \if KO 속성 이름 \endif \if EN The value used for property name. \endif\if KO 지정된 속성 이름으로 PropertyChanging 이벤트를 발생시킵니다. \endif \if EN Handles the property changing event or state change. \endif
propertyName— \if KO 속성 이름 \endif \if EN The value used for property name. \endif\if KO 백킹 필드를 설정하고 값이 변경되었을 경우 PropertyChanging/PropertyChanged를 발생시킵니다. \endif \if EN Sets the property value. \endif
field— \if KO 백킹 필드 \endif \if EN The value used for field. \endifvalue— \if KO 새로운 값 \endif \if EN The value to apply. \endifpropertyName— \if KO 속성 이름 \endif \if EN The value used for property name. \endif반환: \if KO 값이 변경되었는지 여부 \endif \if EN when the set property condition is satisfied; otherwise, . \endif
\if KO Property Changed 상황이 발생할 때 알립니다. \endif \if EN Occurs when property changed takes place. \endif
\if KO Property Changing 상황이 발생할 때 알립니다. \endif \if EN Occurs when property changing takes place. \endif