Skip to main content

InstanceGenericFirstDependencyResolver

Struct InstanceGenericFirstDependencyResolver 

Source
pub struct InstanceGenericFirstDependencyResolver { /* private fields */ }
Expand description

A resolver whose registrations belong to the instance, kept per service type and contract (InstanceGenericFirstDependencyResolver). It is the resolver AppLocator starts with.

A registration runs the callbacks of its service type and contract; disposing the resolver drops its registrations, disposes the constants and the created lazy singletons that were registered as disposable, and runs every callback once more.

Implementations§

Source§

impl InstanceGenericFirstDependencyResolver

Source

pub fn new() -> Self

An empty resolver.

Source

pub fn with_configuration( configure: impl FnOnce(&dyn IMutableDependencyResolver), ) -> Self

A resolver that configure registers services with first (InstanceGenericFirstDependencyResolver(Action<IMutableDependencyResolver>?)).

Trait Implementations§

Source§

impl Default for InstanceGenericFirstDependencyResolver

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl IDisposable for InstanceGenericFirstDependencyResolver

Source§

fn dispose(&self)

Source§

impl IMutableDependencyResolver for InstanceGenericFirstDependencyResolver

Source§

fn has_registration_erased( &self, service_type: ServiceType, contract: Option<&str>, ) -> bool

Whether a service is registered for service_type and contract (HasRegistration<T>).
Source§

fn register_erased( &self, factory: ServiceFactory, service_type: ServiceType, contract: Option<&str>, )

Registers a factory, called for each resolution (Register<T>(Func<T?>, string?)).
Source§

fn register_constant_erased( &self, value: Option<ErasedService>, disposal: Option<Rc<dyn Fn()>>, service_type: ServiceType, contract: Option<&str>, )

Registers a constant (RegisterConstant<T>(T?, string?)). disposal is what disposing the resolver does with it: upstream disposes a constant that is IDisposable.
Source§

fn register_lazy_singleton_erased( &self, factory: ServiceFactory, disposal: Option<LazyDisposal>, service_type: ServiceType, contract: Option<&str>, )

Registers a singleton created by factory on its first resolution (RegisterLazySingleton<T>(Func<T?>, string?)). disposal is what disposing the resolver does with the value once it was created.
Source§

fn unregister_current_erased( &self, service_type: ServiceType, contract: Option<&str>, )

Removes the last registration (UnregisterCurrent<T>(string?)).
Source§

fn unregister_all_erased( &self, service_type: ServiceType, contract: Option<&str>, )

Removes every registration (UnregisterAll<T>(string?)).
Source§

fn service_registration_callback_erased( &self, service_type: ServiceType, contract: Option<&str>, callback: RegistrationCallback, ) -> Rc<dyn IDisposable>

Calls callback for every registration, those that exist and those to come, until the returned disposable is disposed (ServiceRegistrationCallback<T>(string?, Action<IDisposable>)).
Source§

impl IReadonlyDependencyResolver for InstanceGenericFirstDependencyResolver

Source§

fn get_service_erased( &self, service_type: ServiceType, contract: Option<&str>, ) -> Option<ErasedService>

The last service registered for service_type and contract, or None (GetService<T>(string? contract)).
Source§

fn get_services_erased( &self, service_type: ServiceType, contract: Option<&str>, ) -> Vec<ErasedService> ⓘ

Every service registered for service_type and contract, in the order of registration (GetServices<T>(string? contract)).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<R> IDependencyResolver for R

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<R> MutableDependencyResolverExt for R

Source§

fn has_registration<S: ?Sized + 'static>(&self) -> bool

HasRegistration<T>().
Source§

fn has_registration_with_contract<S: ?Sized + 'static>( &self, contract: Option<&str>, ) -> bool

HasRegistration<T>(string? contract).
Source§

fn register<S: ?Sized + 'static>( &self, factory: impl Fn() -> Option<Rc<S>> + 'static, )

Register<T>(Func<T?>).
Source§

fn register_with_contract<S: ?Sized + 'static>( &self, factory: impl Fn() -> Option<Rc<S>> + 'static, contract: Option<&str>, )

Register<T>(Func<T?>, string? contract).
Source§

fn register_constant<S: ?Sized + 'static>(&self, value: Rc<S>)

RegisterConstant<T>(T).
Source§

fn register_constant_with_contract<S: ?Sized + 'static>( &self, value: Rc<S>, contract: Option<&str>, )

RegisterConstant<T>(T, string? contract).
Source§

fn register_constant_disposable<S: ?Sized + IDisposable + 'static>( &self, value: Rc<S>, )

RegisterConstant<T>(T) of a constant that the resolver disposes when it is disposed.
Source§

fn register_constant_disposable_with_contract<S: ?Sized + IDisposable + 'static>( &self, value: Rc<S>, contract: Option<&str>, )

RegisterConstant<T>(T, string? contract) of a constant that the resolver disposes when it is disposed.
Source§

fn register_lazy_singleton<S: ?Sized + 'static>( &self, factory: impl Fn() -> Option<Rc<S>> + 'static, )

