IoCConfiguration_classMember.xml
This configuration file can be downloaded downloaded from IoCConfiguration_classMember.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
18<iocConfiguration
19 xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
20 xsi:noNamespaceSchemaLocation="http://oroptimizer.com/IoC.Configuration/V2/IoC.Configuration.Schema.22B4BA50-3429-48FE-8059-B9C1F855A639.xsd">
21
22 <!--The application should have write permissions to path specified in appDataDir.
23 This is where dynamically generated DLLs are saved.-->
24 <!--NOTE: path should be an absolute path, or should be converted to absolute path by some implementation of
25 IoC.Configuration.AttributeValueTransformer.IAttributeValueTransformer. In this example the paths are converted by
26 IoC.Configuration.Tests.FileFolderPathAttributeValueTransformer.-->
27 <appDataDir
28 path="TestFiles\AutogeneratedDlls\DynamicFiles_ClassMemberTests"/>
29
30 <plugins
31 pluginsDirPath="TestFiles\PluginDlls">
32
33 <!--
34 Plugin assemblies will be in a folder with similar name under pluginsDirPath folder.
35 The plugin folders will be included in assembly resolution mechanism.
36 -->
37
38 <!--A folder K:\...\IoC.Configuration\Tests\IoC.Configuration.Tests\bin\TestFiles\PluginDlls\Plugin1 should exist. -->
39 <plugin name="Plugin1"/>
40 <plugin name="Plugin2" enabled="true"/>
41 <plugin name="Plugin3" enabled="false"/>
42 </plugins>
43
44 <additionalAssemblyProbingPaths>
45 <probingPath
46 path="TestFiles\ThirdPartyLibs"/>
47 <probingPath
48 path="TestFiles\ContainerImplementations\Autofac"/>
49 <probingPath
50 path="TestFiles\ContainerImplementations\Ninject"/>
51 <probingPath
52 path="TestFiles\DynamicallyLoadedDlls"/>
53 </additionalAssemblyProbingPaths>
54
55 <assemblies>
56 <!--Assemblies should be in one of the following locations:
57 1) Executable's folder
58 2) In folder specified in additionalAssemblyProbingPaths element.
59 3) In one of the plugin folders specified in plugins element (only for assemblies with plugin attribute) -->
60
61 <!--
62 Use "overrideDirectory" attribute, to make the assembly path explicit, rather then searching for
63 an assembly in predefined folders, which also include probing paths specified in additionalAssemblyProbingPaths element.
64 -->
65 <assembly name="IoC.Configuration.Autofac" alias="autofac_ext"/>
66 <assembly name="IoC.Configuration.Ninject" alias="ninject_ext"/>
67
68 <assembly name="TestProjects.Modules" alias="modules"/>
69
70 <assembly name="TestProjects.DynamicallyLoadedAssembly1"
71 alias="dynamic1"/>
72
73 <assembly name="TestProjects.DynamicallyLoadedAssembly2"
74 alias="dynamic2"/>
75
76 <assembly name="TestProjects.TestPluginAssembly1"
77 alias="pluginassm1" plugin="Plugin1"/>
78
79 <assembly name="TestProjects.TestPluginAssembly2"
80 alias="pluginassm2" plugin="Plugin2"/>
81
82 <assembly name="TestProjects.TestPluginAssembly3"
83 alias="pluginassm3" plugin="Plugin3"/>
84
85 <assembly name="TestProjects.ModulesForPlugin1"
86 alias="modules_plugin1" plugin="Plugin1"/>
87
88 <assembly name="TestProjects.SharedServices" alias="shared_services"/>
89
90 <assembly name="IoC.Configuration.Tests" alias="tests"/>
91 </assemblies>
92
93 <typeDefinitions>
94 <typeDefinition alias="ConstAndStaticAppIds"
95 type="IoC.Configuration.Tests.ClassMember.Services.ConstAndStaticAppIds"/>
96 <typeDefinition alias="IAppIds" type="IoC.Configuration.Tests.ClassMember.Services.IAppIds"/>
97 <typeDefinition alias="AppTypes" type="IoC.Configuration.Tests.ClassMember.Services.AppTypes"/>
98 <typeDefinition alias="AppInfo" type="IoC.Configuration.Tests.ClassMember.Services.AppInfo"/>
99 <typeDefinition alias="StaticMethodsWithParameters"
100 type="IoC.Configuration.Tests.ClassMember.Services.StaticMethodsWithParameters"/>
101 </typeDefinitions>
102
103 <parameterSerializers>
104 <serializers></serializers>
105 </parameterSerializers>
106
107 <!--The value of type attribute should be a type that implements
108 IoC.Configuration.DiContainer.IDiManager-->
109 <diManagers activeDiManagerName="Autofac">
110 <diManager name="Ninject" type="IoC.Configuration.Ninject.NinjectDiManager"
111 assembly="ninject_ext">
112 <!--
113 Use parameters element to specify constructor parameters,
114 if the type specified in 'type' attribute has non-default constructor.
115 -->
116 <!--<parameters>
117 </parameters>-->
118 </diManager>
119
120 <diManager name="Autofac" type="IoC.Configuration.Autofac.AutofacDiManager"
121 assembly="autofac_ext">
122 </diManager>
123 </diManagers>
124
125 <!--
126 If settingsRequestor element is used, the type in type attribute should
127 specify a type that implements IoC.Configuration.ISettingsRequestor.
128 The implementation specifies a collection of required settings that should be present
129 in settings element.
130 Note, the type specified in type attribute is fully integrated into a dependency
131 injection framework. In other words, constructor parameters will be injected using
132 bindings specified in dependencyInjection element.
133 -->
134
135 <settings>
136
137 </settings>
138
139 <dependencyInjection>
140 <modules>
141 <!--<module type="IoC.Configuration.Tests.AutoService.AutoServiceTestsModule" />-->
142 <module type="IoC.Configuration.Tests.ClassMember.Module1">
143 <parameters>
144 <classMember name="param1" classRef="ConstAndStaticAppIds" memberName="DefaultAppId"/>
145 <classMember name="param2" classRef="StaticMethodsWithParameters" memberName="GetString">
146 <parameters>
147 <int32 name="intParam" value="5"/>
148 <string name="strParam" value="Value 1"/>
149 </parameters>
150 </classMember>
151 </parameters>
152 </module>
153 </modules>
154 <services>
155 <service type="System.Int32">
156 <valueImplementation scope="singleton">
157 <!--Example of classMember in valueImplementation. Since IAppIds.DefaultAppId is non-static,
158 IAppIds will be resolved from dependency injection container, and the value of property DefaultAppId of
159 resolved object will be bound to System.Int32
160 -->
161 <classMember classRef="IAppIds" memberName="DefaultAppId"/>
162
163 </valueImplementation>
164 </service>
165
166 <!--<service type="System.String">
167 <valueImplementation scope="singleton">
168 <object type="System.String" value="Test"/>
169 </valueImplementation>
170 </service>-->
171 <service type="System.String">
172 <valueImplementation scope="singleton">
173 <!--Example of classMember in valueImplementation. Since IAppIds.DefaultAppDescription is non-static,
174 IAppIds will be resolved from dependency injection container, and the value of property DefaultAppDescription of
175 resolved object will be bound to System.Int32
176 -->
177 <classMember classRef="IAppIds" memberName="DefaultAppDescription"/>
178 <!-- <object type="System.String" value="Test" />-->
179 </valueImplementation>
180 </service>
181
182
183 <service type="IoC.Configuration.Tests.ClassMember.Services.IAppInfo">
184 <!--The DI will try to construct IoC.Configuration.Tests.ClassMember.Services.AppInfo using the constructor
185 with max number of parameters: AppInfo(int appId, string appDescription).
186 Since we bound System.Int32, and System.String to IoC.Configuration.Tests.ClassMember.Services.IAppIds.DefaultAppId,
187 and IoC.Configuration.Tests.ClassMember.Services.IAppIds.DefaultAppDescription, the values of injected
188 appId and appDescription will be IoC.Configuration.Tests.ClassMember.Services.IAppIds.DefaultAppId and
189 IoC.Configuration.Tests.ClassMember.Services.IAppIds.DefaultAppDescription.
190 -->
191 <implementation typeRef="AppInfo" scope="singleton">
192 </implementation>
193 </service>
194
195 <service type="System.Collections.Generic.IReadOnlyList[System.Int32]">
196 <valueImplementation scope="singleton">
197 <collection>
198 <!--Demo of classMember in collection element.-->
199 <classMember classRef="ConstAndStaticAppIds" memberName="AppId1"/>
200 <classMember classRef="IAppIds" memberName="DefaultAppId"/>
201 </collection>
202 </valueImplementation>
203 </service>
204
205 <service type="IoC.Configuration.Tests.ClassMember.Services.IAppInfoFactory">
206 <implementation type="IoC.Configuration.Tests.ClassMember.Services.AppInfoFactory" scope="singleton"/>
207 </service>
208 </services>
209
210 <autoGeneratedServices>
211
212 <!--The scope for autoService implementations is always singleton -->
213 <autoService interfaceRef="IAppIds">
214 <autoProperty name="DefaultAppId" returnType="System.Int32">
215 <!--Example of using classMember attribute in auto property.-->
216 <classMember class="System.Int32" memberName="MaxValue"/>
217 </autoProperty>
218
219 <autoProperty name="DefaultAppDescription" returnType="System.String">
220 <!--Example of using classMember attribute in auto property.-->
221 <classMember classRef="ConstAndStaticAppIds" memberName="DefaultAppDescription"/>
222 </autoProperty>
223 </autoService>
224
225 <autoService interface="IoC.Configuration.Tests.ClassMember.Services.IAppInfos">
226 <autoProperty name="AllAppInfos"
227 returnType="System.Collections.Generic.IReadOnlyList[IoC.Configuration.Tests.ClassMember.Services.IAppInfo]">
228 <collection>
229 <constructedValue typeRef="AppInfo">
230 <parameters>
231 <!--Property IoC.Configuration.Tests.ClassMember.Services.IAppIds.DefaultAppId is non-static, therefore
232 IoC.Configuration.Tests.ClassMember.Services.IAppIds will be resolved from dependency injection container,
233 and the value of property DefaultAppId in resolved object will be used as parameter value appId-->
234 <classMember name="appId" classRef="IAppIds" memberName="DefaultAppId"/>
235 </parameters>
236 <injectedProperties>
237 <!--Property IoC.Configuration.Tests.ClassMember.Services.IAppIds.DefaultAppId is non-static, therefore
238 IoC.Configuration.Tests.ClassMember.Services.IAppIds will be resolved from dependency injection container,
239 and the value of property DefaultAppId in resolved object will be used as parameter value appId-->
240 <classMember name="AppDescription" classRef="IAppIds"
241 memberName="DefaultAppDescription"/>
242 </injectedProperties>
243 </constructedValue>
244
245 <!--
246 An example of calling a non static factory method to create an instance of IAppInfo.
247 Since method IoC.Configuration.Tests.ClassMember.Services.IAppInfoFactory.CreateAppInfo(appId, appDescription)
248 is non-static, an instance of IAppInfoFactory will be resolved using the DI container.
249 Also, since IAppInfoFactory is an interface, a binding for IAppInfoFactory should be configured in configuration
250 file or in some module.
251 -->
252 <classMember class="IoC.Configuration.Tests.ClassMember.Services.IAppInfoFactory"
253 memberName="CreateAppInfo">
254 <parameters>
255 <int32 name="appId" value="1258"/>
256 <string name="appDescription" value="App info created with non-static method call."/>
257 </parameters>
258 </classMember>
259
260 <!--
261 An example of calling a static factory method to create an instance of IAppInfo.
262 -->
263 <classMember class="IoC.Configuration.Tests.ClassMember.Services.StaticAppInfoFactory"
264 memberName="CreateAppInfo">
265 <parameters>
266 <int32 name="appId" value="1259"/>
267 <string name="appDescription" value="App info created with static method call."/>
268 </parameters>
269 </classMember>
270
271 <constructedValue typeRef="AppInfo">
272 <parameters>
273 <!--Method IoC.Configuration.Tests.ClassMember.Services.IAppIds.GetAppId() is non-static, therefore
274 IoC.Configuration.Tests.ClassMember.Services.IAppIds will be resolved from dependency injection container,
275 and the value returned by method IAppIds.GetAppId() will be used as parameter value appId-->
276 <classMember name="appId" classRef="IAppIds" memberName="GetAppId"/>
277 </parameters>
278 </constructedValue>
279
280 <constructedValue typeRef="AppInfo">
281 <parameters>
282 <!--Variable IoC.Configuration.Tests.ClassMember.Services.AppIdVars.NonStaticAppIdVar is non-static/non-constant, therefore
283 IoC.Configuration.Tests.ClassMember.Services.AppIdVars will be resolved from dependency injection container,
284 and the value variable NonStaticAppIdVarin resolved object will be used as parameter value appId
285 NOTE, no need to add a self bound service for IoC.Configuration.Tests.ClassMember.Services.AppIdVars, since
286 IoC.Configuration will generated one.
287 -->
288 <classMember name="appId" class="IoC.Configuration.Tests.ClassMember.Services.AppIdVars"
289 memberName="NonStaticAppIdVar"/>
290 </parameters>
291 </constructedValue>
292
293 <constructedValue typeRef="AppInfo">
294 <parameters>
295 <!--IoC.Configuration.Tests.ClassMember.Services.ConstAndStaticAppIds.AppId1 is a constant value.-->
296 <classMember name="appId" classRef="ConstAndStaticAppIds" memberName="AppId1"/>
297
298 <!--IoC.Configuration.Tests.ClassMember.Services.ConstAndStaticAppIds.App1Description is a constant value.-->
299 <classMember name="appDescription" classRef="ConstAndStaticAppIds"
300 memberName="App1Description"/>
301 </parameters>
302 </constructedValue>
303
304 <constructedValue typeRef="AppInfo">
305 <parameters>
306 <!--IoC.Configuration.Tests.ClassMember.Services.ConstAndStaticAppIds.AppId2 is a static variable.-->
307 <classMember name="appId" classRef="ConstAndStaticAppIds" memberName="AppId2"/>
308
309 <!--IoC.Configuration.Tests.ClassMember.Services.ConstAndStaticAppIds.App2Description is a static variable.-->
310 <classMember name="appDescription" classRef="ConstAndStaticAppIds"
311 memberName="App2Description"/>
312 </parameters>
313 </constructedValue>
314
315 <constructedValue typeRef="AppInfo">
316 <parameters>
317 <!--IoC.Configuration.Tests.ClassMember.Services.ConstAndStaticAppIds.AppId3 is a static property.-->
318 <classMember name="appId" classRef="ConstAndStaticAppIds" memberName="AppId3"/>
319
320 <!--IoC.Configuration.Tests.ClassMember.Services.ConstAndStaticAppIds.GetApp3Description is a static function-->
321 <classMember name="appDescription" classRef="ConstAndStaticAppIds"
322 memberName="GetApp3Description"/>
323 </parameters>
324 </constructedValue>
325
326 <constructedValue typeRef="AppInfo">
327 <parameters>
328 <!--IoC.Configuration.Tests.ClassMember.Services.ConstAndStaticAppIds.GetAppId4() is a static method.-->
329 <classMember name="appId" classRef="ConstAndStaticAppIds" memberName="GetAppId4"/>
330
331 <string name="appDescription" value="App 4"/>
332 </parameters>
333 </constructedValue>
334
335 <constructedValue typeRef="AppInfo">
336 <parameters>
337 <!--IoC.Configuration.Tests.ClassMember.Services.AppTypes.App1 is an enum value.-->
338 <classMember name="appId" classRef="AppTypes" memberName="App1"/>
339 </parameters>
340 </constructedValue>
341 </collection>
342 </autoProperty>
343 </autoService>
344
345 <autoService interface="IoC.Configuration.Tests.ClassMember.Services.IAppIdToPriority">
346 <autoMethod name="GetPriority" returnType="System.Int32">
347 <methodSignature>
348 <int32 paramName="appId"/>
349 </methodSignature>
350
351 <!--Property IoC.Configuration.Tests.ClassMember.Services.IAppIds.DefaultAppId is non-static, therefore
352 IoC.Configuration.Tests.ClassMember.Services.IAppIds will be resolved from dependency injection container,
353 and the value of property DefaultAppId in resolved object will be used in if condition-->
354 <if parameter1="_classMember:IAppIds.DefaultAppId">
355 <int32 value="14"/>
356 </if>
357
358 <!--Method IoC.Configuration.Tests.ClassMember.Services.IAppIds.GetAppId() is non-static, therefore
359 IoC.Configuration.Tests.ClassMember.Services.IAppIds will be resolved from dependency injection container,
360 and the value returned by method IAppIds.GetAppId() will be used in if condition-->
361 <if parameter1="_classMember:IAppIds.GetAppId">
362 <int32 value="25"/>
363 </if>
364
365 <!--Variable IoC.Configuration.Tests.ClassMember.Services.AppIdVars.NonStaticAppIdVar is non-static/non-constant, therefore
366 IoC.Configuration.Tests.ClassMember.Services.AppIdVars will be resolved from dependency injection container,
367 and the value variable NonStaticAppIdVarin resolved object will be used in if condition.
368 NOTE, no need to add a self bound service for IoC.Configuration.Tests.ClassMember.Services.AppIdVars, since
369 IoC.Configuration will generated one. -->
370 <if parameter1="_classMember:IoC.Configuration.Tests.ClassMember.Services.AppIdVars.NonStaticAppIdVar">
371 <int32 value="23"/>
372 </if>
373
374 <!--IoC.Configuration.Tests.ClassMember.Services.ConstAndStaticAppIds.AppId1 is a constant value.-->
375 <if parameter1="_classMember:ConstAndStaticAppIds.AppId1">
376 <int32 value="4"/>
377 </if>
378
379 <!--IoC.Configuration.Tests.ClassMember.Services.ConstAndStaticAppIds.AppId2 is a static variable.-->
380 <if parameter1="_classMember:ConstAndStaticAppIds.AppId2">
381 <int32 value="7"/>
382 </if>
383
384 <!--IoC.Configuration.Tests.ClassMember.Services.ConstAndStaticAppIds.AppId3 is a static property.-->
385 <if parameter1="_classMember:ConstAndStaticAppIds.AppId3">
386 <int32 value="8"/>
387 </if>
388
389 <!--IoC.Configuration.Tests.ClassMember.Services.ConstAndStaticAppIds.GetAppId4() is a static method.-->
390 <if parameter1="_classMember:ConstAndStaticAppIds.GetAppId4">
391 <int32 value="5"/>
392 </if>
393
394 <default>
395 <int32 value="0"/>
396 </default>
397 </autoMethod>
398
399 <autoMethod name="GetPriority" returnType="System.Int32">
400 <methodSignature>
401 <object paramName="appType" type="IoC.Configuration.Tests.ClassMember.Services.AppTypes"/>
402 </methodSignature>
403 <!--Example of using _classMember in If statement to reference enum value.-->
404 <if parameter1="_classMember:IoC.Configuration.Tests.ClassMember.Services.AppTypes.App1">
405 <int32 value="8"/>
406 </if>
407
408 <!--Example of using _classMember in If statement to reference enum value.-->
409 <if parameter1="_classMember:IoC.Configuration.Tests.ClassMember.Services.AppTypes.App2">
410 <int32 value="9"/>
411 </if>
412 <default>
413 <int32 value="1"/>
414 </default>
415 </autoMethod>
416 </autoService>
417 </autoGeneratedServices>
418 </dependencyInjection>
419
420 <startupActions>
421
422 </startupActions>
423
424 <pluginsSetup>
425 <pluginSetup plugin="Plugin1">
426 <!--The type in pluginImplementation should be non-abstract class
427 that implements IoC.Configuration.IPlugin and which has a public constructor-->
428 <pluginImplementation type="TestPluginAssembly1.Implementations.Plugin1_Simple">
429 </pluginImplementation>
430
431 <settings>
432 <int32 name="Int32Setting1" value="10"/>
433 <string name="StringSetting1" value="Some text"/>
434 </settings>
435
436 <dependencyInjection>
437 <modules>
438 </modules>
439
440 <services>
441 </services>
442
443 <autoGeneratedServices>
444 </autoGeneratedServices>
445 </dependencyInjection>
446 </pluginSetup>
447
448 <pluginSetup plugin="Plugin2">
449 <pluginImplementation type="TestPluginAssembly2.Implementations.Plugin2" assembly="pluginassm2">
450 <parameters>
451 <boolean name="param1" value="true"/>
452 <double name="param2" value="25.3"/>
453 <string name="param3" value="String value"/>
454 </parameters>
455 </pluginImplementation>
456 <settings>
457 </settings>
458 <dependencyInjection>
459 <modules>
460 </modules>
461 <services>
462 </services>
463 <autoGeneratedServices>
464 </autoGeneratedServices>
465 </dependencyInjection>
466 </pluginSetup>
467
468 <pluginSetup plugin="Plugin3">
469 <pluginImplementation type="TestPluginAssembly3.Implementations.Plugin3" assembly="pluginassm3">
470
471 </pluginImplementation>
472 <settings>
473 </settings>
474 <dependencyInjection>
475 <modules>
476 </modules>
477 <services>
478 </services>
479 <autoGeneratedServices>
480 </autoGeneratedServices>
481 </dependencyInjection>
482 </pluginSetup>
483 </pluginsSetup>
484</iocConfiguration>