Dreamine.MVVM.Core 1.0.13
중요: 자동 등록된 타입은 기본적으로 Singleton으로 등록됩니다. 따라서 자동 발견된 ViewModel, Model, Event, Manager는 애플리케이션이 별도 수명으로 명시 등록하지 않는 한 반복 해석 시 동일 인스턴스를 유지합니다.
로딩중...
검색중...
일치하는것 없음
ConstructorSelector.cs
이 파일의 문서화 페이지로 가기
1using System;
2using System.Linq;
3using System.Reflection;
4using Dreamine.MVVM.Interfaces.DependencyInjection;
5
7{
16 public sealed class ConstructorSelector : IConstructorSelector
17 {
58 public ConstructorInfo SelectConstructor(Type implementationType)
59 {
60 if (implementationType is null)
61 {
62 throw new ArgumentNullException(nameof(implementationType));
63 }
64
65 ConstructorInfo? constructor = implementationType
66 .GetConstructors()
67 .OrderByDescending(item => item.GetParameters().Length)
68 .FirstOrDefault();
69
70 if (constructor is null)
71 {
72 throw new InvalidOperationException(
73 $"No public constructor was found for [{implementationType.FullName}].");
74 }
75
76 return constructor;
77 }
78 }
79}
ConstructorInfo SelectConstructor(Type implementationType)