Dreamine.MVVM.ViewModels 1.0.5
Dreamine.MVVM.ViewModels 프로젝트의 API와 구성 요소를 제공합니다.
로딩중...
검색중...
일치하는것 없음
Dreamine.MVVM.ViewModels.RelayCommand 클래스 참조sealed

더 자세히 ...

Dreamine.MVVM.ViewModels.RelayCommand에 대한 상속 다이어그램 :
Dreamine.MVVM.ViewModels.RelayCommand에 대한 협력 다이어그램:

Public 멤버 함수

 RelayCommand (Action execute, Func< bool >? canExecute=null)
bool CanExecute (object? parameter)
void Execute (object? parameter)
void RaiseCanExecuteChanged ()

이벤트

EventHandler? CanExecuteChanged

Private 속성

readonly Action _execute
readonly? Func< bool > _canExecute
readonly? SynchronizationContext _syncContext

상세한 설명

매개변수가 없는 기본 RelayCommand 구현입니다. ViewModel에서 ICommand 바인딩용으로 사용됩니다.

RelayCommand.cs 파일의 13 번째 라인에서 정의되었습니다.

생성자 & 소멸자 문서화

◆ RelayCommand()

Dreamine.MVVM.ViewModels.RelayCommand.RelayCommand ( Action execute,
Func< bool >? canExecute = null )
inline

RelayCommand 생성자

매개변수
execute실행 메서드
canExecute실행 가능 여부 판단 메서드 (선택)
예외
ArgumentNullException필수 입력 인자 중 하나가 null인 경우 발생합니다.

RelayCommand.cs 파일의 76 번째 라인에서 정의되었습니다.

77 {
78 // Argument 검증
79 _execute = execute ?? throw new ArgumentNullException(nameof(execute));
80 _canExecute = canExecute;
81
82 // 생성 시점의 SynchronizationContext를 캡처하여 UI 스레드 마샬링에 사용
83 _syncContext = SynchronizationContext.Current;
84 }

다음을 참조함 : _canExecute, _execute, _syncContext.

다음에 의해서 참조됨 : RaiseCanExecuteChanged().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

멤버 함수 문서화

◆ CanExecute()

bool Dreamine.MVVM.ViewModels.RelayCommand.CanExecute ( object? parameter)
inline

현재 명령이 실행 가능한지를 나타냅니다.

매개변수
parameter명령 실행에 사용될 파라미터 (사용하지 않음)
반환값
명령이 실행 가능한 경우 true, 그렇지 않으면 false

RelayCommand.cs 파일의 110 번째 라인에서 정의되었습니다.

111 {
112 // canExecute 미지정 시 항상 실행 가능
113 return _canExecute?.Invoke() ?? true;
114 }

다음을 참조함 : _canExecute.

다음에 의해서 참조됨 : Dreamine.MVVM.ViewModels.RelayCommand< T >.Execute(), Execute().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ Execute()

void Dreamine.MVVM.ViewModels.RelayCommand.Execute ( object? parameter)
inline

명령을 실행합니다.

매개변수
parameter명령 실행에 사용될 파라미터 (사용하지 않음)

RelayCommand.cs 파일의 132 번째 라인에서 정의되었습니다.

133 {
134 if (CanExecute(parameter))
135 _execute();
136 }

다음을 참조함 : _execute, CanExecute().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ RaiseCanExecuteChanged()

void Dreamine.MVVM.ViewModels.RelayCommand.RaiseCanExecuteChanged ( )
inline

CanExecute 상태를 수동으로 갱신합니다. UI 스레드가 아닌 스레드에서 호출되더라도 UI 스레드로 안전하게 마샬링합니다.

RelayCommand.cs 파일의 156 번째 라인에서 정의되었습니다.

157 {
158 // 이벤트 핸들러가 없으면 빠른 종료
159 var handler = CanExecuteChanged;
160 if (handler is null)
161 return;
162
163 // 캡처한 컨텍스트가 있고 현재 컨텍스트가 다르면 Post로 UI 스레드 호출
164 if (_syncContext != null && !ReferenceEquals(SynchronizationContext.Current, _syncContext))
165 {
166 _syncContext.Post(static state =>
167 {
168 // state는 (RelayCommand, EventHandler) 튜플
169 var tuple = ((RelayCommand cmd, EventHandler evt))state!;
170 tuple.evt.Invoke(tuple.cmd, EventArgs.Empty);
171 }, (this, handler));
172
173 return;
174 }
175
176 // 동일 컨텍스트(보통 UI)에서 즉시 호출
177 handler.Invoke(this, EventArgs.Empty);
178 }

다음을 참조함 : _syncContext, CanExecuteChanged, RelayCommand().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

멤버 데이터 문서화

◆ _canExecute

readonly? Func<bool> Dreamine.MVVM.ViewModels.RelayCommand._canExecute
private

can Execute 값을 보관합니다.

RelayCommand.cs 파일의 32 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : CanExecute(), RelayCommand().

◆ _execute

readonly Action Dreamine.MVVM.ViewModels.RelayCommand._execute
private

execute 값을 보관합니다.

RelayCommand.cs 파일의 23 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : Dreamine.MVVM.ViewModels.RelayCommand< T >.Execute(), Execute(), RelayCommand().

◆ _syncContext

readonly? SynchronizationContext Dreamine.MVVM.ViewModels.RelayCommand._syncContext
private

sync Context 값을 보관합니다.

RelayCommand.cs 파일의 42 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : RaiseCanExecuteChanged(), RelayCommand().

이벤트 문서화

◆ CanExecuteChanged

EventHandler? Dreamine.MVVM.ViewModels.RelayCommand.CanExecuteChanged

명령의 실행 가능 상태가 변경될 때 발생하는 이벤트입니다.

RelayCommand.cs 파일의 146 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : RaiseCanExecuteChanged().


이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.: