public void GetAllInstancesWithInjectSplit( InjectContext context, List <TypeValuePair> args, out Action injectAction, List <object> buffer) { Assert.IsEmpty(args); Assert.IsNotNull(context); Assert.That(typeof(TReturn).DerivesFromOrEqual(context.MemberType)); injectAction = null; if (_container.IsValidating && !TypeAnalyzer.ShouldAllowDuringValidation(context.MemberType)) { buffer.Add(new ValidationMarker(typeof(TReturn))); } else { var result = _method(context); if (result == null) { throw Assert.CreateException( "Method '{0}' returned null when list was expected. Object graph:\n {1}", _method.ToDebugString(), context.GetObjectGraphString()); } foreach (var obj in result) { buffer.Add(obj); } } }
public void GetAllInstancesWithInjectSplit( InjectContext context, List <TypeValuePair> args, out Action injectAction, List <object> buffer) { Assert.IsNotNull(context); #if UNIDI_MULTITHREADING lock (_locker) #endif { var instances = TryGetMatchFromCache(context.MemberType); if (instances != null) { injectAction = null; buffer.AllocFreeAddRange(instances); return; } #if !UNIDI_MULTITHREADING // This should only happen with constructor injection // Field or property injection should allow circular dependencies if (_isCreatingInstance) { var instanceType = _creator.GetInstanceType(context); throw Assert.CreateException( "Found circular dependency when creating type '{0}'. Object graph:\n {1}{2}\n", instanceType, context.GetObjectGraphString(), instanceType); } _isCreatingInstance = true; #endif instances = new List <object>(); _creator.GetAllInstancesWithInjectSplit( context, args, out injectAction, instances); Assert.IsNotNull(instances); _cachedInstances.Add(instances); #if !UNIDI_MULTITHREADING _isCreatingInstance = false; #endif buffer.AllocFreeAddRange(instances); } }
public DiContainer CreateSubContainer(List <TypeValuePair> args, InjectContext context, out Action injectAction) { // We can't really support arguments if we are using the cached value since // the arguments might change when called after the first time Assert.IsEmpty(args); #if UNIDI_MULTITHREADING lock (_locker) #endif { if (_subContainer == null) { #if !UNIDI_MULTITHREADING Assert.That(!_isLookingUp, "Found unresolvable circular dependency when looking up sub container! Object graph:\n {0}", context.GetObjectGraphString()); _isLookingUp = true; #endif _subContainer = _subCreator.CreateSubContainer( new List <TypeValuePair>(), context, out injectAction); #if !UNIDI_MULTITHREADING _isLookingUp = false; #endif Assert.IsNotNull(_subContainer); } else { injectAction = null; } return(_subContainer); } }