object element¶
Element object is used to specify a value by using value attribute, that is de-serialize by a serializer specified in iocConfiguration/parameterSerializers/serializers/parameterSerializer elements.
Note
Refer to Parameter Serializers for more details on parameter serializers.
Note
- IoC.Configuration provides default parameter serializers for some types. The types for which parameter serializers are provided out of the box are:
- System.Byte, System.Int16, System.Int32, System.Int64, System.Double, System.Boolean, System.DateTime, System.String, and System.Guid.
Example 1: Using object element in settings element¶
1 2 3 4 5 6 | <settings>
<object name="Project1Guid" typeRef="Guid"
value="EA91B230-3FF8-43FA-978B-3261493D58A3" />
<object name="Project2Guid" typeRef="Guid"
value="9EDC7F1A-6BD6-4277-9015-5A9277218681" />
</settings>
|
Example 2: Using object element to specify a returned value in autoProperty and autoMethod elements¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <autoGeneratedServices>
<autoService interfaceRef="IProjectGuids" >
<autoProperty name="Project1" returnTypeRef="Guid">
<object typeRef="Guid"
value="966FE6A6-76AC-4895-84B2-47E27E58FD02"/>
</autoProperty>
<autoMethod name="GetDefaultProject"
returnTypeRef="Guid">
<default>
<object typeRef="Guid"
value="1E08071B-D02C-4830-AE3C-C9E78A29EA37"/>
</default>
</autoMethod>
</autoService>
<autoGeneratedServices>
|
Example 3: Using object element to specify constructor and injected property values for service implementation¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <service type="TestPluginAssembly1.Interfaces.IRoom">
<implementation type="TestPluginAssembly1.Implementations.Room" scope="transient">
<parameters>
<object name="door1" type="TestPluginAssembly1.Interfaces.IDoor"
value="5,185.1" />
<injectedObject name="door2"
type="TestPluginAssembly1.Interfaces.IDoor" />
</parameters>
<injectedProperties>
<object name="Door2"
type="TestPluginAssembly1.Interfaces.IDoor"
value="7,187.3" />
</injectedProperties>
</implementation>
</service>
|