/// <summary> /// Check if injection is baked for the type. /// </summary> /// <param name="type">Checked type.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">If <paramref name="type"/> is null.</exception> public static bool IsInjectionBaked([NotNull] Type type) { if (type == null) { throw new ArgumentNullException(nameof(type)); } return(BakedInjectionFunctions.TryGetValue(type, out _)); }
/// <summary> /// Try inject using baked data. /// </summary> /// <param name="component">Component to inject dependencies to.</param> /// <param name="resolutionFunction">Resolution provider.</param> /// <returns>True if baked and injected, false otherwise.</returns> /// <exception cref="ArgumentNullException">If any of arguments are null.</exception> public static bool TryInject([NotNull] MonoBehaviour component, [NotNull] ResolutionFunction resolutionFunction) { if (component == null) { throw new ArgumentNullException(nameof(component)); } if (resolutionFunction == null) { throw new ArgumentNullException(nameof(resolutionFunction)); } if (!BakedInjectionFunctions.TryGetValue(component.GetType(), out var injectionFunction)) { return(false); } injectionFunction(component, resolutionFunction); return(true); }