RegisterLazySingleton<T>(Func<T?>).
Source§

fn register_lazy_singleton_with_contract<S: ?Sized + 'static>( &self, factory: impl Fn() -> Option<Rc<S>> + 'static, contract: Option<&str>, )

RegisterLazySingleton<T>(Func<T?>, string? contract).
Source§

fn register_lazy_singleton_disposable<S: ?Sized + IDisposable + 'static>( &self, factory: impl Fn() -> Option<Rc<S>> + 'static, )

RegisterLazySingleton<T>(Func<T?>) of a singleton that the resolver disposes, once created, when it is disposed.
Source§

fn register_lazy_singleton_disposable_with_contract<S: ?Sized + IDisposable + 'static>( &self, factory: impl Fn() -> Option<Rc<S>> + 'static, contract: Option<&str>, )

RegisterLazySingleton<T>(Func<T?>, string? contract) of a singleton that the resolver disposes, once created, when it is disposed.
Source§

fn unregister_current<S: ?Sized + 'static>(&self)

UnregisterCurrent<T>().
Source§

fn unregister_current_with_contract<S: ?Sized + 'static>( &self, contract: Option<&str>, )

UnregisterCurrent<T>(string? contract).
Source§

fn unregister_all<S: ?Sized + 'static>(&self)

UnregisterAll<T>().
Source§

fn unregister_all_with_contract<S: ?Sized + 'static>( &self, contract: Option<&str>, )

UnregisterAll<T>(string? contract).
Source§

fn service_registration_callback<S: ?Sized + 'static>( &self, callback: impl Fn(&dyn IDisposable) + 'static, ) -> Rc<dyn IDisposable>

ServiceRegistrationCallback<T>(Action<IDisposable>).
Source§

fn service_registration_callback_with_contract<S: ?Sized + 'static>( &self, contract: Option<&str>, callback: impl Fn(&dyn IDisposable) + 'static, ) -> Rc<dyn IDisposable>

ServiceRegistrationCallback<T>(string? contract, Action<IDisposable>).
Source§

impl<R> ReadonlyDependencyResolverExt for R

Source§

fn get_service<S: ?Sized + 'static>(&self) -> Option<Rc<S>>

GetService<T>().
Source§

fn get_service_with_contract<S: ?Sized + 'static>( &self, contract: Option<&str>, ) -> Option<Rc<S>>

GetService<T>(string? contract).
Source§

fn get_services<S: ?Sized + 'static>(&self) -> Vec<Rc<S>>

GetServices<T>().
Source§

fn get_services_with_contract<S: ?Sized + 'static>( &self, contract: Option<&str>, ) -> Vec<Rc<S>>

GetServices<T>(string? contract).
Source§

impl<R> ResolverMixins for R

Source§

fn register_and<S: Default + 'static>(&self) -> &Self

RegisterAnd<TService>(): a new S per resolution.
Source§

fn register_and_with_contract<S: Default + 'static>( &self, contract: &str, ) -> &Self

RegisterAnd<TService>(string contract).
Source§

fn register_and_factory<S: ?Sized + 'static>( &self, factory: impl Fn() -> Rc<S> + 'static, ) -> &Self

RegisterAnd<TService>(Func<TService>).
Source§

fn register_and_factory_with_contract<S: ?Sized + 'static>( &self, factory: impl Fn() -> Rc<S> + 'static, contract: &str, ) -> &Self

RegisterAnd<TService>(Func<TService>, string contract).
Source§

fn register_constant_and<S: Default + 'static>(&self) -> &Self

RegisterConstantAnd<TService>(): one new S, registered as a factory that returns it.
Source§

fn register_constant_and_with_contract<S: Default + 'static>( &self, contract: &str, ) -> &Self

RegisterConstantAnd<TService>(string contract).
Source§

fn register_constant_and_value<S: ?Sized + 'static>( &self, value: Rc<S>, ) -> &Self

RegisterConstantAnd<TService>(TService value).
Source§

fn register_constant_and_value_with_contract<S: ?Sized + 'static>( &self, value: Rc<S>, contract: &str, ) -> &Self

RegisterConstantAnd<TService>(TService value, string contract).
Source§

fn register_lazy_singleton_and<S: Default + 'static>(&self) -> &Self

RegisterLazySingletonAnd<TService>(): one S, created on the first resolution.
Source§

fn register_lazy_singleton_and_with_contract<S: Default + 'static>( &self, contract: &str, ) -> &Self

RegisterLazySingletonAnd<TService>(string contract).
Source§

fn register_lazy_singleton_and_factory<S: ?Sized + 'static>( &self, factory: impl Fn() -> Rc<S> + 'static, ) -> &Self

RegisterLazySingletonAnd<TService>(Func<TService>).
Source§

fn register_lazy_singleton_and_factory_with_contract<S: ?Sized + 'static>( &self, factory: impl Fn() -> Rc<S> + 'static, contract: &str, ) -> &Self

RegisterLazySingletonAnd<TService>(Func<TService>, string contract).
Source§

impl<R> ServiceLocationInitializationExt for R

Source§

fn initialize_splat(&self)

InitializeSplat.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.