/// <summary> /// Determines whether the required dependency has been registered /// </summary> /// <typeparam name="TAbstract">Type of the singleton or dependency</typeparam> /// <remarks> /// Services will be loaded if exists in this order: /// - Initialized singletons /// - Uninitialized singletons /// - Transients /// </remarks> public bool HasRequiredDependency(Type serviceType) { if (InitializedSingletons.ContainsKey(serviceType)) { return(true); } else if (RegisteredSingletons.ContainsKey(serviceType)) { return(true); } else if (RegisteredTransients.ContainsKey(serviceType)) { return(true); } else { return(false); } }
/// <summary> /// Gets a registered singleton or transient dependency, or null if the dependency could not be found /// </summary> /// <typeparam name="TAbstract">Type of the singleton or dependency</typeparam> /// <remarks> /// Services will be loaded if exists in this order: /// - Initialized singletons /// - Uninitialized singletons /// - Transients /// </remarks> public object GetRequiredDependency(Type serviceType) { if (InitializedSingletons.ContainsKey(serviceType)) { return(InitializedSingletons[serviceType]); } else if (RegisteredSingletons.ContainsKey(serviceType)) { var instance = RegisteredSingletons[serviceType].Invoke(this); InitializedSingletons.Add(serviceType, instance); return(instance); } else if (RegisteredTransients.ContainsKey(serviceType)) { return(RegisteredTransients[serviceType].Invoke(this)); } else { return(null); } }