public override ObjectBuilderState TryGetFirstValid(IInjectionTargetInfo targetInfo, out ObjectBuilder builder) { builder = null; if (_candidates.Count == 0) { return(ObjectBuilderState.Unregistered); } foreach (var candidate in _candidates) { var candidateBuilder = candidate.ObjectBuilder; if (!candidateBuilder.MatchCondition(targetInfo) || candidateBuilder.Obsolete) { continue; } if (builder == null) { builder = candidateBuilder; } else { throw AmbiguousObjectBuilderException(true); } } return(builder != null ? ObjectBuilderState.Normal : ObjectBuilderState.Invalid); }
public override List <ObjectBuilder> GetAllValid(IInjectionTargetInfo targetInfo) { var builder = MyRegistration.ObjectBuilder; return(!builder.MatchCondition(targetInfo) || builder.Obsolete ? null : new List <ObjectBuilder> { builder }); }
bool TryGetCore(Type contract, IInjectionTargetInfo targetInfo, out ObjectBuilderGroup group, out List <ObjectBuilder> builders) { var key = GetKey(contract); _operationLock.EnterReadLock(); try { if (_key2Groups.TryGetValue(key, out group)) { builders = targetInfo != null ? group.GetAllValid(targetInfo) : group.GetAllValid(); if (builders != null) { return(true); } } } finally { _operationLock.ExitReadLock(); } var args = new ObjectRequestedEventArgs(_kernel, contract, targetInfo); if (!HandleObjectBuilderRequest(args)) { builders = null; return(false); } _operationLock.EnterReadLock(); try { if (group == null && !_key2Groups.TryGetValue(key, out group)) { builders = null; return(false); } builders = targetInfo != null ? group.GetAllValid(targetInfo) : group.GetAllValid(); return(builders != null); } finally { _operationLock.ExitReadLock(); } }
ObjectBuilderState TryGetCore(Type contract, IInjectionTargetInfo targetInfo, out ObjectBuilderGroup group, out ObjectBuilder builder) { var result = ObjectBuilderState.Unregistered; var key = GetKey(contract); _operationLock.EnterReadLock(); try { if (_key2Groups.TryGetValue(key, out group)) { result = targetInfo != null ? group.TryGetFirstValid(targetInfo, out builder) : group.TryGetFirstValid(out builder); if (result == ObjectBuilderState.Normal) { return(result); } } } finally { _operationLock.ExitReadLock(); } var args = new ObjectRequestedEventArgs(_kernel, contract, targetInfo); if (!HandleObjectBuilderRequest(args)) { builder = null; return(result); } _operationLock.EnterReadLock(); try { if (group == null && !_key2Groups.TryGetValue(key, out group)) { builder = null; return(result); } return(targetInfo != null ? group.TryGetFirstValid(targetInfo, out builder) : group.TryGetFirstValid(out builder)); } finally { _operationLock.ExitReadLock(); } }
public ObjectCollectionObserver(ObjectBuilderGroup group, List <ObjectBuilder> builders, IInjectionTargetInfo targetInfo) : base(group) { if (SystemHelper.MultiProcessors) { _lock = new SpinLockSlim(); } else { _lock = new MonitorLock(); } _builders = builders; _targetInfo = targetInfo; }
public bool Match(IInjectionTargetInfo targetInfo) { if (targetInfo == null) { return(false); } var targetType = targetInfo.TargetDescription.ConcreteType; foreach (var expectedType in _expectedTypes) { if (targetType == expectedType) { return(true); } } return(false); }
public bool TryGet(Type injectable, IInjectionTargetInfo targetInfo, out ObjectCollectionObserver observer) { Requires.NotNull(injectable, "injectable"); Requires.NotNull(targetInfo, "info"); ObjectBuilderGroup group; List <ObjectBuilder> builders; if (!TryGetCore(injectable, targetInfo, out group, out builders)) { observer = null; return(false); } var obs = new ObjectCollectionObserver(group, builders, targetInfo); group.AddObserver(obs); observer = obs; return(true); }
internal static DependencyProvider CreateAutowiredDependencyProvider(IInjectionTargetInfo injectionTargetInfo, bool strongTyped) { if (!strongTyped) { return(new WeakAutowiredDependencyProvider(injectionTargetInfo)); } var strongDependencyProviderType = typeof(StrongAutowiredDependencyProvider <>).MakeGenericType(injectionTargetInfo.TargetType); try { return((DependencyProvider)Activator.CreateInstance(strongDependencyProviderType, injectionTargetInfo)); } catch (TargetInvocationException ex) { throw ex.InnerException; } }
public override ObjectBuilderState TryGetFirstValid(IInjectionTargetInfo targetInfo, out ObjectBuilder builder) { builder = null; if (MyRegistration == null) { return(ObjectBuilderState.Unregistered); } var myBuilder = MyRegistration.ObjectBuilder; if (!myBuilder.MatchCondition(targetInfo) || myBuilder.Obsolete) { return(ObjectBuilderState.Invalid); } builder = myBuilder; return(ObjectBuilderState.Normal); }
public override List <ObjectBuilder> GetAllValid(IInjectionTargetInfo targetInfo) { List <ObjectBuilder> builders = null; foreach (var candidate in _candidates) { var candidateBuilder = candidate.ObjectBuilder; if (!candidateBuilder.MatchCondition(targetInfo) || candidateBuilder.Obsolete) { continue; } if (builders == null) { builders = new List <ObjectBuilder>(); } builders.Add(candidateBuilder); } return(builders); }
ObjectBuilder DoGetObjectBuilder(Type concreteType, IInjectionTargetInfo injectionTargetInfo) { if (_registrationPolicies == null || !concreteType.IsConcrete()) { return(null); } IAutoRegistrationPolicy matchPolicy = null; for (int i = 0; i < _registrationPolicies.Length; i++) { var autoRegistrationPolicy = _registrationPolicies[i]; if (!autoRegistrationPolicy.ShouldRegister(concreteType)) { continue; } matchPolicy = autoRegistrationPolicy; break; } if (matchPolicy == null) { return(null); } IObjectRegistration registration; _registrar.Register(concreteType).In(matchPolicy.GetLifetimeProvider()).Return(out registration); if (!registration.ObjectBuilder.MatchCondition(injectionTargetInfo)) { return(null); } _registrar.CommitRegistrations(); return(registration.ObjectBuilder); }
protected DependencyResolverBase(IInjectionTargetInfo targetInfo) { MyTargetInfo = targetInfo; }
public WeakDependencyResolver(IInjectionTargetInfo targetInfo) : base(targetInfo) { }
protected CollectionDependencyResolver(IInjectionTargetInfo targetInfo, IObjectMapper mapper) : this(targetInfo, mapper, null) { }
protected CollectionDependencyResolver(IInjectionTargetInfo targetInfo, IObjectMapper mapper, ObjectCollectionObserver observer) : base(targetInfo) { MyMapper = mapper; MyObserver = observer; }
public virtual void Dispose() { MyTargetInfo = null; }
internal abstract bool MatchCondition(IInjectionTargetInfo targetInfo);
public ParameterExpression GetLocateDependencyExpression(Type importType = null, string importName = null, IInjectionTargetInfo targetInfo = null, string variableName = null, bool isRequired = true, IExportValueProvider valueProvider = null, ExportStrategyFilter exportStrategyFilter = null, ILocateKeyValueProvider locateKey = null, object comparerObject = null) { if (importType == null && importName == null) { throw new ArgumentException("GetLocateDependencyExpression must be called with importType or "); } return null; }
public MappableStrongDependencyResolver(IInjectionTargetInfo targetInfo, IObjectMapper mapper) : base(targetInfo) { _mapper = mapper; }
/// <summary> /// Default constructor /// </summary> /// <param name="locateName">name used to locate</param> /// <param name="locateType">type used to locate</param> /// <param name="targetInfo"></param> public LocationInformationEntry(string locateName, TypeWrapper locateType, IInjectionTargetInfo targetInfo) { TargetInfo = targetInfo; LocateName = locateName; LocateType = locateType; }
public ObjectBuilderState TryGet(Type injectable, IInjectionTargetInfo targetInfo, out ObjectBuilder builder) { Requires.NotNull(injectable, "injectable"); Requires.NotNull(targetInfo, "info"); return(TryGetCore(injectable, targetInfo, out builder)); }
public bool Match(IInjectionTargetInfo targetInfo) { return(targetInfo != null && _condition.Invoke(targetInfo)); }
ObjectBuilderState TryGetCore(Type contract, IInjectionTargetInfo targetInfo, out ObjectBuilder builder) { ObjectBuilderGroup group; return(TryGetCore(contract, targetInfo, out group, out builder)); }
public bool Match(IInjectionTargetInfo targetInfo) { return(targetInfo != null && (_expectedType == targetInfo.TargetDescription.ConcreteType || _expectedType.IsAssignableFrom(targetInfo.TargetDescription.ConcreteType))); }
public MappableWeakDependencyResolver(IInjectionTargetInfo targetInfo, IObjectMapper mapper) : base(targetInfo) { MyMapper = mapper; }
public bool Match(IInjectionTargetInfo targetInfo) { return(targetInfo != null && _metadata.Equals(targetInfo.TargetDescription.Metadata)); }
public StrongDependencyResolver(IInjectionTargetInfo targetInfo) : base(targetInfo) { }
internal static DependencyProvider CreateAutowiredDependencyProvider <TParam>(IInjectionTargetInfo injectionTargetInfo) { return(new StrongAutowiredDependencyProvider <TParam>(injectionTargetInfo)); }
public MappableStrongCollectionDependencyResolver(IInjectionTargetInfo targetInfo, IObjectMapper mapper) : base(targetInfo, mapper) { }
internal static DependencyProvider CreateAutowiredDependencyProvider(IInjectionTargetInfo injectionTargetInfo) { return(new WeakAutowiredDependencyProvider(injectionTargetInfo)); }
protected SingleDependencyResolver(IInjectionTargetInfo targetInfo) : base(targetInfo) { }
internal override bool MatchCondition(IInjectionTargetInfo targetInfo) { return(_condition.Match(targetInfo) && base.MatchCondition(targetInfo)); }