internal static bool CanBeResolvedGloballySafe(this DependencySource source, [NotNull] Type type, out DependencySource actualSource) { if (type == null) { throw new ArgumentNullException(nameof(type)); } if (!source.Includes(DependencySource.Global)) { actualSource = default; return(false); } var containers = Object.FindObjectsOfType <RootDependencyContainer>(); var canBeResolved = false; foreach (var container in containers) { if (container.CanBeResolvedSafe(type)) { canBeResolved = true; break; } } actualSource = canBeResolved ? DependencySource.Global : default; return(canBeResolved); }
private static bool CanBeResolvedGloballySafe(this DependencySource source, Type type) { if (!source.Includes(Global)) { return(false); } var container = Object.FindObjectOfType <RootDependencyContainer>(); return(container && container.CanBeResolvedSafe(type)); }
private static bool TryResolveLocally(DependencySource source, Context context, Type type, out object result) { if (source.Includes(Local) && context.Component.TryGetComponent(type, out var foundComponent)) { result = foundComponent; return(true); } result = default; return(false); }
private static bool TryResolveGlobally(this DependencySource source, Type type, out object result) { var container = RootDependencyContainer.Instance; if (source.Includes(Global) && container && container.TryResolve(type, out result)) { return(true); } result = default; return(false); }
private static bool TryResolveInParent(DependencySource source, Context context, Type type, out object result) { if (source.Includes(Parent)) { var foundComponent = context.Resolver.GetComponentInParent(type); if (foundComponent != null) { result = foundComponent; return(true); } } result = default; return(false); }
private static bool TryResolveGlobally(this DependencySource source, [NotNull] RootDependencyContainer container, [NotNull] Type type, out object result, out DependencySource actualSource) { if (container == null) { throw new ArgumentNullException(nameof(container)); } if (type == null) { throw new ArgumentNullException(nameof(type)); } if (source.Includes(DependencySource.Global) && container && container.TryResolve(type, out result)) { actualSource = DependencySource.Global; return(true); } result = default; actualSource = default; return(false); }