Dreamine.MVVM.Core 1.0.13
중요: 자동 등록된 타입은 기본적으로 Singleton으로 등록됩니다. 따라서 자동 발견된 ViewModel, Model, Event, Manager는 애플리케이션이 별도 수명으로 명시 등록하지 않는 한 반복 해석 시 동일 인스턴스를 유지합니다.
로딩중...
검색중...
일치하는것 없음
Dreamine.MVVM.Core.DependencyInjection.DreamineContainer 클래스 참조sealed

더 자세히 ...

Dreamine.MVVM.Core.DependencyInjection.DreamineContainer에 대한 상속 다이어그램 :
Dreamine.MVVM.Core.DependencyInjection.DreamineContainer에 대한 협력 다이어그램:

Public 멤버 함수

 DreamineContainer ()
 DreamineContainer (IObjectActivator objectActivator)
void Register< TImplementation > ()
void Register< TService, TImplementation > ()
void Register< TService > (Func< TService > factory)
void RegisterSingleton< TService > (TService instance)
void RegisterSingleton< TImplementation > ()
void RegisterSingleton< TService, TImplementation > ()
bool IsRegistered (Type serviceType)
TService Resolve< TService > ()
bool TryResolve< TService > (out TService? result)
object Resolve (Type serviceType)
void Dispose ()

Private 멤버 함수

object ResolveCore (Type serviceType)
object CreateConcrete (Type implementationType)

정적 Private 멤버 함수

static bool CanCreateUnregisteredConcreteType (Type type)

Private 속성

readonly Dictionary< Type, ServiceDescriptor_descriptors = new()
readonly Dictionary< Type, object > _singletonInstances = new()
readonly AsyncLocal< ResolutionContext?> _currentResolutionContext = new()
readonly IObjectActivator _objectActivator
readonly object _syncRoot = new()
bool _disposed

상세한 설명

Dreamine Container 기능과 관련 상태를 캡슐화합니다.

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

생성자 & 소멸자 문서화

◆ DreamineContainer() [1/2]

Dreamine.MVVM.Core.DependencyInjection.DreamineContainer.DreamineContainer ( )
inline

지정한 설정으로 DreamineContainer 클래스의 새 인스턴스를 초기화합니다.

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

82 : this(new ConstructorActivator(new ConstructorSelector()))
83 {
84 }

◆ DreamineContainer() [2/2]

Dreamine.MVVM.Core.DependencyInjection.DreamineContainer.DreamineContainer ( IObjectActivator objectActivator)
inline

지정한 설정으로 DreamineContainer 클래스의 새 인스턴스를 초기화합니다.

매개변수
objectActivatorobject Activator에 사용할 IObjectActivator 값입니다.
예외
ArgumentNullException필수 입력 인자 중 하나가 null인 경우 발생합니다.

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

111 {
112 _objectActivator = objectActivator
113 ?? throw new ArgumentNullException(nameof(objectActivator));
114 }

다음을 참조함 : _objectActivator.

멤버 함수 문서화

◆ CanCreateUnregisteredConcreteType()

bool Dreamine.MVVM.Core.DependencyInjection.DreamineContainer.CanCreateUnregisteredConcreteType ( Type type)
inlinestaticprivate

Can Create Unregistered Concrete Type 조건을 확인합니다.

매개변수
typetype에 사용할 Type 값입니다.
반환값
Can Create Unregistered Concrete Type 조건이 충족되면 true이고, 그렇지 않으면 false입니다.

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

728 {
729 return type.IsClass &&
730 !type.IsAbstract &&
731 !type.IsGenericTypeDefinition;
732 }

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

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

◆ CreateConcrete()

object Dreamine.MVVM.Core.DependencyInjection.DreamineContainer.CreateConcrete ( Type implementationType)
inlineprivate

Concrete 값을 생성합니다.

매개변수
implementationTypeimplementation Type에 사용할 Type 값입니다.
반환값
Create Concrete 작업에서 생성한 object 결과입니다.
예외
InvalidOperationException현재 객체 상태에서 Create Concrete 작업을 수행할 수 없는 경우 발생합니다.

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

651 {
652 ResolutionContext context = _currentResolutionContext.Value ?? new ResolutionContext();
653 if (!context.TryEnter(implementationType))
654 {
655 throw new InvalidOperationException(
656 $"Circular dependency detected while resolving [{implementationType.FullName}].");
657 }
658
659 try
660 {
661 return _objectActivator.CreateInstance(implementationType, this);
662 }
663 finally
664 {
665 context.Exit(implementationType);
666 }
667 }

