The method element contains details of the method injection requirements for this object type. You can include one or more method elements in each typeConfig section.
<method name="Initialize">
<param name="connectionString" parameterType="string">
<value value="contoso"/>
</param>
<param name="dataService" parameterType="IMyService">
<dependency />
</param>
</method>
The configuration above corresponds to a method named Initialize that takes two parameters, as shown here.
public void Initialize(string connectionString, IMyService dataService)
{
...
}
Public Sub Initialize(connectionString As String, dataService As IMyService)
...
End Sub
The configuration settings specify that the value of the connectionString parameter will be "AdventureWorks", and that the value of the dataService parameter will be the result of any mapping for the IMyService interface stored in the container (effectively a call to the Resolve method for the class IMyService).
Attributes and Child Elements
The following table lists the attributes for the method element.
| Attribute | Description |
| name | The name of the method to apply dependency injection to. This attribute is required. |
The method element has one or more child elements named param. For details, see param Element.