Exemple #1
0
        public void ThenSingleInjectedPropertyForConstantValue()
        {
            ConstantParameterValue param =
                (ConstantParameterValue)registration.InjectedProperties.ElementAt(0).PropertyValue;

            Assert.AreEqual("value", param.Value);
        }
 /// <summary>
 /// The method called when a
 /// <see cref="T:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ConstantParameterValue"/>
 /// object is visited.
 /// </summary>
 /// <param name="parameterValue">
 /// The <see cref="T:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ConstantParameterValue"/> to process.
 /// </param>
 /// <remarks>
 /// <para>
 /// This method creates a <see cref="Autofac.Core.ResolvedParameter"/>
 /// based on the constant value in <paramref name="parameterValue" />
 /// and ties it to 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 VisitConstantParameterValue(ConstantParameterValue parameterValue)
 {
     if (parameterValue == null)
     {
         throw new ArgumentNullException("parameterValue");
     }
     this.AutofacParameter = this.CreateResolvedParameter((pi, context) => parameterValue.Value);
 }
Exemple #3
0
        public void ThenRegistrationHasOptionalContainerResolvedParameter()
        {
            ConstantParameterValue param =
                (ConstantParameterValue)registration.ConstructorParameters.ElementAt(2);

            Assert.AreEqual(typeof(IBar), param.Type);
            Assert.AreEqual(null, param.Value);
        }
Exemple #4
0
        public void ThenPropertyValuesMatchSuppliedValues()
        {
            ConstantParameterValue anotherPropertyValue =
                (ConstantParameterValue)registration.InjectedProperties.First(p => p.PropertyName == "AnotherProperty").PropertyValue;

            Assert.AreEqual(42, anotherPropertyValue.Value);

            ConstantParameterValue propertyValue =
                (ConstantParameterValue)registration.InjectedProperties.First(p => p.PropertyName == "Property").PropertyValue;

            Assert.AreEqual("value", propertyValue.Value);
        }
 public void PublicVisitConstantParameterValue(ConstantParameterValue parameterValue)
 {
     base.VisitConstantParameterValue(parameterValue);
 }
 protected override void VisitConstantParameterValue(ConstantParameterValue parameterValue)
 {
     this.InjectionParameter = new InjectionParameter(parameterValue.Type, parameterValue.Value);
 }
 protected override void VisitConstantParameterValue(ConstantParameterValue parameterValue)
 {
     this.InjectionParameter = new InjectionParameter(parameterValue.Type, parameterValue.Value);
 }
Exemple #8
0
        public void WhenRegistryTypeInstantiated_ConstantConstructorResultsInValueParameterDependency()
        {
            ConstantParameterValue param = (ConstantParameterValue)registration.ConstructorParameters.ElementAt(0);

            Assert.AreEqual("aString", param.Value);
        }
            /// <summary>
            /// The method called when a <see cref="T:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ConstantParameterValue"/> object is visited.
            /// </summary>
            /// <param name="parameterValue">The <see cref="T:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ConstantParameterValue"/> to process.</param>
            protected override void VisitConstantParameterValue(ConstantParameterValue parameterValue)
            {
                String key = ((MemberExpression)parameterValue.Expression).Member.Name;

                InjectionParameters = new Property[] { Property.ForKey(key).Eq(parameterValue.Value) };
            }