IoCConfiguration_GenericTypesAndTypeReUse.xml
This configuration file can be downloaded downloaded from IoCConfiguration_GenericTypesAndTypeReUse.xml.
1<?xml version="1.0" encoding="utf-8"?>
2
3<!--This configuration demonstrates usage of types. Types can be specified in various elements either by using 'type' attribute, and an
4 optional 'assembly' attribute, or by using typeRef (or some other variations, such as interfaceRef), to reference a type defined in section
5 'typeDefinitions'.
6 In other words, every typeRef attribute can be replaced with 'type' (along with optional 'assembly' attribute)-->
7<!--
8 The XML configuration file is validated against schema file IoC.Configuration.Schema.22B4BA50-3429-48FE-8059-B9C1F855A639.xsd,
9 which can be found in folder IoC.Configuration.Content in output directory.
10 The schema file can also be downloaded from
11 http://oroptimizer.com/ioc.configuration/V2/IoC.Configuration.Schema.22B4BA50-3429-48FE-8059-B9C1F855A639.xsd or in source code
12 project in Github.com.
13
14 To use Visual Studio code completion based on schema contents, right click Properties on this file in Visual Studio, and in Schemas
15 field pick the schema IoC.Configuration.Schema.22B4BA50-3429-48FE-8059-B9C1F855A639.xsd.
16
17 Before running the tests make sure to execute IoC.Configuration\Tests\IoC.Configuration.Tests\PostBuildCommands.bat to copy the dlls into
18 folders specified in this configuration file.
19 Also, modify the batch file to copy the Autofac and Ninject assemblies from Nuget packages folder on machine, where the test is run.
20-->
21
22<iocConfiguration
23 xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
24 xsi:noNamespaceSchemaLocation="http://oroptimizer.com/IoC.Configuration/V2/IoC.Configuration.Schema.22B4BA50-3429-48FE-8059-B9C1F855A639.xsd">
25
26 <!--The application should have write permissions to path specified in appDataDir.
27 This is where dynamically generated DLLs are saved.-->
28 <!--NOTE: path should be an absolute path, or should be converted to absolute path by some implementation of
29 IoC.Configuration.AttributeValueTransformer.IAttributeValueTransformer. In this example the paths are converted by
30 IoC.Configuration.Tests.FileFolderPathAttributeValueTransformer.-->
31 <appDataDir
32 path="TestFiles\AutogeneratedDlls\DynamicFiles_TypeTests" />
33
34 <plugins pluginsDirPath="TestFiles\PluginDlls">
35
36 <!--
37 Plugin assemblies will be in a folder with similar name under pluginsDirPath folder.
38 The plugin folders will be included in assembly resolution mechanism.
39 -->
40
41 <!--A folder K:\...\IoC.Configuration\Tests\IoC.Configuration.Tests\bin\TestFiles\PluginDlls\Plugin1 should exist. -->
42 <plugin name="Plugin1" />
43 <plugin name="Plugin2" />
44 </plugins>
45
46 <additionalAssemblyProbingPaths>
47 <probingPath
48 path="TestFiles\ThirdPartyLibs" />
49 <probingPath
50 path="TestFiles\ContainerImplementations\Autofac" />
51 <probingPath
52 path="TestFiles\ContainerImplementations\Ninject" />
53 <probingPath
54 path="TestFiles\DynamicallyLoadedDlls" />
55 </additionalAssemblyProbingPaths>
56
57 <assemblies>
58 <!--Assemblies should be in one of the following locations:
59 1) Executable's folder
60 2) In folder specified in additionalAssemblyProbingPaths element.
61 3) In one of the plugin folders specified in plugins element (only for assemblies with plugin attribute) -->
62
63 <!--
64 Use "overrideDirectory" attribute, to make the assembly path explicit, rather then searching for
65 an assembly in predefined folders, which also include probing paths specified in additionalAssemblyProbingPaths element.
66 -->
67 <assembly name="OROptimizer.Shared" alias="oroptimizer_shared" />
68 <assembly name="IoC.Configuration" alias="ioc_config" />
69 <assembly name="IoC.Configuration.Autofac" alias="autofac_ext" />
70 <assembly name="IoC.Configuration.Ninject" alias="ninject_ext" />
71
72 <assembly name="TestProjects.Modules" alias="modules" />
73
74 <assembly name="TestProjects.DynamicallyLoadedAssembly1"
75 alias="dynamic1" />
76
77 <assembly name="TestProjects.DynamicallyLoadedAssembly2"
78 alias="dynamic2" />
79
80 <assembly name="TestProjects.TestPluginAssembly1"
81 alias="pluginassm1" plugin="Plugin1" />
82
83 <assembly name="TestProjects.TestPluginAssembly2"
84 alias="pluginassm2" plugin="Plugin2" />
85
86 <assembly name="TestProjects.ModulesForPlugin1"
87 alias="modules_plugin1" plugin="Plugin1" />
88
89 <assembly name="TestProjects.SharedServices" alias="shared_services" />
90
91 <assembly name="IoC.Configuration.Tests" alias="tests" />
92
93 <assembly name="System.Private.CoreLib" alias="corlib"/>
94
95 <assembly name="System.Threading.Tasks.Extensions" alias="threading_tasks_extensions" />
96 </assemblies>
97
98 <typeDefinitions>
99 <typeDefinition alias="ReadOnlyListOf_IInterface1" type="System.Collections.Generic.IReadOnlyList">
100 <genericTypeParameters>
101 <typeDefinition type="SharedServices.Interfaces.IInterface1" assembly="shared_services" />
102 </genericTypeParameters>
103 </typeDefinition>
104
105 <typeDefinition alias="IEnumerableOf_IInterface1"
106 type="System.Collections.Generic.IEnumerable[SharedServices.Interfaces.IInterface1]" />
107
108 <typeDefinition alias="IGeneric1_1_of_Interface1_Impl1"
109 type="SharedServices.Interfaces.Generic.IGeneric1_1[SharedServices.Implementations.Interface1_Impl1]">
110 </typeDefinition>
111
112 <!--The type definition below is similar to C# type SharedServices.Interfaces.IInterface1[]-->
113 <typeDefinition alias="arrayOfInterface1" type="SharedServices.Interfaces.IInterface1#" />
114
115 <!--The type definition below is similar to C# type System.Collections.Generic.IEnumerable<SharedServices.Interfaces.IInterface1[]>-->
116 <typeDefinition alias="enumerableOfArray" type="System.Collections.Generic.IEnumerable[SharedServices.Interfaces.IInterface1#]" />
117
118 <!--The type definition below is similar to C# type System.Collections.Generic.IList<SharedServices.Interfaces.IInterface1[]>-->
119 <typeDefinition alias="listOfArray" type="System.Collections.Generic.IList" >
120 <genericTypeParameters>
121 <typeDefinition type="SharedServices.Interfaces.IInterface1#" />
122 </genericTypeParameters>
123 </typeDefinition>
124
125 <!--The type definition below is similar to C# type
126 SharedServices.Interfaces.Generic.IGeneric4_2<SharedServices.Interfaces.IInterface1[], SharedServices.Interfaces.IInterface2[]>[]-->
127 <typeDefinition alias="arraysOfGenericTypes" type="SharedServices.Interfaces.Generic.IGeneric4_2[SharedServices.Interfaces.IInterface1#, SharedServices.Interfaces.IInterface2#]#" />
128
129 <typeDefinition alias="Generic1_1_of_Interface1_Impl1" type="SharedServices.Implementations.Generic.Generic1_1[SharedServices.Implementations.Interface1_Impl1]">
130 </typeDefinition>
131
132 <typeDefinition alias="Generic4_2_a" type="SharedServices.Implementations.Generic.Generic4_2" >
133 <genericTypeParameters>
134 <typeDefinition type="System.Int32" />
135 <typeDefinition type="System.String" />
136 </genericTypeParameters>
137 </typeDefinition>
138
139 <typeDefinition alias="Generic4_2_b" type="SharedServices.Implementations.Generic.Generic4_2" >
140 <genericTypeParameters>
141 <typeDefinition type="SharedServices.Implementations.Generic.Generic2_1[SharedServices.Implementations.Interface1_Impl1]" />
142 <typeDefinition type="SharedServices.Implementations.Generic.Generic2_1">
143 <genericTypeParameters>
144 <typeDefinition type="System.Int64" />
145 </genericTypeParameters>
146 </typeDefinition>
147 </genericTypeParameters>
148 </typeDefinition>
149
150 <typeDefinition alias="Generic4_2_c" type="SharedServices.Implementations.Generic.Generic4_2" >
151 <genericTypeParameters>
152 <typeDefinition type="SharedServices.Interfaces.Generic.IGeneric2_1">
153 <genericTypeParameters>
154 <typeDefinition type="System.String" />
155 </genericTypeParameters>
156 </typeDefinition>
157 <typeDefinition type="SharedServices.Interfaces.Generic.IGeneric2_1[SharedServices.Implementations.Interface1_Impl2]" />
158 </genericTypeParameters>
159 </typeDefinition>
160
161 <typeDefinition alias="Generic4_2_d" type="SharedServices.Implementations.Generic.Generic4_2" >
162 <genericTypeParameters>
163 <typeDefinition type="SharedServices.Interfaces.Generic.IGeneric2_1">
164 <genericTypeParameters>
165 <typeDefinition type="System.String" />
166 </genericTypeParameters>
167 </typeDefinition>
168
169 <typeDefinition type="SharedServices.Interfaces.Generic.IGeneric2_1">
170 <genericTypeParameters>
171 <typeDefinition type="System.Double" />
172 </genericTypeParameters>
173 </typeDefinition>
174 </genericTypeParameters>
175 </typeDefinition>
176
177 <typeDefinition alias="Interface1" type="SharedServices.Interfaces.IInterface1"></typeDefinition>
178 <typeDefinition alias="Interface1_Impl1" type="SharedServices.Implementations.Interface1_Impl1"></typeDefinition>
179 <typeDefinition alias="module2" type="Modules.IoC.DiModule2" />
180 <typeDefinition alias="SerializerAggregator" type="OROptimizer.Serializer.TypeBasedSimpleSerializerAggregator" />
181 <typeDefinition alias="TestTypeRefTestClass3Serializer" type="IoC.Configuration.Tests.GenericTypesAndTypeReUse.GenericTypesAndTypeReUseTests.TestTypeRefTestClass3Serializer" />
182 <typeDefinition alias="TestTypeRefTestClass1" type="IoC.Configuration.Tests.GenericTypesAndTypeReUse.GenericTypesAndTypeReUseTests.TestTypeRefTestClass1" />
183 <typeDefinition alias="TestTypeRefTestClass2" type="IoC.Configuration.Tests.GenericTypesAndTypeReUse.GenericTypesAndTypeReUseTests.TestTypeRefTestClass2" />
184 <typeDefinition alias="TestTypeRefTestClass3" type="IoC.Configuration.Tests.GenericTypesAndTypeReUse.GenericTypesAndTypeReUseTests.TestTypeRefTestClass3" />
185 <!--Plugin types can be used in non plugin definitions. However, usage of this types in other non-plugin sections should confirm'
186 to certain restictions.-->
187 <typeDefinition alias="pluginTypeDef" type="TestPluginAssembly1.Implementations.Window" assembly="pluginassm1"></typeDefinition>
188
189 </typeDefinitions>
190
191 <parameterSerializers serializerAggregatorTypeRef="SerializerAggregator">
192 <!--
193 Use parameters element to specify constructor parameters, if the type specified in 'serializerAggregatorType' attribute
194 has non-default constructor.
195 -->
196 <!--<parameters>
197 </parameters>-->
198 <serializers>
199 <parameterSerializer typeRef="TestTypeRefTestClass3Serializer" />
200 </serializers>
201 </parameterSerializers>
202
203 <!--The value of type attribute should be a type that implements
204 IoC.Configuration.DiContainer.IDiManager-->
205 <diManagers activeDiManagerName="Autofac">
206 <diManager name="Ninject" type="IoC.Configuration.Ninject.NinjectDiManager"
207 assembly="ninject_ext">
208 <!--
209 Use parameters element to specify constructor parameters,
210 if the type specified in 'type' attribute has non-default constructor.
211 -->
212 <!--<parameters>
213 </parameters>-->
214 </diManager>
215
216 <diManager name="Autofac" type="IoC.Configuration.Autofac.AutofacDiManager"
217 assembly="autofac_ext">
218 </diManager>
219 </diManagers>
220
221 <!--
222 If settingsRequestor element is used, the type in type attribute should
223 specify a type that implements IoC.Configuration.ISettingsRequestor.
224 The implementation specifies a collection of required settings that should be present
225 in settings element.
226 Note, the type specified in type attribute is fully integrated into a dependency
227 injection framework. In other words, constructor parameters will be injected using
228 bindings specified in dependencyInjection element.
229 -->
230 <settingsRequestor type="IoC.Configuration.Tests.GenericTypesAndTypeReUse.SettingsRequestor"
231 assembly="tests">
232 <!-- TODO:-->
233 </settingsRequestor>
234
235 <settings>
236
237 <constructedValue name="GenericSetting1" typeRef="Generic1_1_of_Interface1_Impl1" >
238 <parameters>
239 <constructedValue name="param1" typeRef="Interface1_Impl1">
240 </constructedValue>
241 </parameters>
242 </constructedValue>
243 </settings>
244
245 <dependencyInjection>
246 <modules>
247 <module typeRef="module2">
248 <parameters>
249 <constructedValue name="param1" typeRef="Interface1_Impl1" />
250 </parameters>
251 </module>
252 </modules>
253 <services>
254
255 <selfBoundService typeRef="Interface1_Impl1" scope="singleton" />
256 <service typeRef="Interface1">
257 <implementation typeRef="Interface1_Impl1" scope="singleton"></implementation>
258 </service>
259
260 <service typeRef="IGeneric1_1_of_Interface1_Impl1">
261 <valueImplementation scope="singleton">
262 <settingValue settingName="GenericSetting1"/>
263 </valueImplementation>
264 <implementation typeRef="Generic1_1_of_Interface1_Impl1" scope="singleton"></implementation>
265 <implementation type="SharedServices.Implementations.Generic.Generic1_1[SharedServices.Implementations.Interface1_Impl1]" scope="singleton" />
266 </service>
267
268 <service type="SharedServices.Interfaces.Generic.IGeneric2_1[SharedServices.Implementations.Generic.Generic3_1[System.Int32]]" >
269 <implementation type="SharedServices.Implementations.Generic.Generic2_1[SharedServices.Implementations.Generic.Generic3_1[System.Int32]]"
270 scope="singleton">
271 <parameters>
272 <constructedValue name="param1" type="SharedServices.Implementations.Generic.Generic3_1[System.Int32]">
273 <parameters>
274 <int32 name="param1" value="17"/>
275 </parameters>
276 </constructedValue>
277 </parameters>
278 </implementation>
279 </service>
280
281 <selfBoundService typeRef="Generic4_2_b" scope="singleton">
282 <parameters>
283 <constructedValue name="param1" type="SharedServices.Implementations.Generic.Generic2_1[SharedServices.Implementations.Interface1_Impl1]">
284 <parameters>
285 <injectedObject name="param1" type="SharedServices.Implementations.Interface1_Impl1" />
286 </parameters>
287 </constructedValue>
288 </parameters>
289 <injectedProperties>
290 <constructedValue name="Value2" type="SharedServices.Implementations.Generic.Generic2_1[System.Int64]">
291 <parameters>
292 <int64 name="param1" value="19"/>
293 </parameters>
294 </constructedValue>
295 </injectedProperties>
296 </selfBoundService>
297
298 <selfBoundService typeRef="TestTypeRefTestClass2" scope="singleton">
299 </selfBoundService>
300
301 <selfBoundService typeRef="TestTypeRefTestClass1" scope="singleton">
302 <parameters>
303 <injectedObject name="param1" typeRef="TestTypeRefTestClass2" />
304 <object name="param2" typeRef="TestTypeRefTestClass3" value="5"/>
305 </parameters>
306 <injectedProperties>
307 <injectedObject name="Property3" typeRef="TestTypeRefTestClass2" />
308 <object name="Property4" typeRef="TestTypeRefTestClass3" value="7"/>
309 </injectedProperties>
310 </selfBoundService>
311 </services>
312 <autoGeneratedServices>
313
314 </autoGeneratedServices>
315 </dependencyInjection>
316
317 <startupActions>
318 <startupAction type="IoC.Configuration.Tests.GenericTypesAndTypeReUse.StartupAction1"
319 assembly="tests">
320 <!-- TODO:-->
321 <!--Use parameters element to specify constructor parameters if necessary.-->
322 <!--<parameters></parameters>-->
323 <!--Use injectedProperties element to inject properties into startup action if necessary.-->
324 <!--<injectedProperties></injectedProperties>-->
325 </startupAction>
326
327 </startupActions>
328
329 <pluginsSetup>
330 <pluginSetup plugin="Plugin1">
331 <!--The type in pluginImplementation should be non-abstract class
332 that implements IoC.Configuration.IPlugin and which has a public constructor-->
333 <pluginImplementation type="TestPluginAssembly1.Implementations.Plugin1_Simple">
334 </pluginImplementation>
335
336 <typeDefinitions>
337 <!--Generic1_1_of_Interface1_Impl1 type definition overrides the definition in non-plugins section.-->
338 <typeDefinition alias="Generic1_1_of_Interface1_Impl1" type="SharedServices.Implementations.Generic.Generic1_1[TestPluginAssembly1.Implementations.Interface1_Impl1]">
339 </typeDefinition>
340
341 <typeDefinition alias="ReadOnlyListOfGenericType" type="System.Collections.Generic.IReadOnlyList" assembly="corlib">
342 <genericTypeParameters>
343 <typeDefinition type="SharedServices.Implementations.Generic.Generic3_1" >
344 <genericTypeParameters>
345 <typeDefinition type="SharedServices.Implementations.Interface1_Impl1" />
346 </genericTypeParameters>
347 </typeDefinition>
348 </genericTypeParameters>
349 </typeDefinition>
350
351 <typeDefinition alias="IDoor" type="TestPluginAssembly1.Interfaces.IDoor"></typeDefinition>
352 <typeDefinition alias="Door" type="TestPluginAssembly1.Implementations.Door"></typeDefinition>
353 <typeDefinition alias="plugin1Module" type="ModulesForPlugin1.IoC.DiModule2"></typeDefinition>
354
355 </typeDefinitions>
356
357 <settings>
358 <constructedValue name="PluginGenericSetting1" typeRef="Generic1_1_of_Interface1_Impl1" >
359 <parameters>
360 <constructedValue name="param1" type="TestPluginAssembly1.Implementations.Interface1_Impl1">
361 </constructedValue>
362 </parameters>
363 </constructedValue>
364 </settings>
365
366 <dependencyInjection>
367 <modules>
368 <module typeRef="plugin1Module">
369 <parameters>
370 <constructedValue name="param1" typeRef="Door">
371 <parameters>
372 <int32 name="color" value="255"/>
373 <int32 name="height" value="200"/>
374 </parameters>
375 </constructedValue>
376 </parameters>
377 </module>
378 </modules>
379 <services>
380 <selfBoundService typeRef="Door" scope="singleton">
381 <parameters>
382 <int32 name="color" value="258"/>
383 <int32 name="height" value="100" />
384 </parameters>
385 </selfBoundService>
386 <service typeRef="IDoor">
387 <implementation typeRef="Door" scope="singleton">
388 <parameters>
389 <int32 name="color" value="255"/>
390 <int32 name="height" value="25"/>
391 </parameters>
392 </implementation>
393 </service>
394 </services>
395 <autoGeneratedServices>
396
397 </autoGeneratedServices>
398 </dependencyInjection>
399 </pluginSetup>
400
401 <pluginSetup plugin="Plugin2">
402 <pluginImplementation type="TestPluginAssembly2.Implementations.Plugin2_TypeTests" assembly="pluginassm2">
403 <!--<parameters>
404
405 </parameters>-->
406 </pluginImplementation>
407 <settings>
408 </settings>
409 <dependencyInjection>
410 <modules>
411 </modules>
412 <services>
413
414 </services>
415 <autoGeneratedServices>
416 </autoGeneratedServices>
417 </dependencyInjection>
418 </pluginSetup>
419 </pluginsSetup>
420</iocConfiguration>