IoCConfiguration_valueImplementation.xml
This configuration file can be downloaded downloaded from IoCConfiguration_valueImplementation.xml.
1<?xml version="1.0" encoding="utf-8"?>
2
3<!--
4 The XML configuration file is validated against schema file IoC.Configuration.Schema.22B4BA50-3429-48FE-8059-B9C1F855A639.xsd,
5 which can be found in folder IoC.Configuration.Content in output directory.
6 The schema file can also be downloaded from
7 http://oroptimizer.com/ioc.configuration/V2/IoC.Configuration.Schema.22B4BA50-3429-48FE-8059-B9C1F855A639.xsd or in source code
8 project in Github.com.
9
10 To use Visual Studio code completion based on schema contents, right click Properties on this file in Visual Studio, and in Schemas
11 field pick the schema IoC.Configuration.Schema.22B4BA50-3429-48FE-8059-B9C1F855A639.xsd.
12
13 Before running the tests make sure to execute IoC.Configuration\Tests\IoC.Configuration.Tests\PostBuildCommands.bat to copy the dlls into
14 folders specified in this configuration file.
15 Also, modify the batch file to copy the Autofac and Ninject assemblies from Nuget packages folder on machine, where the test is run.
16-->
17<iocConfiguration
18 xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
19 xsi:noNamespaceSchemaLocation="http://oroptimizer.com/IoC.Configuration/V2/IoC.Configuration.Schema.22B4BA50-3429-48FE-8059-B9C1F855A639.xsd">
20
21 <!--The application should have write permissions to path specified in appDataDir.
22 This is where dynamically generated DLLs are saved.-->
23 <!--NOTE: path should be an absolute path, or should be converted to absolute path by some implementation of
24 IoC.Configuration.AttributeValueTransformer.IAttributeValueTransformer. In this example the paths are converted by
25 IoC.Configuration.Tests.FileFolderPathAttributeValueTransformer.-->
26 <appDataDir
27 path="TestFiles\AutogeneratedDlls\DynamicFiles_ValueImplementationTests" />
28
29 <plugins pluginsDirPath="TestFiles\PluginDlls">
30
31 <!--
32 Plugin assemblies will be in a folder with similar name under pluginsDirPath folder.
33 The plugin folders will be included in assembly resolution mechanism.
34 -->
35
36 <!--A folder K:\...\IoC.Configuration\Tests\IoC.Configuration.Tests\bin\TestFiles\PluginDlls\Plugin1 should exist. -->
37 <plugin name="Plugin1" />
38 <plugin name="Plugin2" enabled="true" />
39 <plugin name="Plugin3" enabled="false" />
40 </plugins>
41
42 <additionalAssemblyProbingPaths>
43 <probingPath
44 path="TestFiles\ThirdPartyLibs" />
45 <probingPath
46 path="TestFiles\ContainerImplementations\Autofac" />
47 <probingPath
48 path="TestFiles\ContainerImplementations\Ninject" />
49 <probingPath
50 path="TestFiles\DynamicallyLoadedDlls" />
51 </additionalAssemblyProbingPaths>
52
53 <assemblies>
54 <!--Assemblies should be in one of the following locations:
55 1) Executable's folder
56 2) In folder specified in additionalAssemblyProbingPaths element.
57 3) In one of the plugin folders specified in plugins element (only for assemblies with plugin attribute) -->
58
59 <!--
60 Use "overrideDirectory" attribute, to make the assembly path explicit, rather then searching for
61 an assembly in predefined folders, which also include probing paths specified in additionalAssemblyProbingPaths element.
62 -->
63 <assembly name="IoC.Configuration.Autofac" alias="autofac_ext" />
64 <assembly name="IoC.Configuration.Ninject" alias="ninject_ext" />
65
66 <assembly name="TestProjects.Modules" alias="modules" />
67
68 <assembly name="TestProjects.DynamicallyLoadedAssembly1"
69 alias="dynamic1" />
70
71 <assembly name="TestProjects.DynamicallyLoadedAssembly2"
72 alias="dynamic2" />
73
74 <assembly name="TestProjects.TestPluginAssembly1"
75 alias="pluginassm1" plugin="Plugin1" />
76
77 <assembly name="TestProjects.TestPluginAssembly2"
78 alias="pluginassm2" plugin="Plugin2" />
79
80 <assembly name="TestProjects.TestPluginAssembly3"
81 alias="pluginassm3" plugin="Plugin3" />
82
83 <assembly name="TestProjects.ModulesForPlugin1"
84 alias="modules_plugin1" plugin="Plugin1" />
85
86 <assembly name="TestProjects.SharedServices" alias="shared_services" />
87
88 <assembly name="IoC.Configuration.Tests" alias="tests" />
89 </assemblies>
90
91 <typeDefinitions>
92 <typeDefinition alias="IAppInfo" type="IoC.Configuration.Tests.ValueImplementation.Services.IAppInfo" />
93 <typeDefinition alias="AppInfo" type="IoC.Configuration.Tests.ValueImplementation.Services.AppInfo" />
94 </typeDefinitions>
95
96 <parameterSerializers>
97 <serializers>
98 <parameterSerializer type="TestPluginAssembly1.Implementations.DoorSerializer" />
99 </serializers>
100 </parameterSerializers>
101
102 <!--The value of type attribute should be a type that implements
103 IoC.Configuration.DiContainer.IDiManager-->
104 <diManagers activeDiManagerName="Autofac">
105 <diManager name="Ninject" type="IoC.Configuration.Ninject.NinjectDiManager"
106 assembly="ninject_ext">
107 <!--
108 Use parameters element to specify constructor parameters,
109 if the type specified in 'type' attribute has non-default constructor.
110 -->
111 <!--<parameters>
112 </parameters>-->
113 </diManager>
114
115 <diManager name="Autofac" type="IoC.Configuration.Autofac.AutofacDiManager"
116 assembly="autofac_ext">
117 </diManager>
118 </diManagers>
119
120 <!--
121 If settingsRequestor element is used, the type in type attribute should
122 specify a type that implements IoC.Configuration.ISettingsRequestor.
123 The implementation specifies a collection of required settings that should be present
124 in settings element.
125 Note, the type specified in type attribute is fully integrated into a dependency
126 injection framework. In other words, constructor parameters will be injected using
127 bindings specified in dependencyInjection element.
128 -->
129
130 <settings>
131 <int32 name="defaultAppId" value="38" />
132 <string name="defaultAppDescription" value="Deafult App"/>
133 <!--<constructedValue name="defaultAppInfo" typeRef="AppInfo">
134 <parameters>
135 <int32 name="appId" value="37"/>
136 </parameters>
137 </constructedValue>-->
138
139 </settings>
140
141 <dependencyInjection>
142 <modules>
143 <!--<module type="IoC.Configuration.Tests.AutoService.AutoServiceTestsModule" />-->
144 <module type="IoC.Configuration.Tests.ValueImplementation.Module1" />
145 </modules>
146 <services>
147 <!--int value is bound to the value of setting defaultAppId.-->
148 <service type="System.Int32">
149 <valueImplementation scope="singleton">
150 <settingValue settingName="defaultAppId"/>
151 </valueImplementation>
152 </service>
153
154
155 <!--Service IAppInfo is bound to AppInfo constructed using constructedValue element.-->
156 <service typeRef="IAppInfo">
157 <valueImplementation scope="transient">
158 <constructedValue typeRef="AppInfo">
159 <parameters>
160 <settingValue name="appId" settingName="defaultAppId" />
161 </parameters>
162 </constructedValue>
163 </valueImplementation>
164 </service>
165
166 <!--System.Double value is bound to 3.5.-->
167 <service type="System.Double">
168 <valueImplementation scope="singleton">
169 <!--object elements value is initialized by a serializer of type OROptimizer.Serializer.ITypeBasedSimpleSerializer
170 that can be registered in section parameterSerializers.
171 IoC.Configuration provides number of default serializers for some types.
172 The out of the box serializer for System.Double is OROptimizer.Serializer.TypeBasedSimpleSerializerDouble which is available
173 in Nuget package OROptimizer.Shared.
174 -->
175 <object type="System.Double" value="3.5"/>
176 </valueImplementation>
177 </service>
178
179 <!--Examples of using classMember element in valueImplementation-->
180 <service type="IoC.Configuration.Tests.ValueImplementation.Services.IDbConnectionProvider">
181 <implementation type="IoC.Configuration.Tests.ValueImplementation.Services.DbConnectionProvider" scope="singleton">
182 <parameters>
183 <string name="serverName" value="SqlServer1"/>
184 <string name="databaseName" value="Db1"/>
185 <string name="userName" value="restrictedUser"/>
186 <string name="password" value="safePassword123"/>
187 </parameters>
188 </implementation>
189 </service>
190
191 <!--Type SharedServices.Interfaces.IDbConnection will be bound to a vlue returned by call to
192 IoC.Configuration.Tests.ValueImplementation.Services.IDbConnectionProvider.GetDbConnection().
193 Since IDbConnectionProvider.GetDbConnection() is non-static, an instance of IDbConnectionProvider will be resolved
194 from DI container, and method GetDbConnection() will be called using the resolved instance
195 -->
196 <service type="SharedServices.Interfaces.IDbConnection">
197 <valueImplementation scope="transient">
198 <classMember class="IoC.Configuration.Tests.ValueImplementation.Services.IDbConnectionProvider" memberName="GetDbConnection"/>
199 </valueImplementation>
200 </service>
201
202 <service type="SharedServices.Interfaces.IActionValidator">
203 <valueImplementation scope="transient">
204 <classMember class="IoC.Configuration.Tests.ValueImplementation.Services.StaticMethods" memberName="GetActionValidator"/>
205 </valueImplementation>
206 </service>
207
208 <!--Service IReadOnlyList<IoC.Configuration.Tests.ValueImplementation.Services.IAppInfo> is bound to a collection
209 specified in valueImplementation element.-->
210 <service type="System.Collections.Generic.IReadOnlyList[IoC.Configuration.Tests.ValueImplementation.Services.IAppInfo]">
211 <valueImplementation scope="singleton" >
212 <collection>
213 <constructedValue typeRef="AppInfo">
214 <parameters>
215 <int32 name="paramId" value="1"/>
216 </parameters>
217 </constructedValue>
218
219 <constructedValue typeRef="AppInfo">
220 <parameters>
221 <int32 name="paramId" value="2"/>
222 </parameters>
223 </constructedValue>
224 </collection>
225 </valueImplementation>
226 </service>
227
228 <!--
229 The service below will be ignored, since registerIfNotRegistered is true, and we already registered a binding for
230 System.Collections.Generic.List<IoC.Configuration.Tests.ValueImplementation.Services.IAppInfo> in
231 IoC.Configuration.Tests.ValueImplementation.Module1.
232 -->
233 <service type="System.Collections.Generic.List[IoC.Configuration.Tests.ValueImplementation.Services.IAppInfo]"
234 registerIfNotRegistered="true">
235 <valueImplementation scope="singleton" >
236 <collection>
237 <constructedValue typeRef="AppInfo">
238 <parameters>
239 <int32 name="paramId" value="15"/>
240 </parameters>
241 </constructedValue>
242 </collection>
243 </valueImplementation>
244 </service>
245 </services>
246
247 <autoGeneratedServices>
248 <!--The scope for autoService implementations is always singleton -->
249
250 </autoGeneratedServices>
251 </dependencyInjection>
252
253 <startupActions>
254
255 </startupActions>
256
257 <pluginsSetup>
258 <pluginSetup plugin="Plugin1">
259 <!--The type in pluginImplementation should be non-abstract class
260 that implements IoC.Configuration.IPlugin and which has a public constructor-->
261 <pluginImplementation type="TestPluginAssembly1.Implementations.Plugin1_Simple">
262 </pluginImplementation>
263
264 <settings>
265 <int32 name="Int32Setting1" value="10"/>
266 <string name="StringSetting1" value="Some text"/>
267 </settings>
268
269 <dependencyInjection>
270 <modules>
271 </modules>
272
273 <services>
274 <service type="System.Collections.Generic.IReadOnlyList[TestPluginAssembly1.Interfaces.IDoor]">
275 <valueImplementation scope="singleton">
276 <collection>
277 <object type="TestPluginAssembly1.Interfaces.IDoor" value="4359924, 80.3"/>
278 <constructedValue type="TestPluginAssembly1.Implementations.Door">
279 <parameters>
280 <int32 name="color" value="4359934"/>
281 <double name="height" value="85.2" />
282 </parameters>
283 </constructedValue>
284 </collection>
285 </valueImplementation>
286 </service>
287 </services>
288
289 <autoGeneratedServices>
290
291 </autoGeneratedServices>
292 </dependencyInjection>
293 </pluginSetup>
294
295 <pluginSetup plugin="Plugin2">
296 <pluginImplementation type="TestPluginAssembly2.Implementations.Plugin2" assembly="pluginassm2">
297 <parameters>
298 <boolean name="param1" value="true" />
299 <double name="param2" value="25.3" />
300 <string name="param3" value="String value" />
301 </parameters>
302 </pluginImplementation>
303 <settings>
304 </settings>
305 <dependencyInjection>
306 <modules>
307 </modules>
308 <services>
309 </services>
310 <autoGeneratedServices>
311 </autoGeneratedServices>
312 </dependencyInjection>
313 </pluginSetup>
314
315 <pluginSetup plugin="Plugin3">
316 <pluginImplementation type="TestPluginAssembly3.Implementations.Plugin3" assembly="pluginassm3">
317
318 </pluginImplementation>
319 <settings>
320 </settings>
321 <dependencyInjection>
322 <modules>
323 </modules>
324 <services>
325 </services>
326 <autoGeneratedServices>
327 </autoGeneratedServices>
328 </dependencyInjection>
329 </pluginSetup>
330 </pluginsSetup>
331</iocConfiguration>