protected override void VisitResolvedParameterValue(ContainerResolvedParameter parameterValue) { string name = parameterValue.Name ?? String.Format("{0}.{1}", parameterValue.Type.Name, "__default__"); InjectionParameter = new RuntimeObjectReference(String.Concat(name,".", parameterValue.Type.Name)); }
/// <summary> /// The method called when a <see cref="T:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ContainerResolvedParameter"/> object is visited. /// </summary> /// <param name="parameterValue">The <see cref="T:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ContainerResolvedParameter"/> to process.</param> protected override void VisitResolvedParameterValue(ContainerResolvedParameter parameterValue) { InjectionParameters = new Property[] { Property.ForKey(parameterValue.Type).Is(parameterValue.Name) }; }
/// <summary> /// The method called when a <see cref="ContainerResolvedParameter"/> object is visited. /// </summary> /// <remarks>By default, this method throws an exception. Override it to provide your /// specific processing.</remarks> /// <param name="parameterValue">The <see cref="ContainerResolvedParameter"/> to process.</param> protected virtual void VisitResolvedParameterValue(ContainerResolvedParameter parameterValue) { VisitParameterValue(parameterValue); }
/// <summary> /// The method called when a /// <see cref="T:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ContainerResolvedParameter"/> /// object is visited. /// </summary> /// <param name="parameterValue"> /// The <see cref="T:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ContainerResolvedParameter"/> to process. /// </param> /// <remarks> /// <para> /// If the <see cref="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ContainerResolvedParameter.Name"/> /// is not set on the <paramref name="parameterValue" />, the value /// is assumed to be a typed registration. If the /// <see cref="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ContainerResolvedParameter.Name"/> /// is present, the value is assumed to be both typed and named. /// </para> /// <para> /// Either way, a <see cref="Autofac.Core.ResolvedParameter"/> will /// be created with a lambda that resolves the typed (and possibly named, /// as the case may be) service for the parameter passed in during construction. /// </para> /// </remarks> /// <exception cref="System.ArgumentNullException"> /// Thrown if <paramref name="parameterValue" /> is <see langword="null" />. /// </exception> protected override void VisitResolvedParameterValue(ContainerResolvedParameter parameterValue) { if (parameterValue == null) { throw new ArgumentNullException("parameterValue"); } if (!String.IsNullOrEmpty(parameterValue.Name)) { this.AutofacParameter = this.CreateResolvedParameter((pi, context) => context.ResolveNamed(parameterValue.Name, parameterValue.Type)); } else { this.AutofacParameter = this.CreateResolvedParameter((pi, context) => context.Resolve(parameterValue.Type)); } }