Esempio n. 1
0
        public void ThenRegistrationHasOptionalContainerResolvedParameter()
        {
            ContainerResolvedParameter param =
                (ContainerResolvedParameter)registration.ConstructorParameters.ElementAt(2);

            Assert.AreEqual(typeof(IBar), param.Type);
            Assert.AreEqual("anotherBar", param.Name);
        }
Esempio n. 2
0
        public void WhenRegistryTypeInstantiated_ReferenceConstructorParamResultsInNamedContainerResolvedParameter()
        {
            ContainerResolvedParameter param =
                (ContainerResolvedParameter)registration.ConstructorParameters.ElementAt(2);

            Assert.AreEqual(typeof(IBar), param.Type);
            Assert.AreEqual("anotherBar", param.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>
 /// <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));
     }
 }
 public void PublicVisitResolvedParameterValue(ContainerResolvedParameter parameterValue)
 {
     base.VisitResolvedParameterValue(parameterValue);
 }
 protected override void VisitResolvedParameterValue(ContainerResolvedParameter parameterValue)
 {
     InjectionParameter = new ResolvedParameter(parameterValue.Type, parameterValue.Name);
 }
 protected override void VisitResolvedParameterValue(ContainerResolvedParameter parameterValue)
 {
     InjectionParameter = new ResolvedParameter(parameterValue.Type, parameterValue.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) };
 }