다음을 참조함 : _objectActivator.

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

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

◆ Dispose()

void Dreamine.MVVM.Core.DependencyInjection.DreamineContainer.Dispose ( )
inline

이 인스턴스가 소유한 리소스를 해제합니다.

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

678 {
679 List<object> toDispose;
680
681 lock (_syncRoot)
682 {
683 if (_disposed)
684 {
685 return;
686 }
687
688 _disposed = true;
689 toDispose = new List<object>(_singletonInstances.Values);
690 _singletonInstances.Clear();
691 _descriptors.Clear();
692 }
693
694 foreach (object instance in toDispose)
695 {
696 if (instance is IDisposable disposable)
697 {
698 disposable.Dispose();
699 }
700 }
701 }

다음을 참조함 : _descriptors, _disposed, _singletonInstances, _syncRoot.

◆ IsRegistered()

bool Dreamine.MVVM.Core.DependencyInjection.DreamineContainer.IsRegistered ( Type serviceType)
inline

Is Registered 조건을 확인합니다.

매개변수
serviceTypeservice Type에 사용할 Type 값입니다.
반환값
Is Registered 조건이 충족되면 true이고, 그렇지 않으면 false입니다.
예외
ArgumentNullException필수 입력 인자 중 하나가 null인 경우 발생합니다.

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

388 {
389 if (serviceType is null)
390 {
391 throw new ArgumentNullException(nameof(serviceType));
392 }
393
394 lock (_syncRoot)
395 {
396 return _descriptors.ContainsKey(serviceType);
397 }
398 }

다음을 참조함 : _descriptors, _syncRoot.

◆ Register< TImplementation >()

void Dreamine.MVVM.Core.DependencyInjection.DreamineContainer.Register< TImplementation > ( )
inline

Register 작업을 수행합니다.

템플릿 파라메터
TImplementationTImplementation 형식 매개변수입니다.
타입 한정자들
TImplementation :class 

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

133 : class
134 {
135 Register<TImplementation, TImplementation>();
136 }

◆ Register< TService >()

void Dreamine.MVVM.Core.DependencyInjection.DreamineContainer.Register< TService > ( Func< TService > factory)
inline

Register 작업을 수행합니다.

템플릿 파라메터
TServiceTService 형식 매개변수입니다.
매개변수
factoryfactory에 사용할 Func<TService> 값입니다.
예외
ArgumentNullException필수 입력 인자 중 하나가 null인 경우 발생합니다.
타입 한정자들
TService :class 

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

214 : class
215 {
216 if (factory is null)
217 {
218 throw new ArgumentNullException(nameof(factory));
219 }
220
221 Type serviceType = typeof(TService);
222
223 lock (_syncRoot)
224 {
225 _descriptors[serviceType] = new ServiceDescriptor(
226 serviceType,
227 implementationType: null,
228 factory: () => factory(),
229 instance: null,
230 lifetime: ServiceLifetime.Transient);
231 _singletonInstances.Remove(serviceType);
232 }
233 }

다음을 참조함 : _descriptors, _singletonInstances, _syncRoot.

◆ Register< TService, TImplementation >()

void Dreamine.MVVM.Core.DependencyInjection.DreamineContainer.Register< TService, TImplementation > ( )
inline

Register 작업을 수행합니다.

템플릿 파라메터
TServiceTService 형식 매개변수입니다.
TImplementationTImplementation 형식 매개변수입니다.
타입 한정자들
TService :class 
TImplementation :class 
TImplementation :TService 

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

163 : class
164 where TImplementation : class, TService
165 {
166 Type serviceType = typeof(TService);
167 Type implementationType = typeof(TImplementation);
168
169 lock (_syncRoot)
170 {
171 _descriptors[serviceType] = new ServiceDescriptor(
172 serviceType,
173 implementationType,
174 factory: null,
175 instance: null,
176 lifetime: ServiceLifetime.Transient);
177 _singletonInstances.Remove(serviceType);
178 }
179 }

다음을 참조함 : _descriptors, _singletonInstances, _syncRoot.

◆ RegisterSingleton< TImplementation >()

void Dreamine.MVVM.Core.DependencyInjection.DreamineContainer.RegisterSingleton< TImplementation > ( )
inline

