Click or drag to resize

AutofacParameterBuilderVisitor Class

Visitor for resolving object construction parameters from ParameterValue registrations during container configuration.
Inheritance Hierarchy
SystemObject
  ParameterValueVisitor
    Autofac.Extras.EnterpriseLibraryConfiguratorAutofacParameterBuilderVisitor

Namespace:  Autofac.Extras.EnterpriseLibraryConfigurator
Assembly:  Autofac.Extras.EnterpriseLibraryConfigurator (in Autofac.Extras.EnterpriseLibraryConfigurator.dll) Version: 4.0.0-CI-216
Syntax
public class AutofacParameterBuilderVisitor : ParameterValueVisitor

The AutofacParameterBuilderVisitor type exposes the following members.

Constructors
  NameDescription
Public methodAutofacParameterBuilderVisitor
Initializes a new instance of the AutofacParameterBuilderVisitor class.
Top
Properties
  NameDescription
Public propertyAutofacParameter
Gets the generated Parameter after executing Visit(ParameterValue).
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodVisit (Inherited from ParameterValueVisitor.)
Protected methodVisitConstantParameterValue
The method called when a ConstantParameterValue object is visited.
(Overrides ParameterValueVisitor.VisitConstantParameterValue(ConstantParameterValue).)
Protected methodVisitEnumerableParameterValue
The method called when a ContainerResolvedEnumerableParameter object is visited.
(Overrides ParameterValueVisitor.VisitEnumerableParameterValue(ContainerResolvedEnumerableParameter).)
Protected methodVisitParameterValue (Inherited from ParameterValueVisitor.)
Protected methodVisitResolvedParameterValue
The method called when a ContainerResolvedParameter object is visited.
(Overrides ParameterValueVisitor.VisitResolvedParameterValue(ContainerResolvedParameter).)
Top
Remarks

When registering a dependency from Enterprise Library, you get an instance of TypeRegistration. To construct an instance of the type described by the registration, you need to add the registration to your ContainerBuilder with a corresponding set of Parameter values.

To convert the constructor parameters from Enterprise Library format to Autofac format, you need to look at each of the ConstructorParameters and create a corresponding Parameter that can be added to the dependency registration in the Autofac container.

This class takes advantage of the Visit(ParameterValue) method to determine the type of the parameter and creates a corresponding ResolvedParameter with the appropriate value.

Parameter TypeResolved Parameter Value
ConstantParameterValue The exact provided constant value. (VisitConstantParameterValue(ConstantParameterValue))
ContainerResolvedEnumerableParameter A lambda that builds a generic list of the specified type containing the set of resolved named service instances. (VisitEnumerableParameterValue(ContainerResolvedEnumerableParameter))
ContainerResolvedParameter If the parameter is a named parameter, the named service is resolved; otherwise the typed service is resolved. (VisitResolvedParameterValue(ContainerResolvedParameter))

After calling the Visit(ParameterValue) method on this visitor, the AutofacParameter property will be set with the output of the transformation. You can use this in conjunction with WithParametersTLimit, TReflectionActivatorData, TStyle(IRegistrationBuilderTLimit, TReflectionActivatorData, TStyle, IEnumerableParameter) to add the parameters to the component registration.

Normally this class will not be used by itself. Instead, consider using it in conjunction with the AutofacContainerConfigurator and the Enterprise Library registration extension methods in EnterpriseLibraryRegistrationExtensions.

For more information on how type registrations are created and the possible values of constant and resolved parameters, see TypeRegistration, which is the entry point for creating parameter values, and Container, which is the placeholder class used by the registration mechanism for signifying that a parameter value is resolved rather than constant.

See Also