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<settings>
2 <object name="Project1Guid" typeRef="Guid"
3 value="EA91B230-3FF8-43FA-978B-3261493D58A3" />
4 <object name="Project2Guid" typeRef="Guid"
5 value="9EDC7F1A-6BD6-4277-9015-5A9277218681" />
6</settings>
Example 2: Using object element to specify a returned value in autoProperty and autoMethod elements
1<autoGeneratedServices>
2 <autoService interfaceRef="IProjectGuids" >
3 <autoProperty name="Project1" returnTypeRef="Guid">
4 <object typeRef="Guid"
5 value="966FE6A6-76AC-4895-84B2-47E27E58FD02"/>
6 </autoProperty>
7
8 <autoMethod name="GetDefaultProject"
9 returnTypeRef="Guid">
10 <default>
11 <object typeRef="Guid"
12 value="1E08071B-D02C-4830-AE3C-C9E78A29EA37"/>
13 </default>
14 </autoMethod>
15 </autoService>
16<autoGeneratedServices>
Example 3: Using object element to specify constructor and injected property values for service implementation
1<service type="TestPluginAssembly1.Interfaces.IRoom">
2 <implementation type="TestPluginAssembly1.Implementations.Room" scope="transient">
3 <parameters>
4 <object name="door1" type="TestPluginAssembly1.Interfaces.IDoor"
5 value="5,185.1" />
6 <injectedObject name="door2"
7 type="TestPluginAssembly1.Interfaces.IDoor" />
8 </parameters>
9 <injectedProperties>
10 <object name="Door2"
11 type="TestPluginAssembly1.Interfaces.IDoor"
12 value="7,187.3" />
13 </injectedProperties>
14 </implementation>
15</service>