protected override void VisitEnumerableParameterValue(ContainerResolvedEnumerableParameter parameterValue) { var resolveParameters = parameterValue.Names .Select(name => new ResolvedParameter(parameterValue.ElementType, name)) .ToArray(); InjectionParameter = new ResolvedArrayParameter(parameterValue.ElementType, resolveParameters); }
/// <summary> /// The method called when a /// <see cref="T:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ContainerResolvedEnumerableParameter"/> /// object is visited. /// </summary> /// <param name="parameterValue"> /// The <see cref="T:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ContainerResolvedEnumerableParameter"/> to process. /// </param> /// <remarks> /// <para> /// Resolved enumerables in Enterprise Library are always made up of /// a list of individual named resolutions - there is no notion of a /// typed auto-collection resolution the way there is in Autofac. /// </para> /// <para> /// As such, the <see cref="Autofac.Core.ResolvedParameter"/> lambda /// this method generates is a loop over the set of resolved named /// typed registrations to build them manually into a list of the /// type specified. /// </para> /// </remarks> /// <exception cref="System.ArgumentNullException"> /// Thrown if <paramref name="parameterValue" /> is <see langword="null" />. /// </exception> protected override void VisitEnumerableParameterValue(ContainerResolvedEnumerableParameter parameterValue) { if (parameterValue == null) { throw new ArgumentNullException("parameterValue"); } this.AutofacParameter = this.CreateResolvedParameter( (pi, context) => { var listType = typeof(List <>).MakeGenericType(parameterValue.ElementType); var list = Activator.CreateInstance(listType) as IList; foreach (var name in parameterValue.Names) { list.Add(context.ResolveNamed(name, parameterValue.ElementType)); } return(list); }); }
public void PublicVisitEnumerableParameterValue(ContainerResolvedEnumerableParameter parameterValue) { base.VisitEnumerableParameterValue(parameterValue); }
/// <summary> /// The method called when a <see cref="T:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ContainerResolvedEnumerableParameter"/> object is visited. /// </summary> /// <param name="parameterValue">The <see cref="T:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ContainerResolvedEnumerableParameter"/> to process.</param> protected override void VisitEnumerableParameterValue(ContainerResolvedEnumerableParameter parameterValue) { InjectionParameters = parameterValue.Names .Select(name => Property.ForKey(parameterValue.ElementType).Is(name)) .ToArray(); }