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

더 자세히 ...

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

Public 멤버 함수

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

이벤트

EventHandler? CanExecuteChanged

정적 Private 멤버 함수

static bool TryGetParameter (object? parameter, out T value)

Private 속성

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

상세한 설명

제네릭 RelayCommand 구현입니다. 매개변수를 사용하는 경우 사용됩니다.

템플릿 파라메터
T매개변수 타입

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

멤버 함수 문서화

◆ CanExecute()

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

명령이 현재 실행 가능한지를 결정합니다.

매개변수
parameter명령 실행에 전달된 파라미터. T 로 변환됩니다.
반환값
명령이 실행 가능하면 true, 그렇지 않으면 false

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

295 {
296 // canExecute 미지정 시 항상 실행 가능
297 if (_canExecute is null)
298 return true;
299
300 // 파라미터 변환 실패 시 실행 불가 처리(예외 대신 false)
301 if (!TryGetParameter(parameter, out var value))
302 return false;
303
304 return _canExecute.Invoke(value);
305 }

다음을 참조함 : _canExecute, TryGetParameter().

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

◆ Execute()

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

명령을 실행합니다.

매개변수
parameter명령 실행에 전달된 파라미터. T 로 변환됩니다.
예외
ArgumentException입력 인자가 유효하지 않은 경우 발생합니다.

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

332 {
333 if (!CanExecute(parameter))
334 return;
335
336 if (!TryGetParameter(parameter, out var value))
337 throw new ArgumentException($"Command parameter is not assignable to {typeof(T).FullName}.", nameof(parameter));
338
339 _execute(value);
340 }

다음을 참조함 : Dreamine.MVVM.ViewModels.RelayCommand._execute, Dreamine.MVVM.ViewModels.RelayCommand.CanExecute(), TryGetParameter().

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

◆ RaiseCanExecuteChanged()

void Dreamine.MVVM.ViewModels.RelayCommand< T >.RaiseCanExecuteChanged ( )
inline

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

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

361 {
362 // 핸들러 스냅샷
363 var handler = CanExecuteChanged;
364 if (handler is null)
365 return;
366
367 // 다른 컨텍스트라면 Post로 이벤트 발생
368 if (_syncContext != null && !ReferenceEquals(SynchronizationContext.Current, _syncContext))
369 {
370 _syncContext.Post(static state =>
371 {
372 // state는 (RelayCommand<T>, EventHandler) 튜플
373 var tuple = ((RelayCommand<T> cmd, EventHandler evt))state!;
374 tuple.evt.Invoke(tuple.cmd, EventArgs.Empty);
375 }, (this, handler));
376
377 return;
378 }
379
380 handler.Invoke(this, EventArgs.Empty);
381 }

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

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

◆ RelayCommand()

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

RelayCommand 생성자

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

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

261 {
262 // Argument 검증
263 _execute = execute ?? throw new ArgumentNullException(nameof(execute));
264 _canExecute = canExecute;
265
266 // 생성 시점 SynchronizationContext 캡처
267 _syncContext = SynchronizationContext.Current;
268 }

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

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

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

◆ TryGetParameter()

bool Dreamine.MVVM.ViewModels.RelayCommand< T >.TryGetParameter ( object? parameter,
out T value )
inlinestaticprivate

ICommand parameter를 T 로 안전하게 변환합니다.

매개변수
parameter원본 파라미터
value변환 결과
반환값
변환 성공 시 true, 실패 시 false

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

416 {
417 // null 처리
418 if (parameter is null)
419 {
420 // 참조 타입 또는 Nullable이면 default 허용
421 if (default(T) is null)
422 {
423 value = default!;
424 return true;
425 }
426
427 // non-nullable value type은 null 불가
428 value = default!;
429 return false;
430 }
431
432 // 이미 T면 그대로 사용
433 if (parameter is T t)
434 {
435 value = t;
436 return true;
437 }
438
439 // 타입 불일치
440 value = default!;
441 return false;
442 }

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

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

멤버 데이터 문서화

◆ _canExecute

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

can Execute 값을 보관합니다.

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

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

◆ _execute

readonly Action<T> Dreamine.MVVM.ViewModels.RelayCommand< T >._execute
private

execute 값을 보관합니다.

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

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

◆ _syncContext

readonly? SynchronizationContext Dreamine.MVVM.ViewModels.RelayCommand< T >._syncContext
private

sync Context 값을 보관합니다.

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

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

이벤트 문서화

◆ CanExecuteChanged

EventHandler? Dreamine.MVVM.ViewModels.RelayCommand< T >.CanExecuteChanged

명령의 실행 가능 상태가 변경되었음을 알리는 이벤트입니다. UI 바인딩 요소는 이 이벤트를 통해 CanExecute 상태를 다시 평가합니다.

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

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


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