Register Singleton 작업을 수행합니다.

템플릿 파라메터
TImplementationTImplementation 형식 매개변수입니다.
타입 한정자들
TImplementation :class 

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

307 : class
308 {
309 RegisterSingleton<TImplementation, TImplementation>();
310 }

◆ RegisterSingleton< TService >()

void Dreamine.MVVM.Core.DependencyInjection.DreamineContainer.RegisterSingleton< TService > ( TService instance)
inline

Register Singleton 작업을 수행합니다.

템플릿 파라메터
TServiceTService 형식 매개변수입니다.
매개변수
instanceinstance에 사용할 TService 값입니다.
예외
ArgumentNullException필수 입력 인자 중 하나가 null인 경우 발생합니다.
타입 한정자들
TService :class 

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

268 : class
269 {
270 if (instance is null)
271 {
272 throw new ArgumentNullException(nameof(instance));
273 }
274
275 Type serviceType = typeof(TService);
276
277 lock (_syncRoot)
278 {
279 _descriptors[serviceType] = new ServiceDescriptor(
280 serviceType,
281 instance.GetType(),
282 factory: null,
283 instance,
284 lifetime: ServiceLifetime.Singleton);
285
286 _singletonInstances[serviceType] = instance;
287 }
288 }

다음을 참조함 : _descriptors, _singletonInstances, _syncRoot.

◆ RegisterSingleton< TService, TImplementation >()

void Dreamine.MVVM.Core.DependencyInjection.DreamineContainer.RegisterSingleton< TService, TImplementation > ( )
inline

Register Singleton 작업을 수행합니다.

템플릿 파라메터
TServiceTService 형식 매개변수입니다.
TImplementationTImplementation 형식 매개변수입니다.
타입 한정자들
TService :class 
TImplementation :class 
TImplementation :TService 

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

337 : class
338 where TImplementation : class, TService
339 {
340 Type serviceType = typeof(TService);
341 Type implementationType = typeof(TImplementation);
342
343 lock (_syncRoot)
344 {
345 _descriptors[serviceType] = new ServiceDescriptor(
346 serviceType,
347 implementationType,
348 factory: null,
349 instance: null,
350 lifetime: ServiceLifetime.Singleton);
351 _singletonInstances.Remove(serviceType);
352 }
353 }

다음을 참조함 : _descriptors, _singletonInstances, _syncRoot.

◆ Resolve()

object Dreamine.MVVM.Core.DependencyInjection.DreamineContainer.Resolve ( Type serviceType)
inline

Resolve 작업을 수행합니다.

매개변수
serviceTypeservice Type에 사용할 Type 값입니다.
반환값
Resolve 작업에서 생성한 object 결과입니다.
예외
ArgumentNullException필수 입력 인자 중 하나가 null인 경우 발생합니다.

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

510 {
511 if (serviceType is null)
512 {
513 throw new ArgumentNullException(nameof(serviceType));
514 }
515
516 // AsyncLocal context setup is per-async-flow and must live outside the lock
517 // so that nested Resolve calls on the same flow see the same context
518 // without requiring lock re-entry ordering to be preserved.
519 ResolutionContext? previousContext = _currentResolutionContext.Value;
520 bool ownsContext = previousContext is null;
521 if (ownsContext)
522 {
523 _currentResolutionContext.Value = new ResolutionContext();
524 }
525
526 try
527 {
528 lock (_syncRoot)
529 {
530 return ResolveCore(serviceType);
531 }
532 }
533 finally
534 {
535 if (ownsContext)
536 {
537 _currentResolutionContext.Value = null;
538 }
539 }
540 }

다음을 참조함 : _currentResolutionContext, _syncRoot, ResolveCore().

다음에 의해서 참조됨 : Resolve< TService >().

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

◆ Resolve< TService >()

Resolve 작업을 수행합니다.

템플릿 파라메터
TServiceTService 형식 매개변수입니다.
반환값
Resolve 작업에서 생성한 TService 결과입니다.
타입 한정자들
TService :class 

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

425 : class
426 {
427 return (TService)Resolve(typeof(TService));
428 }

다음을 참조함 : Resolve().

다음에 의해서 참조됨 : TryResolve< TService >().

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

◆ ResolveCore()

object Dreamine.MVVM.Core.DependencyInjection.DreamineContainer.ResolveCore ( Type serviceType)
inlineprivate

