private IList <object> GetAll(Type service, string name = null, params IIocParameter[] parameters) { Should.NotBeNull(service, nameof(service)); var key = new BindingKey(service, name); List <BindingRegistration> registrations; lock (_bindingRegistrations) _bindingRegistrations.TryGetValue(key, out registrations); if (registrations != null && registrations.Count > 0) { var result = new object[registrations.Count]; for (int i = 0; i < registrations.Count; i++) { result[i] = registrations[i].Resolve(parameters); } return(result); } if (_parent != null && _parent.HasRegistration(key)) { return(_parent.GetAll(service, name, parameters)); } object value; if (TryResolve(service, parameters, out value)) { return new[] { value } } ; return(Empty.Array <object>()); }
private object ResolveParameter(Type type, ParameterInfo parameterInfo) { //Use default parameter value. if (parameterInfo.IsOptional && !_container.CanResolve(type)) { return(parameterInfo.DefaultValue); } var hasParamsAttr = parameterInfo.IsDefined(typeof(ParamArrayAttribute), false); //If have ParamArrayAttribute. if (hasParamsAttr) { #if NET4 var originalType = type.GetElementType(); #else var originalType = type.GetTypeInfo().GetElementType(); #endif //If exist array binding. if (_container.CanResolve(type)) { return(_container.Get(type)); } //If exist binding for type. if (_container.CanResolve(originalType)) { return(ConvertToArray(type, _container.GetAll(originalType))); } return(ConvertToArray(type, new object[0])); } return(_container.Get(type)); }