Resolve Core 작업을 수행합니다.

매개변수
serviceTypeservice Type에 사용할 Type 값입니다.
반환값
Resolve Core 작업에서 생성한 object 결과입니다.
예외
InvalidOperationException현재 객체 상태에서 Resolve Core 작업을 수행할 수 없는 경우 발생합니다.

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

575 {
576 if (_singletonInstances.TryGetValue(serviceType, out object? singleton))
577 {
578 return singleton;
579 }
580
581 if (!_descriptors.TryGetValue(serviceType, out ServiceDescriptor? descriptor))
582 {
583 if (CanCreateUnregisteredConcreteType(serviceType))
584 {
585 return CreateConcrete(serviceType);
586 }
587
588 throw new InvalidOperationException(
589 $"Service [{serviceType.FullName}] is not registered.");
590 }
591
592 if (descriptor.Factory is not null)
593 {
594 return descriptor.Factory();
595 }
596
597 if (descriptor.Instance is not null)
598 {
599 return descriptor.Instance;
600 }
601
602 if (descriptor.ImplementationType is null)
603 {
604 throw new InvalidOperationException(
605 $"Service [{serviceType.FullName}] has no implementation type.");
606 }
607
608 object instance = CreateConcrete(descriptor.ImplementationType);
609
610 if (descriptor.Lifetime == ServiceLifetime.Singleton)
611 {
612 _singletonInstances[serviceType] = instance;
613 }
614
615 return instance;
616 }

다음을 참조함 : _descriptors, _singletonInstances, CanCreateUnregisteredConcreteType(), CreateConcrete().

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

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

◆ TryResolve< TService >()

bool Dreamine.MVVM.Core.DependencyInjection.DreamineContainer.TryResolve< TService > ( out TService? result)
inline

Resolve 작업을 시도하고 성공 여부를 반환합니다.

템플릿 파라메터
TServiceTService 형식 매개변수입니다.
매개변수
resultresult에 사용할 TService 값입니다.
반환값
Try Resolve 조건이 충족되면 true이고, 그렇지 않으면 false입니다.
타입 한정자들
TService :class 

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

463 : class
464 {
465 try
466 {
467 result = Resolve<TService>();
468 return true;
469 }
470 catch (InvalidOperationException)
471 {
472 result = null;
473 return false;
474 }
475 }

다음을 참조함 : Resolve< TService >().

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

멤버 데이터 문서화

◆ _currentResolutionContext

readonly AsyncLocal<ResolutionContext?> Dreamine.MVVM.Core.DependencyInjection.DreamineContainer._currentResolutionContext = new()
private

current Resolution Context 값을 보관합니다.

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

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

◆ _descriptors

readonly Dictionary<Type, ServiceDescriptor> Dreamine.MVVM.Core.DependencyInjection.DreamineContainer._descriptors = new()
private

descriptors 값을 보관합니다.

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

다음에 의해서 참조됨 : Dispose(), IsRegistered(), Register< TService >(), Register< TService, TImplementation >(), RegisterSingleton< TService >(), RegisterSingleton< TService, TImplementation >(), ResolveCore().

◆ _disposed

bool Dreamine.MVVM.Core.DependencyInjection.DreamineContainer._disposed
private

disposed 값을 보관합니다.

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

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

◆ _objectActivator

readonly IObjectActivator Dreamine.MVVM.Core.DependencyInjection.DreamineContainer._objectActivator
private

object Activator 값을 보관합니다.

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

다음에 의해서 참조됨 : CreateConcrete(), DreamineContainer().

◆ _singletonInstances

readonly Dictionary<Type, object> Dreamine.MVVM.Core.DependencyInjection.DreamineContainer._singletonInstances = new()
private

singleton Instances 값을 보관합니다.

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

다음에 의해서 참조됨 : Dispose(), Register< TService >(), Register< TService, TImplementation >(), RegisterSingleton< TService >(), RegisterSingleton< TService, TImplementation >(), ResolveCore().

◆ _syncRoot

readonly object Dreamine.MVVM.Core.DependencyInjection.DreamineContainer._syncRoot = new()
private

sync Root 값을 보관합니다.

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

다음에 의해서 참조됨 : Dispose(), IsRegistered(), Register< TService >(), Register< TService, TImplementation >(), RegisterSingleton< TService >(), RegisterSingleton< TService, TImplementation >(), Resolve().


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