IoCConfiguration_Overview.xml
The file IoCConfiguration_Overview.xml provides an overview of various features of IoC.Configuration
This configuration file can be downloaded downloaded from IoCConfiguration_Overview.xml.
1<?xml version="1.0" encoding="utf-8"?>
2
3<!--This is a demo IoC.Configuration file. Even though this configuration file, along with tests in folder SuccessfulConfigurationLoadTests
4 covers many use cases, some concepts are covered in more details in separate configuration files and tests.
5 Here is the list of other configuration files and tests that cover specific use cases:
6
7 Type reuse, generic types and arrays (elements typeDefinitions and typeDefinition and referencing types defined under typeDefinitions
8 element using attributes like typeRef, interfaceRef, classRef, etc): Look at configuration file
9 IoCConfiguration_GenericTypesAndTypeReUse.xml and tests in folder GenericTypesAndTypeReUse.
10 Element autoService: look at configuration file IoCConfiguration_autoService.xml and tests in folder AutoService.
11 Element autoServiceCustom: look at configuration file IoCConfiguration_autoServiceCustom.xml and tests in folder AutoService.
12 Element collection: look at configuration file IoCConfiguration_collection.xml and tests in folder Collection.
13 Element classMember and _classMember: prefix in "if" elements under autoMethod elements: look at configuration file
14 IoCConfiguration_classMember.xml and tests in folder ClassMember.
15 Element settingValue: look at configuration file IoCConfiguration_settingValue_ReferencingInConfiguration.xml and tests in folder SettingValue.
16 Element constructedValue: look at configuration file IoCConfiguration_constructedValue.xml and tests in folder ConstructedValue.
17 Element proxyService: look at configuration file IoCConfiguration_proxyService.xml and tests in folder ProxyService.
18
19 Element valueImplementation (to provide implementation as a value). Example is using a classMember, or settingValue elements to
20 provide an implementation for a service.: look at configuration file IoCConfiguration_valueImplementation.xml and tests in folder ValueImplementation.
21-->
22<!--
23 The XML configuration file is validated against schema file IoC.Configuration.Schema.22B4BA50-3429-48FE-8059-B9C1F855A639.xsd,
24 which can be found in folder IoC.Configuration.Content in output directory.
25 The schema file can also be downloaded from
26 http://oroptimizer.com/ioc.configuration/V2/IoC.Configuration.Schema.22B4BA50-3429-48FE-8059-B9C1F855A639.xsd or in source code
27 project in Github.com.
28
29 To use Visual Studio code completion based on schema contents, right click Properties on this file in Visual Studio, and in Schemas
30 field pick the schema IoC.Configuration.Schema.22B4BA50-3429-48FE-8059-B9C1F855A639.xsd.
31
32 Before running the tests make sure to execute IoC.Configuration\Tests\IoC.Configuration.Tests\PostBuildCommands.bat to copy the dlls into
33 folders specified in this configuration file.
34 Also, modify the batch file to copy the Autofac and Ninject assemblies from Nuget packages folder on machine, where the test is run.
35-->
36
37<iocConfiguration
38 xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
39 xsi:noNamespaceSchemaLocation="http://oroptimizer.com/IoC.Configuration/V2/IoC.Configuration.Schema.22B4BA50-3429-48FE-8059-B9C1F855A639.xsd">
40
41 <!--The application should have write permissions to path specified in appDataDir.
42 This is where dynamically generated DLLs are saved.-->
43 <!--NOTE: path should be an absolute path, or should be converted to absolute path by some implementation of
44 IoC.Configuration.AttributeValueTransformer.IAttributeValueTransformer. In this example the paths are converted by
45 IoC.Configuration.Tests.FileFolderPathAttributeValueTransformer.-->
46 <appDataDir
47 path="TestFiles\AutogeneratedDlls\IoCConfiguration_Overview" />
48
49 <plugins pluginsDirPath="TestFiles\PluginDlls">
50
51 <!--
52 Plugin assemblies will be in a folder with similar name under pluginsDirPath folder.
53 The plugin folders will be included in assembly resolution mechanism.
54 -->
55
56 <!--A folder K:\...\IoC.Configuration\Tests\IoC.Configuration.Tests\bin\TestFiles\PluginDlls\Plugin1 should exist. -->
57 <plugin name="Plugin1" />
58 <plugin name="Plugin2" />
59 <plugin name="Plugin3" enabled="false" />
60 </plugins>
61
62 <additionalAssemblyProbingPaths>
63 <probingPath
64 path="TestFiles\ThirdPartyLibs" />
65 <probingPath
66 path="TestFiles\ContainerImplementations\Autofac" />
67 <probingPath
68 path="TestFiles\ContainerImplementations\Ninject" />
69
70 <probingPath
71 path="TestFiles\DynamicallyLoadedDlls" />
72 <probingPath
73 path="TestFiles\TestAssemblyResolution" />
74 </additionalAssemblyProbingPaths>
75
76 <assemblies>
77 <!--Assemblies should be in one of the following locations:
78 1) Executable's folder
79 2) In folder specified in additionalAssemblyProbingPaths element.
80 3) In one of the plugin folders specified in plugins element (only for assemblies with plugin attribute) -->
81 <assembly name="OROptimizer.Shared" alias="oroptimizer_shared" />
82 <assembly name="IoC.Configuration" alias="ioc_config" />
83 <assembly name="IoC.Configuration.Autofac" alias="autofac_ext" />
84 <assembly name="IoC.Configuration.Ninject" alias="ninject_ext" />
85
86 <assembly name="TestProjects.Modules" alias="modules" />
87
88 <!--
89 Use "overrideDirectory" attribute, to make the assembly path explicit, rather then searching for
90 an assembly in predefined folders, which also include
91 probing paths specified in additionalAssemblyProbingPaths element.
92 -->
93 <assembly name="TestProjects.DynamicallyLoadedAssembly1"
94 alias="dynamic1" overrideDirectory="TestFiles\DynamicallyLoadedDlls"/>
95
96 <assembly name="TestProjects.DynamicallyLoadedAssembly2"
97 alias="dynamic2" />
98
99 <assembly name="TestProjects.TestPluginAssembly1"
100 alias="pluginassm1" plugin="Plugin1" />
101
102 <assembly name="TestProjects.ModulesForPlugin1"
103 alias="modules_plugin1" plugin="Plugin1" />
104
105 <assembly name="TestProjects.Plugin1WebApiControllers"
106 alias="plugin1api" plugin="Plugin1" />
107
108
109 <assembly name="TestProjects.TestPluginAssembly2"
110 alias="pluginassm2" plugin="Plugin2" />
111
112 <assembly name="TestProjects.ModulesForPlugin2"
113 alias="modules_plugin2" plugin="Plugin2"/>
114
115 <assembly name="TestProjects.TestPluginAssembly3"
116 alias="pluginassm3" plugin="Plugin3" />
117
118 <assembly name="TestProjects.SharedServices" alias="shared_services" />
119
120 <assembly name="IoC.Configuration.Tests" alias="tests" />
121
122 <assembly name="System.Threading.Tasks.Extensions" alias="threading_tasks_extensions" />
123 </assemblies>
124
125 <typeDefinitions>
126 <!--For more examples of type definitions and generic types, arrays, and re-using types defined under
127 typeDefinition element look at file IoCConfiguration_GenericTypesAndTypeReUse.xml, as well as tests
128 in folder GenericTypesAndTypeReUse.
129 -->
130 <typeDefinition alias="ReadOnlyListOf_IInterface1" type="System.Collections.Generic.IReadOnlyList[SharedServices.Interfaces.IInterface1]" />
131
132 <!--The type definition below is similar to C# type System.Collections.Generic.IEnumerable<SharedServices.Interfaces.IInterface1[]>-->
133 <typeDefinition alias="enumerableOfArray" type="System.Collections.Generic.IEnumerable[SharedServices.Interfaces.IInterface1#]" />
134
135 <!--The type definition below is similar to C# type System.Collections.Generic.IList<SharedServices.Interfaces.IInterface1[]>-->
136 <typeDefinition alias="listOfArray" type="System.Collections.Generic.IList" >
137 <genericTypeParameters>
138 <typeDefinition type="SharedServices.Interfaces.IInterface1#" />
139 </genericTypeParameters>
140 </typeDefinition>
141
142 <typeDefinition alias="AutoService_IInterface1" type="IoC.Configuration.Tests.AutoService.Services.IInterface1" />
143 <typeDefinition alias="IActionValidator" type="SharedServices.Interfaces.IActionValidator" />
144 <typeDefinition alias="IProjectGuids" type="IoC.Configuration.Tests.AutoService.Services.IProjectGuids" />
145 <typeDefinition alias="ActionTypes" type="SharedServices.DataContracts.ActionTypes" />
146 <typeDefinition alias="Guid" type="System.Guid" />
147 <typeDefinition alias="ListOfInt" type="System.Collections.Generic.List[System.Int32]" >
148 </typeDefinition>
149 </typeDefinitions>
150
151 <!--assembly attribute is not required, and only is needed to make sure the type is looked at specific assembly
152 If the assembly attribute is omitted, the type will be looked in all assemblies specified in assemblies, plus some additional
153 assemblies such as OROptimizer.Shared, IoC.Configuration, etc.
154 -->
155 <parameterSerializers serializerAggregatorType="OROptimizer.Serializer.TypeBasedSimpleSerializerAggregator"
156 assembly="oroptimizer_shared">
157 <!--
158 Use parameters element to specify constructor parameters, if the type specified in 'serializerAggregatorType' attribute
159 has non-default constructor.
160 -->
161 <!--<parameters>
162 </parameters>-->
163 <serializers>
164 <parameterSerializer type="OROptimizer.Serializer.TypeBasedSimpleSerializerDouble" />
165 <parameterSerializer type="OROptimizer.Serializer.TypeBasedSimpleSerializerLong" />
166 <parameterSerializer type="OROptimizer.Serializer.TypeBasedSimpleSerializerInt"/>
167 <parameterSerializer type="OROptimizer.Serializer.TypeBasedSimpleSerializerShort"/>
168 <parameterSerializer type="OROptimizer.Serializer.TypeBasedSimpleSerializerByte" />
169 <parameterSerializer type="OROptimizer.Serializer.TypeBasedSimpleSerializerBoolean" />
170 <parameterSerializer type="OROptimizer.Serializer.TypeBasedSimpleSerializerDateTime" />
171 <parameterSerializer type="OROptimizer.Serializer.TypeBasedSimpleSerializerString" />
172 <parameterSerializer type="TestPluginAssembly1.Implementations.DoorSerializer" />
173 <parameterSerializer type="TestPluginAssembly2.Implementations.WheelSerializer" />
174
175 <parameterSerializer type="TestPluginAssembly1.Implementations.UnsignedIntSerializerWithParameters" >
176 <parameters>
177 <int32 name="param1" value="25" />
178 <double name="param2" value="36.5" />
179 </parameters>
180 </parameterSerializer>
181 </serializers>
182
183 </parameterSerializers>
184
185 <!--The value of type attribute should be a type that implements
186 IoC.Configuration.DiContainer.IDiManager-->
187 <diManagers activeDiManagerName="Autofac">
188 <diManager name="Ninject" type="IoC.Configuration.Ninject.NinjectDiManager">
189 <!--
190 Use parameters element to specify constructor parameters,
191 if the type specified in 'type' attribute has non-default constructor.
192 -->
193 <!--<parameters>
194 </parameters>-->
195 </diManager>
196
197 <diManager name="Autofac" type="IoC.Configuration.Autofac.AutofacDiManager">
198 </diManager>
199 </diManagers>
200
201 <!--
202 If settingsRequestor element is used, the type in type attribute should
203 specify a type that implements IoC.Configuration.ISettingsRequestor.
204 The implementation specifies a collection of required settings that should be present
205 in settings element.
206 Note, the type specified in type attribute is fully integrated into a dependency
207 injection framework. In other words, constructor parameters will be injected using
208 bindings specified in dependencyInjection element.
209 -->
210 <settingsRequestor type="SharedServices.FakeSettingsRequestor">
211 </settingsRequestor>
212
213 <settings>
214 <int32 name="SynchronizerFrequencyInMilliseconds" value="5000" />
215 <double name="MaxCharge" value="155.7" />
216 <string name="DisplayValue" value="Some display value" />
217
218 <!--NOTE: For more comprehensive examples for constructedValue element,
219 look at file IoCConfiguration_constructedValue.xml and tests in folder ConstructedValue.-->
220 <constructedValue name="DefaultDBConnection" type="SharedServices.Implementations.SqliteDbConnection">
221 <parameters>
222 <string name="filePath" value="c:\SQLiteFiles\MySqliteDb.sqlite"/>
223 </parameters>
224 </constructedValue>
225
226 <object name="Project1Guid" typeRef="Guid" value="EA91B230-3FF8-43FA-978B-3261493D58A3" />
227 <object name="Project2Guid" typeRef="Guid" value="9EDC7F1A-6BD6-4277-9015-5A9277218681" />
228
229 <constructedValue name="Interface11_Value" type="SharedServices.Implementations.Interface11_Impl1">
230 <parameters>
231 <!-- Constructor parameter of SharedServices.Implementations.Interface11 is injected using a constructedValue element-->
232 <constructedValue name="param1" type="SharedServices.Implementations.Interface10_Impl1" >
233 <parameters>
234 <int32 name="param1" value="13" />
235 </parameters>
236 <injectedProperties>
237 <string name="Property2" value="Value 1"/>
238 </injectedProperties>
239 </constructedValue>
240 </parameters>
241
242 <injectedProperties>
243 <!-- Property SharedServices.Implementations.Interface11.Property2 is injected using a constructedValue element-->
244 <constructedValue name="Property2" type="SharedServices.Implementations.Interface10_Impl1" >
245 <parameters>
246 <int32 name="param1" value="17"/>
247 </parameters>
248 <injectedProperties>
249 <string name="Property2" value="Value 2"/>
250 </injectedProperties>
251 </constructedValue>
252
253 </injectedProperties>
254 </constructedValue>
255
256 <!--NOTE: For more comprehensive examples for collection element,
257 look at file IoCConfiguration_collection.xml and tests in folder Collection.-->
258 <constructedValue name="Collections" type="IoC.Configuration.Tests.Collection.Services.DemoCollectionInjection">
259 <parameters>
260 <!--Demo of injecting a collection into a constructor of DemoCollectionInjection in constructedValue element.-->
261 <collection name="intValues" collectionType="readOnlyList" itemType="System.Int32">
262 <int32 value="17"/>
263 <int32 value="14"/>
264 </collection>
265 </parameters>
266 <injectedProperties>
267 <!--Demo of injecting a collection into a property of DemoCollectionInjection in constructedValue element.-->
268 <collection name="Texts" collectionType="readOnlyList" itemType="System.String">
269 <string value="ABC, Inc"/>
270 <string value="Microsoft"/>
271 </collection>
272 </injectedProperties>
273 </constructedValue>
274
275 <boolean name="failCustomServiceValidation" value="false"/>
276 </settings>
277
278 <!--
279 webApi is an optional element that contains ASP.NET Core related
280 sections such as assemblies with API controllers, etc
281 -->
282 <webApi>
283 <controllerAssemblies>
284 <!--
285 Specify assemblies with API controllers.
286 The user of IoC.Configuration should add the assemblies to MVC using
287 IMvcBuilder.AddApplicationPart(System.Reflection.Assembly)
288 -->
289 <controllerAssembly assembly="dynamic1"></controllerAssembly>
290 </controllerAssemblies>
291 </webApi>
292
293 <dependencyInjection>
294 <modules>
295 <module type="IoC.Configuration.Tests.PrimitiveTypeDefaultBindingsModule" >
296 <parameters>
297 <!--Date time can be also long value for ticks. For example the datetime value below can
298 be replaced with 604096704000000000-->
299 <datetime name="defaultDateTime" value="1915-04-24 00:00:00.000" />
300 <double name="defaultDouble" value="0" />
301 <int16 name="defaultInt16" value="0" />
302 <classMember name="defaultInt32" class="System.Int32" memberName="MinValue"/>
303 </parameters>
304 </module>
305
306 <!--Type Modules.Autofac.AutofacModule1 is an Autofac module and is a
307 subclass of Autofac.AutofacModule-->
308 <module type="Modules.Autofac.AutofacModule1" >
309 <parameters>
310 <int32 name="param1" value="1" />
311 </parameters>
312 </module>
313
314 <!--Type Modules.IoC.DiModule1 is an IoC.Configuration module and is a subclass
315 of IoC.Configuration.DiContainer.ModuleAbstr-->
316 <module type="Modules.IoC.DiModule1" >
317 <parameters>
318 <int32 name="param1" value="2" />
319 </parameters>
320 </module>
321
322 <!--Type Modules.Ninject.NinjectModule1 is a Ninject module and is a
323 subclass of Ninject.Modules.NinjectModule-->
324 <module type="Modules.Ninject.NinjectModule1" >
325 <parameters>
326 <int32 name="param1" value="3" />
327 </parameters>
328 </module>
329
330 <module type="IoC.Configuration.Tests.AutoService.AutoServiceTestsModule" />
331 </modules>
332 <services>
333 <service type="DynamicallyLoadedAssembly1.Interfaces.IInterface1">
334 <implementation type="DynamicallyLoadedAssembly1.Implementations.Interface1_Impl1"
335 scope="singleton">
336 </implementation>
337 </service>
338
339 <service type="DynamicallyLoadedAssembly1.Interfaces.IInterface2">
340 <implementation type="DynamicallyLoadedAssembly1.Implementations.Interface2_Impl1"
341 scope="transient">
342 </implementation>
343 </service>
344
345 <service type="DynamicallyLoadedAssembly1.Interfaces.IInterface3">
346 <implementation type="DynamicallyLoadedAssembly1.Implementations.Interface3_Impl1"
347 scope="scopeLifetime">
348 </implementation>
349 </service>
350
351 <!--
352 Test DI picking the default constructor when instantiating the implementation, if parameters element is
353 present, and using non-default constructor otherwise, with injected parameters.
354 -->
355 <service type="SharedServices.Interfaces.IInterface9">
356 <implementation type="SharedServices.Implementations.Interface9_Impl1"
357 scope="singleton" />
358 </service>
359 <service type="SharedServices.Interfaces.IInterface8">
360 <implementation type="SharedServices.Implementations.Interface8_Impl1"
361 scope="singleton">
362 <!--
363 Since parameters is present, a default constructor will be used to construct an object, even though
364 Interface8_Impl1 has also a non default constructor.
365 -->
366 <parameters>
367 </parameters>
368 </implementation>
369
370 <implementation type="SharedServices.Implementations.Interface8_Impl2" scope="singleton">
371 <!--
372 Since parameters is not present, DI will pick a constructor with maximum number of parameters.
373 Note, Interface8_Impl2 has two constructors, a default one, and a constructor with parameters.
374 -->
375 </implementation>
376 </service>
377
378 <!--Injected constructor parameters with self bound services-->
379 <selfBoundService type="DynamicallyLoadedAssembly1.Implementations.SelfBoundService1"
380 scope="singleton">
381 <parameters>
382 <int32 name="param1" value="14" />
383 <double name="param2" value="15.3" />
384 <injectedObject name="param3" type="DynamicallyLoadedAssembly1.Interfaces.IInterface1" />
385 </parameters>
386 </selfBoundService>
387
388 <!--Injected properties with self bound services-->
389 <selfBoundService type="DynamicallyLoadedAssembly1.Implementations.SelfBoundService2"
390 scope="transient">
391 <injectedProperties>
392 <int32 name="Property1" value="17" />
393 <double name="Property2" value="18.1" />
394 <injectedObject name="Property3" type="DynamicallyLoadedAssembly1.Interfaces.IInterface1" />
395 </injectedProperties>
396 </selfBoundService>
397
398 <!--Lifetime scope with self bound services-->
399 <selfBoundService type="DynamicallyLoadedAssembly1.Implementations.SelfBoundService3"
400 scope="scopeLifetime">
401 </selfBoundService>
402
403 <!--Test circular references between SharedServices.Interfaces.IInterface3 and SharedServices.Interfaces.IInterface4-->
404 <service type="SharedServices.Interfaces.IInterface3" >
405 <implementation type="SharedServices.Implementations.Interface3_Impl1"
406 scope="singleton">
407 <injectedProperties>
408 <injectedObject name="Property2" type="SharedServices.Interfaces.IInterface4" />
409 </injectedProperties>
410 </implementation>
411 </service>
412 <service type="SharedServices.Interfaces.IInterface4">
413 <implementation type="SharedServices.Implementations.Interface4_Impl1"
414 scope="singleton">
415 </implementation>
416 </service>
417
418 <!--Injected constructor parameters-->
419 <service type="SharedServices.Interfaces.IInterface2" >
420 <!--Test constructor parameters-->
421 <implementation type="SharedServices.Implementations.Interface2_Impl1"
422 scope="singleton">
423 <parameters>
424 <!--The value will be de-serialized using serializer TypeBasedSimpleSerializerDateTime
425 in parameterSerializers section.-->
426 <datetime name="param1" value="2014-10-29 23:59:59.099" />
427 <double name="param2" value="125.1" />
428 <injectedObject name="param3" type="SharedServices.Interfaces.IInterface3" />
429 </parameters>
430 </implementation>
431
432 <!--Test injected properties-->
433 <implementation type="SharedServices.Implementations.Interface2_Impl2"
434 scope="singleton">
435 <injectedProperties>
436 <!--The value of param2 will be de-serialized using serializer TypeBasedSimpleSerializerDateTime
437 in parameterSerializers section.-->
438 <datetime name="Property1" value="1915-04-24 00:00:00.001" />
439 <double name="Property2" value="365.41" />
440 <injectedObject name="Property3" type="SharedServices.Interfaces.IInterface3" />
441 </injectedProperties>
442 </implementation>
443
444 <!--Test constructor parameters with injected properties. Constructor values will be overridden by
445 injected properties.-->
446 <implementation type="SharedServices.Implementations.Interface2_Impl3"
447 scope="singleton">
448 <parameters>
449 <!--The value will be de-serialized using serializer TypeBasedSimpleSerializerDateTime in
450 parameterSerializers section.-->
451 <datetime name="param1" value="2017-10-29 23:59:59.099" />
452 <double name="param2" value="138.3" />
453
454 <!--
455 Inject specific implementation. Note, there is no binding for Interface3_Impl2.
456 IoC.Configuration** will automatically register a self bound service for a type specified in elements
457 injectedObject, if the type is not an abstract type or an interface, and if it is not already
458 registered in configuration file.
459 Also, using injectedObject, we can specify a type other than a type registered for interface
460 SharedServices.Implementations.Interface3 (i.e., the type of parameter param3).
461 In other words, no matter what bindings are specified for interface SharedServices.Implementations.Interface3,
462 the object injected for parameter param3 will be of type SharedServices.Implementations.Interface3_Impl2.
463 -->
464 <injectedObject name="param3" type="SharedServices.Implementations.Interface3_Impl2" />
465 </parameters>
466 <injectedProperties>
467 <double name="Property2" value="148.3" />
468 <!--
469 Inject specific implementation. Note, there is no binding for Interface3_Impl3.
470 IoC.Configuration** will automatically register a self bound service for a type specified in element
471 injectedObject, if the type is not an abstract type or an interface, and if it is not already
472 registered in configuration file.
473 Also, using injectedObject, we can specify a type other than a type registered for type of property
474 Property3 somewhere else. By using element injectedObject we explicitly state the type of the object
475 that should be injected, which is SharedServices.Implementations.Interface3_Impl3 in this example.
476 -->
477 <injectedObject name="Property3" type="SharedServices.Implementations.Interface3_Impl3" />
478 </injectedProperties>
479 </implementation>
480
481 <!--Test injected constructor parameters. Primitive type constructor parameters, such as DateTime and double,
482 will be injected with default values specified in module: IoC.Configuration.Tests.PrimitiveTypeDefaultBindingsModule.
483 -->
484 <implementation type="SharedServices.Implementations.Interface2_Impl4"
485 scope="singleton">
486 </implementation>
487 </service>
488
489 <!--Test constructed values to set implementation constructor parameter and property values-->
490 <service type="SharedServices.Interfaces.Airplane.IAirplane" >
491 <implementation type="SharedServices.Implementations.Airplane.Airplane" scope="singleton" >
492 <parameters>
493 <!--Tested constructed value in parameter-->
494 <constructedValue name="engine" type="SharedServices.Implementations.Airplane.AirplaneEngine">
495 <parameters>
496 <!--Constructed value parameters can also be constructed values. However, for simplicity, injected parameters were used -->
497 <injectedObject name="blade" type="SharedServices.Interfaces.Airplane.IAirplaneEngineBlade" />
498 <injectedObject name="rotor" type="SharedServices.Interfaces.Airplane.IAirplaneEngineRotor" />
499 </parameters>
500 <!--constructedValue element also can have injectedProperties child element to inject values into constructed object
501 properties which have public setters.-->
502 <!--<injectedProperties></injectedProperties>-->
503 </constructedValue>
504
505 </parameters>
506 </implementation>
507
508 <!--Tested constructed value to inject property values-->
509 <implementation type="SharedServices.Implementations.Airplane.Airplane" scope="singleton">
510
511 <injectedProperties>
512 <!--Injecting constructed value of type SharedServices.Implementations.Airplane.AirplaneEngine
513 into a property SharedServices.Implementations.Airplane.Airplane.Engine-->
514 <constructedValue name="Engine" type="SharedServices.Implementations.Airplane.AirplaneEngine">
515 <!--Class TestProjects.SharedServices.Implementations.Airplane.AirplaneEngine has a default constructor
516 which will be used in this case.-->
517
518
519 <!--After the object is created, the values of properties AirplaneEngine.Blade and AirplaneEngine.Rotor will
520 be injected using injectedProperties element.-->
521 <injectedProperties>
522
523 <!--Constructed value parameters can also be constructed values. However, for simplicity, injected parameters were used -->
524 <injectedObject name="Blade" type="SharedServices.Interfaces.Airplane.IAirplaneEngineBlade" />
525 <injectedObject name="Rotor" type="SharedServices.Interfaces.Airplane.IAirplaneEngineRotor" />
526 </injectedProperties>
527 </constructedValue>
528 </injectedProperties>
529 </implementation>
530 </service>
531
532 <service type="SharedServices.Interfaces.Airplane.IAirplaneEngineBlade">
533 <implementation type="SharedServices.Implementations.Airplane.AirplaneEngineBlade" scope="singleton"></implementation>
534 </service>
535 <service type="SharedServices.Interfaces.Airplane.IAirplaneEngineRotor">
536 <implementation type="SharedServices.Implementations.Airplane.AirplaneEngineRotor" scope="singleton"></implementation>
537 </service>
538
539 <!--<selfBoundService type="SharedServices.Implementations.ActionValidator3" scope="transient">
540 <parameters>
541 <int32 name="intParam" value="5" />
542 </parameters>
543 </selfBoundService>-->
544
545 <selfBoundService type="DynamicallyLoadedAssembly1.Implementations.CleanupJob2"
546 scope="transient">
547 <parameters>
548 <injectedObject name="cleanupJobData"
549 type="DynamicallyLoadedAssembly1.Implementations.CleanupJobData2" />
550 </parameters>
551 </selfBoundService>
552
553 <selfBoundService type="DynamicallyLoadedAssembly1.Implementations.CleanupJob3"
554 scope="singleton">
555 <injectedProperties>
556 <injectedObject name="CleanupJobData"
557 type="DynamicallyLoadedAssembly1.Implementations.CleanupJobData2"/>
558 </injectedProperties>
559 </selfBoundService>
560
561 <service type="SharedServices.Interfaces.ICleanupJobData">
562 <implementation type="DynamicallyLoadedAssembly1.Implementations.CleanupJobData"
563 scope="singleton">
564 </implementation>
565
566 </service>
567
568 <!--Service implemented by plugins-->
569 <service type="SharedServices.Interfaces.IInterface5">
570 <implementation type="SharedServices.Implementations.Interface5_Impl1"
571 scope="singleton" />
572 <implementation type="TestPluginAssembly1.Implementations.Interface5_Plugin1Impl"
573 scope="singleton" />
574 <implementation type="TestPluginAssembly2.Implementations.Interface5_Plugin2Impl"
575 scope="transient" />
576 <implementation type="TestPluginAssembly3.Implementations.Interface5_Plugin3Impl"
577 scope="transient" />
578 </service>
579
580 <!--
581 Test registerIfNotRegistered. Note, SharedServices.Interfaces.IInterface6 is already registered in
582 module Modules.IoC.DiModule1 for implementation SharedServices.Implementations.Interface6_Impl1.
583 Therefore, implementation SharedServices.Implementations.Interface6_Impl2 will not be registered.
584 -->
585 <service type="SharedServices.Interfaces.IInterface6"
586 registerIfNotRegistered="true">
587 <implementation type="SharedServices.Implementations.Interface6_Impl2"
588 scope="singleton" />
589 </service>
590
591 <!--
592 Note, service SharedServices.Interfaces.IInterface7 was not registered before. Therefore its implementations
593 registered below will be registered.
594 -->
595 <service type="SharedServices.Interfaces.IInterface7"
596 registerIfNotRegistered="true">
597 <implementation type="SharedServices.Implementations.Interface7_Impl1"
598 scope="singleton" />
599 </service>
600
601 <selfBoundService type="SharedServices.Implementations.SelfBoundService1"
602 registerIfNotRegistered="true" scope="singleton">
603
604 </selfBoundService>
605
606 <service type="SharedServices.Interfaces.IInterface12">
607 <implementation type="SharedServices.Implementations.Interface12_Impl1" scope="singleton">
608 <parameters>
609 <!--Setting with name Interface11_Value is injected into constructor parameter param1 of
610 class SharedServices.Implementations.Interface12_Impl1-->
611 <!--NOTE: For more comprehensive examples for settingValue element,
612 look at file IoCConfiguration_settingValue_ReferencingInConfiguration.xml and tests in folder SettingValue.-->
613 <settingValue name="param1" settingName="Interface11_Value"/>
614 </parameters>
615 <injectedProperties>
616 <!--Setting with name Interface11_Value is injected into property
617 SharedServices.Implementations.Interface12_Impl1.Property2-->
618 <settingValue name="Property2" settingName="Interface11_Value"/>
619 </injectedProperties>
620 </implementation>
621
622 </service>
623 <service type="SharedServices.Interfaces.IDbConnection">
624 <valueImplementation scope="singleton">
625 <settingValue settingName="DefaultDBConnection"/>
626 </valueImplementation>
627 </service>
628
629 <!--NOTE: For more comprehensive examples for collection element,
630 look at file IoCConfiguration_collection.xml and tests in folder Collection.-->
631 <!--NOTE: For more comprehensive examples for valueImplementation element,
632 look at file IoCConfiguration_valueImplementation.xml and tests in folder ValueImplementation.-->
633 <service type="System.Collections.Generic.IReadOnlyList[SharedServices.Interfaces.IDbConnection]">
634 <valueImplementation scope="singleton">
635 <collection>
636 <settingValue settingName="DefaultDBConnection"/>
637 <constructedValue type="SharedServices.Implementations.SqlServerDbConnection">
638 <parameters>
639 <string name="serverName" value="SQLSERVER2012"/>
640 <string name="databaseName" value="DB1"/>
641 <string name="userName" value="user1"/>
642 <string name="password" value="password123"/>
643 </parameters>
644 </constructedValue>
645 <constructedValue type="SharedServices.Implementations.SqlServerDbConnection">
646 <parameters>
647 <string name="serverName" value="SQLSERVER2016"/>
648 <string name="databaseName" value="DB1"/>
649 <string name="userName" value="user1"/>
650 <string name="password" value="password123"/>
651 </parameters>
652 </constructedValue>
653 </collection>
654 </valueImplementation>
655 </service>
656
657 <!--NOTE: For more comprehensive examples for proxyService element,
658 look at file IoCConfiguration_proxyService.xml and tests in folder ProxyService.-->
659 <!--
660 Using proxyService we can configure binding of a parent interface IActionValidatorFactoryBase in such a way, that it is resolved
661 using the same binding set up for extending interface IActionValidatorFactory.
662 For example auto-generated service IActionValidatorFactory implements methods and properties in both IActionValidatorFactory
663 as well as in parent interface IActionValidatorFactoryBase. By using proxyService we can inject the auto-generated implementation
664 for IActionValidatorFactory into classes which depend on its parent interface IActionValidatorFactoryBase.
665 -->
666 <proxyService type="IoC.Configuration.Tests.AutoService.Services.IActionValidatorFactoryBase">
667 <serviceToProxy type="IoC.Configuration.Tests.AutoService.Services.IActionValidatorFactory"/>
668 </proxyService>
669
670 <!--START-Test binding an interface to the ame instance to which a self-bound class is bound-->
671 <selfBoundService type="SharedServices.Implementations.Interface13_Impl1" scope="singleton" />
672
673 <!--NOTE: Using proxyService allows us to bind
674 SharedServices.Interfaces.IInterface13 to the same instance of SharedServices.Implementations.Interface13_Impl1 to which
675 SharedServices.Implementations.Interface13_Impl1 was bound using selfBoundService element.
676
677 If we used "implementation" element under service and specified a type SharedServices.Implementations.Interface13_Impl1
678 instead of using "proxyService", then SharedServices.Interfaces.IInterface13 would have been
679 bound to a different instance of SharedServices.Implementations.Interface13_Impl1. In other words resolving
680 SharedServices.Implementations.Interface13_Impl1 and SharedServices.Interfaces.IInterface13 would have resulted in
681 different instances of SharedServices.Implementations.Interface13_Impl1.
682 Using "proxyService" element might be useful when we have module(s) that scan assemblies and self-binds
683 non-abstract classes. In this cases we can use "proxyService" element if we want the interface
684 specified in "proxyService" element to resolve to exactly the same value to which the self bound class is bound.
685 -->
686 <proxyService type="SharedServices.Interfaces.IInterface13">
687 <serviceToProxy type="SharedServices.Implementations.Interface13_Impl1"/>
688 </proxyService>
689
690 <service type="SharedServices.Interfaces.IInterface14">
691 <implementation type="SharedServices.Implementations.Interface14_Impl1" scope="singleton" />
692 </service>
693
694 <!--END-Test binding an interface to the ame instance to which a self-bound class is bound-->
695
696 <!--Note, ActionValidatorsUser constructor has a parameter of type
697 IoC.Configuration.Tests.AutoService.Services.IActionValidatorFactoryBase.
698 Since there is a proxyService element mapping the service IActionValidatorFactoryBase to IActionValidatorFactory,
699 an instance of auto-generated service IoC.Configuration.Tests.AutoService.Services.IActionValidatorFactory will be injected.
700 -->
701 <selfBoundService type="IoC.Configuration.Tests.ProxyService.Services.ActionValidatorsUser" scope="singleton">
702 </selfBoundService>
703
704 <!--System.Collections.Generic.List<System.Int32> will be bound to a list of three integers: 19, 2, 17-->
705 <service typeRef="ListOfInt">
706 <valueImplementation scope="singleton">
707 <collection>
708 <int32 value="19"/>
709 <int32 value="2"/>
710 <int32 value="17"/>
711 </collection>
712 </valueImplementation>
713 </service>
714
715 <!--Resolving System.Collections.Generic.IEnumerable<System.Int32> will return the same value as resolving
716 System.Collections.Generic.List<System.Int32>-->
717 <proxyService type="System.Collections.Generic.IEnumerable[System.Int32]">
718 <serviceToProxy typeRef="ListOfInt"/>
719 </proxyService>
720
721 <!--Resolving System.Collections.Generic.IReadOnlyList<System.Int32> will return the same value as resolving
722 System.Collections.Generic.List<System.Int32>-->
723 <proxyService type="System.Collections.Generic.IReadOnlyList[System.Int32]">
724 <serviceToProxy typeRef="ListOfInt"/>
725 </proxyService>
726
727 <!--Resolving System.Collections.Generic.IList<System.Int32> will return the same value as resolving
728 System.Collections.Generic.List<System.Int32>-->
729 <proxyService type="System.Collections.Generic.IList[System.Int32]">
730 <serviceToProxy typeRef="ListOfInt"/>
731 </proxyService>
732
733 <!--
734 Demo of classMember element to use static or non-static variables, properties and result of a call to parameterless
735 method to generate value used in configuration file.
736 NOTE: For more comprehensive examples for classMember element and "_classMember:" prefix in attributes in "if" elements in
737 autoService element, look at file IoCConfiguration_classMember.xml and tests in folder ClassMember.
738 -->
739 <service type="System.Collections.Generic.IReadOnlyList[IoC.Configuration.Tests.ClassMember.Services.IAppInfo]">
740 <valueImplementation scope="singleton">
741 <collection>
742 <constructedValue type="IoC.Configuration.Tests.ClassMember.Services.AppInfo">
743 <parameters>
744 <!--We inject the constant value IoC.Configuration.Tests.ClassMember.Services.ConstAndStaticAppIds.AppId1
745 into constructor of AppInfo for parameter appId.
746 We can also use non constant static variables, as well as static properties and parameterless methods.
747 -->
748 <classMember name="appId"
749 class="IoC.Configuration.Tests.ClassMember.Services.ConstAndStaticAppIds"
750 memberName="AppId1"/>
751 </parameters>
752 </constructedValue>
753 <constructedValue type="IoC.Configuration.Tests.ClassMember.Services.AppInfo">
754 <injectedProperties>
755 <!--Since SharedServices.Implementations.SelfBoundService1.IntValue is a non-static property,
756 an instance of SharedServices.Implementations.SelfBoundService1 will be resolved from the DI container,
757 and the value of IntValue of resolved instance will be injected into property AppInfo.AppId.
758 Note, we can also use parameterless methods.
759 Also, if the class in class attribute is non-interface, non-abstract, and has a public constructor,
760 IoC.Configuration will generated a binding for that class, if one is not specified in configuration file
761 or IoC.Configuration modules.
762 -->
763 <classMember name="AppId" class="SharedServices.Implementations.SelfBoundService1"
764 memberName="IntValue"/>
765 </injectedProperties>
766 </constructedValue>
767
768 <constructedValue type="IoC.Configuration.Tests.ClassMember.Services.AppInfo">
769 <parameters>
770 <!--The enum value IoC.Configuration.Tests.ClassMember.Services.AppTypes.App1 is injected into constructor of
771 AppInfo for parameter appId-->
772 <classMember name="appId"
773 class="IoC.Configuration.Tests.ClassMember.Services.AppTypes"
774 memberName="App1"/>
775 </parameters>
776 </constructedValue>
777
778 <!--
779 An example of calling a non static factory method to create an instance of IAppInfo.
780 Since method IoC.Configuration.Tests.ClassMember.Services.IAppInfoFactory.CreateAppInfo(appId, appDescription)
781 is non-static, an instance of IAppInfoFactory will be resolved using the DI container.
782 Also, since IAppInfoFactory is an interface, a binding for IAppInfoFactory should be configured in configuration
783 file or in some module.
784 -->
785 <classMember class="IoC.Configuration.Tests.ClassMember.Services.IAppInfoFactory" memberName="CreateAppInfo">
786 <parameters>
787 <int32 name="appId" value="1258"/>
788 <string name="appDescription" value="App info created with non-static method call."/>
789 </parameters>
790 </classMember>
791
792 <!--
793 An example of calling a static factory method to create an instance of IAppInfo.
794 -->
795 <classMember class="IoC.Configuration.Tests.ClassMember.Services.StaticAppInfoFactory" memberName="CreateAppInfo">
796 <parameters>
797 <int32 name="appId" value="1259"/>
798 <string name="appDescription" value="App info created with static method call."/>
799 </parameters>
800 </classMember>
801 </collection>
802 </valueImplementation>
803 </service>
804
805 <service type="IoC.Configuration.Tests.ClassMember.Services.IAppInfoFactory">
806 <implementation type="IoC.Configuration.Tests.ClassMember.Services.AppInfoFactory" scope="singleton"/>
807 </service>
808
809
810 </services>
811
812 <autoGeneratedServices>
813 <!--NOTE: For more comprehensive examples for autoService element, look at
814 file IoCConfiguration_autoService.xml and tests in folder AautoService.-->
815
816 <!--The scope for autoService implementations is always singleton -->
817 <autoService interfaceRef="IProjectGuids" >
818
819 <!--Note, since property Project1 in IoC.Configuration.Tests.AutoService.Services.IProjectGuids has
820 a setter, the implementation will implement the setter as well.-->
821 <autoProperty name="Project1" returnTypeRef="Guid">
822 <object typeRef="Guid" value="966FE6A6-76AC-4895-84B2-47E27E58FD02"/>
823 </autoProperty>
824
825 <autoProperty name="Project2" returnTypeRef="Guid">
826 <object typeRef="Guid" value="AC4EE351-CE69-4F89-A362-F833489FD9A1"/>
827 </autoProperty>
828
829 <autoMethod name="GetDefaultProject" returnTypeRef="Guid">
830 <!--No methodSignature is required, since the method does not have any parameters.-->
831 <default>
832 <!--TODO: change the returned value to classMember which references IProjectGuids.Project1 -->
833 <object typeRef="Guid" value="1E08071B-D02C-4830-AE3C-C9E78A29EA37"/>
834
835 </default>
836 </autoMethod>
837
838 <!---IoC.Configuration.Tests.AutoService.Services.IProjectGuids also has a method NotImplementedMethod()
839 which will be auto-implemented as well.-->
840 </autoService>
841
842 <!--Demo of referencing auto-implemented method parameters using parameterValue element-->
843 <autoService interface="IoC.Configuration.Tests.AutoService.Services.IAppInfoFactory">
844 <autoMethod name="CreateAppInfo" returnType="IoC.Configuration.Tests.AutoService.Services.IAppInfo">
845 <methodSignature>
846 <int32 paramName="appId"/>
847 <string paramName="appDescription"/>
848 </methodSignature>
849
850 <default>
851 <constructedValue type="IoC.Configuration.Tests.AutoService.Services.AppInfo">
852 <parameters>
853 <!--The value of name attribute is the name of constructor parameter in AppInfo-->
854 <!--
855 The value of paramName attribute is the name of parameter in IAppInfoFactory.CreateAppInfo.
856 This parameter should be present under autoMethod/methodSignature element.
857 -->
858 <!--In this example the values of name and paramName are similar, however they don't
859 have to be.-->
860 <parameterValue name="appId" paramName="appId" />
861 <parameterValue name="appDescription" paramName="appDescription" />
862 </parameters>
863 </constructedValue>
864 </default>
865 </autoMethod>
866 </autoService>
867
868 <!--The scope for autoService implementations is always singleton -->
869 <autoService interface="IoC.Configuration.Tests.AutoService.Services.IActionValidatorFactory">
870
871 <autoProperty name="DefaultActionValidator" returnType="SharedServices.Interfaces.IActionValidator">
872 <injectedObject type="IoC.Configuration.Tests.AutoService.Services.ActionValidatorDefault"/>
873 </autoProperty>
874
875 <autoProperty name="PublicProjectId" returnType="System.Guid" >
876 <object type="System.Guid" value="95E352DD-5C79-49D0-BD51-D62153570B61"/>
877 </autoProperty>
878
879 <autoMethod name="GetValidators"
880 returnType="System.Collections.Generic.IReadOnlyList[SharedServices.Interfaces.IActionValidator]"
881 reuseValue="true">
882
883 <methodSignature>
884 <!--paramName attribute is optional, however it makes the auto-implementation more readable. -->
885 <object paramName="actionType" typeRef="ActionTypes"/>
886 <object paramName="projectGuid" type="System.Guid"/>
887 </methodSignature>
888
889 <!--Parameter actionType (parameter1) value: In this example we use class member ViewFilesList (enum value) in enumeration
890 SharedServices.DataContracts.ActionTypes. Note, we use alias ActionTypes to reference the enum type declared in typeDefinitions section.
891 -->
892 <!--Parameter projectGuid (parameter2) value: The string "F79C3F23-C63F-4EB0-A513-7A8772A82B35" will be de-serialized to a System.Guid value,
893 using the default OROptimizer.Serializer.TypeBasedSimpleSerializerGuid serializer. More serializers can be provided in section
894 parameterSerializers-->
895 <if parameter1="_classMember:ActionTypes.ViewFilesList" parameter2="8663708F-C707-47E1-AEDC-2CD9291AD4CB">
896 <collection>
897 <constructedValue type="SharedServices.Implementations.ActionValidator3">
898 <parameters>
899 <int32 name="intParam" value="7"/>
900 </parameters>
901 </constructedValue>
902
903 <!--Constructor of ActionValidatorWithDependencyOnActionValidatorFactory has a parameter of type
904 IoC.Configuration.Tests.AutoService.Services.IActionValidatorFactory. Therefore an instance of auto-generated service IActionValidatorFactory
905 will be injected.
906 -->
907 <injectedObject type="IoC.Configuration.Tests.AutoService.Services.ActionValidatorWithDependencyOnActionValidatorFactory"/>
908
909 <constructedValue type=" IoC.Configuration.Tests.AutoService.Services.ActionValidator1" >
910 <parameters>
911 <injectedObject name="param1" typeRef="AutoService_IInterface1" />
912 </parameters>
913 <injectedProperties>
914 <!-- Note, we could have used constructedValue element to inject a constructed value into property
915 ActionValidator1.Property2. However, to keep the example simple, injectedObject was used -->
916 <injectedObject name="Property2" type="IoC.Configuration.Tests.AutoService.Services.IInterface2" />
917 </injectedProperties>
918 </constructedValue>
919
920 <injectedObject type="TestPluginAssembly1.Implementations.Plugin1ActionValidator"/>
921
922 <classMember class="IoC.Configuration.Tests.AutoService.Services.StaticAndConstMembers" memberName="ActionValidator1" />
923
924 <!--Since DefaultActionValidator property in IoC.Configuration.Tests.AutoService.Services.IActionValidatorValuesProvider interface is
925 not static, IoC.Configuration.Tests.AutoService.Services.IActionValidatorValuesProvider will be injected.
926 Therefore, a binding should be setup for this class (or the interface should be auto-implemented
927 using autoService element)
928 -->
929 <classMember class="IoC.Configuration.Tests.AutoService.Services.IActionValidatorValuesProvider"
930 memberName="DefaultActionValidator"/>
931
932 <!--Since Plugin3 is disabled, Plugin3ActionValidator will be ignored -->
933 <injectedObject type="TestPluginAssembly3.Implementations.Plugin3ActionValidator"/>
934 </collection>
935 </if>
936
937 <!--Parameter actionType (parameter1) value: In this example we use full class path for
938 SharedServices.DataContracts.ActionTypes in parameter1, instead of referencing a type declared in typeDefinitions element.
939 -->
940 <!--Parameter projectGuid (parameter2) value: In this case we reference the Project1Guid setting value in settings section, instead
941 of using a Guid string-->
942 <if parameter1="_classMember:ActionTypes.ViewFileContents" parameter2="_settings:Project1Guid">
943 <collection>
944 <!--Since IoC.Configuration.Tests.AutoService.Services.ActionValidator1 and SharedServices.Implementations.ActionValidator2 are
945 concrete (non-interface and non-abstract) classes), and have public constructors,
946 self bound service bindings for these classes will be automatically added, if binding for these classes are not specified
947 in configuration file or in some module of type IoC.Configuration.DiContainer.IDiModule -->
948
949 <injectedObject type="IoC.Configuration.Tests.AutoService.Services.ActionValidator1" />
950
951 <!--Since GetViewOnlyActionvalidator() method in IoC.Configuration.Tests.AutoService.Services.IActionValidatorValuesProvider
952 interface is not static, IoC.Configuration.Tests.AutoService.Services.IActionValidatorValuesProvider will be injected.
953 Therefore, a binding should be setup for this class (or the interface should be auto-implemented using
954 autoService element).
955 -->
956 <classMember class="IoC.Configuration.Tests.AutoService.Services.IActionValidatorValuesProvider"
957 memberName="GetViewOnlyActionvalidator"/>
958 </collection>
959 </if>
960
961 <!--Parameter actionType (parameter1) value: In this case we use constant value DefaultActionType declared in
962 class IoC.Configuration.Tests.AutoService.Services.StaticAndConstMembers.
963 -->
964 <!--Parameter projectGuid (parameter2) value: In this case we use the value of property Project1 in
965 IoC.Configuration.Tests.AutoService.Services.IProjectGuids. Since the property Project1 is not static,
966 class IoC.Configuration.Tests.AutoService.Services.IProjectGuids will be injected.
967 -->
968 <if parameter1="_classMember:IoC.Configuration.Tests.AutoService.Services.StaticAndConstMembers.DefaultActionType"
969 parameter2="_classMember:IProjectGuids.Project1">
970 <collection>
971 <!--Lets assume no validators are needed for this case-->
972 </collection>
973 </if>
974
975 <!--Parameter actionType (parameter1) value: In this case we use enum value
976 SharedServices.DataContracts.ActionTypes.ViewFileContents. We use a shortcut (an alias) ActionTypes to reference a
977 reference the class SharedServices.DataContracts.ActionTypes declared in typeDefintions section.
978 -->
979 <!--Parameter projectGuid (parameter2) value: In this case we use the value returned by a call to static method
980 GetDefaultProjectGuid() in class IoC.Configuration.Tests.AutoService.Services.StaticAndConstMembers.
981 -->
982 <if parameter1="_classMember:ActionTypes.ViewFileContents"
983 parameter2="_classMember:IoC.Configuration.Tests.AutoService.Services.StaticAndConstMembers.GetDefaultProjectGuid">
984
985 <!--Continue here.-->
986 <collection>
987 <!--Since IoC.Configuration.Tests.AutoService.Services.ActionValidator1 and SharedServices.Implementations.ActionValidator2 are
988 concrete (non-interface and non-abstract classes), and have public constructors,
989 self bound service bindings for these classes will be automatically added, if binding for these classes
990 are not specified in configuration file or in some module of type IoC.Configuration.DiContainer.IDiModule -->
991
992 <injectedObject type="SharedServices.Implementations.ActionValidator2" />
993 <injectedObject type="IoC.Configuration.Tests.AutoService.Services.ActionValidator1" />
994 </collection>
995 </if>
996
997 <!--Note parameter2 references PublicProjectId property in this
998 auto-generated IoC.Configuration.Tests.AutoService.Services.IActionValidatorFactory service. -->
999 <if parameter1="_classMember:ActionTypes.ViewFilesList"
1000 parameter2="_classMember:IoC.Configuration.Tests.AutoService.Services.IActionValidatorFactory.PublicProjectId">
1001 <collection>
1002 <!--Note, we can reference a property in this auto-generated
1003 IoC.Configuration.Tests.AutoService.Services.IActionValidatorFactory service.-->
1004 <classMember class="IoC.Configuration.Tests.AutoService.Services.IActionValidatorFactory" memberName="DefaultActionValidator"/>
1005 </collection>
1006
1007 </if>
1008
1009 <!--if none of conditions above are true, the default value will be returned by interface implementation.-->
1010 <default>
1011 <collection>
1012 <!--We can also call a method or property in auto-generated interface, or in one of its base interfaces.-->
1013 <classMember class="IoC.Configuration.Tests.AutoService.Services.IActionValidatorFactory" memberName="DefaultActionValidator"/>
1014 <injectedObject type="SharedServices.Implementations.ActionValidator3" />
1015 <injectedObject type="DynamicallyLoadedAssembly2.ActionValidator4"/>
1016 </collection>
1017 </default>
1018 </autoMethod>
1019
1020 <!--Overloaded method GetValidators uses parameters of types System.Int2 and System.string, instead of
1021 SharedServices.DataContracts.ActionTypes and System.Guid, as in case above.-->
1022 <autoMethod name="GetValidators"
1023 returnType="System.Collections.Generic.IReadOnlyList[SharedServices.Interfaces.IActionValidator]">
1024 <methodSignature>
1025 <!--paramName attribute is optional, however it makes the auto-implementation more readable. -->
1026 <int32 paramName="actionTypeId"/>
1027 <string paramName="projectGuid" />
1028 </methodSignature>
1029
1030 <!-- Attributes parameter1 and parameter2 map values of parameters param1 and param2 in GetInstances() method to returned values. -->
1031 <if parameter1="0" parameter2="8663708F-C707-47E1-AEDC-2CD9291AD4CB">
1032 <collection>
1033 <injectedObject type="SharedServices.Implementations.ActionValidator3" />
1034 <injectedObject type="IoC.Configuration.Tests.AutoService.Services.ActionValidator4" />
1035 </collection>
1036 </if>
1037
1038 <default>
1039 <collection>
1040 <!--We can also call a method or property in auto-generated interface, or in one of its base interfaces.-->
1041 <classMember class="IoC.Configuration.Tests.AutoService.Services.IActionValidatorFactory"
1042 memberName="DefaultActionValidator"/>
1043 <injectedObject type="SharedServices.Implementations.ActionValidator3" />
1044 <classMember class="IoC.Configuration.Tests.AutoService.Services.StaticAndConstMembers"
1045 memberName="GetDefaultActionValidator" />
1046 <classMember class="IoC.Configuration.Tests.AutoService.Services.IActionValidatorValuesProvider"
1047 memberName="AdminLevelActionValidator"/>
1048 </collection>
1049 </default>
1050 </autoMethod>
1051
1052 <!--Note, interface IoC.Configuration.Tests.AutoService.Services.IActionValidatorFactory also has a method
1053 void SomeMethodThatWillNotBeImplemented(int param1, string param2) and a property int SomeUnImplementedProperty { get; },'
1054 we chose not to implement in configuration file. Unimplemented methods and properties will be auto-implemented to return default values,
1055 based on return type defaults.
1056 -->
1057 </autoService>
1058
1059 <!--IMemberAmbiguityDemo demonstrates cases when there are multiple occurrences
1060 of auto-generated methods and properties with same signatures and return types
1061 in IMemberAmbiguityDemo and its base interfaces.
1062 -->
1063 <autoService interface="IoC.Configuration.Tests.AutoService.Services.IMemberAmbiguityDemo">
1064 <!--GetIntValues(): IReadOnlyList<int> GetIntValues(int param1, string param2)-->
1065 <autoMethod name="GetIntValues" returnType="System.Collections.Generic.IReadOnlyList[System.Int32]" >
1066 <methodSignature>
1067 <int32 paramName="param1"/>
1068 <string paramName="param2"/>
1069 </methodSignature>
1070 <if parameter1="1" parameter2="str1">
1071 <collection>
1072 <int32 value="17"/>
1073 </collection>
1074 </if>
1075 <default>
1076 <collection>
1077 <int32 value="18"/>
1078 <int32 value="19"/>
1079 </collection>
1080 </default>
1081 </autoMethod>
1082
1083 <!--
1084 This method is declared in IMemberAmbiguityDemo_Parent3, which is a base interface for IMemberAmbiguityDemo.
1085 We can provide implementation for this interface, even though it has a similar signature and return type as the method
1086 method IoC.Configuration.Tests.AutoService.Services.IMemberAmbiguityDemo.GetIntValues.
1087 By using the attribute 'declaringInterface', we make a distinction between these two.
1088 -->
1089 <autoMethod name="GetIntValues" returnType="System.Collections.Generic.IReadOnlyList[System.Int32]"
1090 declaringInterface="IoC.Configuration.Tests.AutoService.Services.IMemberAmbiguityDemo_Parent3">
1091 <methodSignature>
1092 <int32 paramName="param1"/>
1093 <string paramName="param2"/>
1094 </methodSignature>
1095 <default>
1096 <collection>
1097 <int32 value="3"/>
1098 </collection>
1099 </default>
1100 </autoMethod>
1101
1102 <!---
1103 The method GetDbConnection(System.Guid appGuid) that return IDbConnection is in two base interfaces
1104 of IMemberAmbiguityDemo: in IoC.Configuration.Tests.AutoService.Services.IMemberAmbiguityDemo_Parent1 and in
1105 IoC.Configuration.Tests.AutoService.Services.IMemberAmbiguityDemo_Parent2.
1106 Therefore, to avoid ambiguity, we have to specify the declaring interface in attribute 'declaringInterface'.
1107 We can specify an implementation for IoC.Configuration.Tests.AutoService.Services.IMemberAmbiguityDemo_Parent2.GetDbConnection(),
1108 and IoC.Configuration will generate a similar auto-implementation for the similar method in IMemberAmbiguityDemo_Parent1
1109 as well.
1110 -->
1111 <autoMethod name="GetDbConnection" returnType="SharedServices.Interfaces.IDbConnection"
1112 declaringInterface="IoC.Configuration.Tests.AutoService.Services.IMemberAmbiguityDemo_Parent2">
1113 <methodSignature>
1114 <object paramName="appGuid" type="System.Guid"/>
1115 </methodSignature>
1116 <default>
1117 <constructedValue type="SharedServices.Implementations.SqliteDbConnection">
1118 <parameters>
1119 <string name="filePath" value="c:\mySqliteDatabase.sqlite"/>
1120 </parameters>
1121 </constructedValue>
1122 </default>
1123 </autoMethod>
1124
1125 <!--
1126 Both IMemberAmbiguityDemo_Parent1 and IMemberAmbiguityDemo_Parent2 have properties called DefaultDbConnection
1127 with the same return types. We can auto-implement this property for each of these interfaces by using
1128 declaringInterface attribute in autoProperty element to explicitly specify the interface that own
1129 the property (declaringInterface can be used in autoMethod as well as demonstrated above)
1130 -->
1131 <!--Auto-implementation of IMemberAmbiguityDemo_Parent1.DefaultDbConnection-->
1132 <autoProperty name="DefaultDbConnection" returnType="SharedServices.Interfaces.IDbConnection"
1133 declaringInterface="IoC.Configuration.Tests.AutoService.Services.IMemberAmbiguityDemo_Parent1">
1134 <constructedValue type="SharedServices.Implementations.SqliteDbConnection">
1135 <parameters>
1136 <string name="filePath" value="c:\IMemberAmbiguityDemo_Parent1_Db.sqlite"/>
1137 </parameters>
1138 </constructedValue>
1139 </autoProperty>
1140
1141 <!--Auto-implementation of IMemberAmbiguityDemo_Parent2.DefaultDbConnection-->
1142 <autoProperty name="DefaultDbConnection" returnType="SharedServices.Interfaces.IDbConnection"
1143 declaringInterface="IoC.Configuration.Tests.AutoService.Services.IMemberAmbiguityDemo_Parent2">
1144 <constructedValue type="SharedServices.Implementations.SqliteDbConnection">
1145 <parameters>
1146 <string name="filePath" value="c:\IMemberAmbiguityDemo_Parent2_Db.sqlite"/>
1147 </parameters>
1148 </constructedValue>
1149 </autoProperty>
1150
1151 <!--
1152 Method GetNumericValue() occurs in both IoC.Configuration.Tests.AutoService.Services.IMemberAmbiguityDemo_Parent2
1153 and IoC.Configuration.Tests.AutoService.Services.IMemberAmbiguityDemo_Parent1_Parent. However, since the return types
1154 are different (System.Double in IMemberAmbiguityDemo_Parent2, and System.Int32 in IMemberAmbiguityDemo_Parent1_Parent),
1155 we can auto-implement both them, without using attribute 'declaringInterface' to separate these two implementation.
1156 -->
1157 <!--IMemberAmbiguityDemo_Parent2.GetNumericValue() with return type of System.Double-->
1158 <autoMethod name="GetNumericValue" returnType="System.Double" >
1159 <default>
1160 <double value="17.3"/>
1161 </default>
1162 </autoMethod>
1163
1164 <!--IMemberAmbiguityDemo_Parent1_Parent.GetNumericValue() with return type of System.Int32-->
1165 <autoMethod name="GetNumericValue" returnType="System.Int32" >
1166 <default>
1167 <int32 value="19"/>
1168 </default>
1169 </autoMethod>
1170
1171 <!--
1172 Property NumericValue occurs in both IoC.Configuration.Tests.AutoService.Services.IMemberAmbiguityDemo_Parent1
1173 and IoC.Configuration.Tests.AutoService.Services.IMemberAmbiguityDemo_Parent2. However, since the return types
1174 are different (System.Double in IMemberAmbiguityDemo_Parent1, and System.Int32 in IMemberAmbiguityDemo_Parent2),
1175 we can auto-implement both them, without using attribute 'declaringInterface' to separate these two implementation.
1176 -->
1177 <!--IMemberAmbiguityDemo_Parent1.NumericValue with return type of System.Double-->
1178 <autoProperty name="NumericValue" returnType="System.Double" >
1179 <double value="18.2"/>
1180 </autoProperty>
1181
1182 <!--IMemberAmbiguityDemo_Parent2.NumericValue with return type of System.Int32-->
1183 <autoProperty name="NumericValue" returnType="System.Int32" >
1184 <int32 value="14"/>
1185 </autoProperty>
1186
1187 <!---Auto-implementing Method with optional parameters:
1188 int MethodWithOptionalParameters(int param1, double param2 = 3.5, int param3=7); -->
1189 <autoMethod name="MethodWithOptionalParameters" returnType="System.Int32">
1190 <methodSignature>
1191 <int32 paramName="param1"/>
1192 <double paramName="param2"/>
1193 <int32 paramName="param3"/>
1194 </methodSignature>
1195 <if parameter1="3" parameter2="3.5" parameter3="7">
1196 <int32 value="17"/>
1197 </if>
1198 <default>
1199 <int32 value="18"/>
1200 </default>
1201 </autoMethod>
1202 </autoService>
1203
1204 <!--Interface specified in autoServiceCustom is auto-implemented by implementation of
1205 IoC.Configuration.ConfigurationFile.ICustomAutoServiceCodeGenerator IoC.Configuration.Tests.AutoServiceCustom.SimpleDataRepository.RepositoryInterfaceImplementationGenerator
1206 that is specified in autoServiceCodeGenerator element.-->
1207 <autoServiceCustom interface="IoC.Configuration.Tests.AutoServiceCustom.SimpleDataRepository.DataRepositories.IAuthorsRepository">
1208 <autoServiceCodeGenerator>
1209 <constructedValue type="IoC.Configuration.Tests.AutoServiceCustom.SimpleDataRepository.RepositoryInterfaceImplementationGenerator">
1210 <parameters>
1211 <int32 name="someDemoConstructorParameter" value="15" />
1212 </parameters>
1213 </constructedValue>
1214 </autoServiceCodeGenerator>
1215 </autoServiceCustom>
1216
1217 <autoServiceCustom interface="IoC.Configuration.Tests.AutoServiceCustom.SimpleDataRepository.DataRepositories.IBooksRepository">
1218 <autoServiceCodeGenerator>
1219 <constructedValue type="IoC.Configuration.Tests.AutoServiceCustom.SimpleDataRepository.RepositoryInterfaceImplementationGenerator">
1220 <parameters>
1221 <int32 name="someDemoConstructorParameter" value="25" />
1222 </parameters>
1223 </constructedValue>
1224 </autoServiceCodeGenerator>
1225 </autoServiceCustom>
1226
1227 <autoServiceCustom interface="IoC.Configuration.Tests.AutoServiceCustom.SimpleDataRepository.DataRepositories.IAuthorBooksRepository">
1228 <autoServiceCodeGenerator>
1229 <constructedValue type="IoC.Configuration.Tests.AutoServiceCustom.SimpleDataRepository.RepositoryInterfaceImplementationGenerator">
1230 <parameters>
1231 <int32 name="someDemoConstructorParameter" value="35" />
1232 </parameters>
1233 </constructedValue>
1234 </autoServiceCodeGenerator>
1235 </autoServiceCustom>
1236 </autoGeneratedServices>
1237 </dependencyInjection>
1238
1239 <startupActions>
1240 <startupAction type="DynamicallyLoadedAssembly1.Implementations.StartupAction1">
1241 <!--Use parameters element to specify constructor parameters if necessary.-->
1242 <!--<parameters></parameters>-->
1243 <!--Use injectedProperties element to inject properties into startup action if necessary.-->
1244 <!--<injectedProperties></injectedProperties>-->
1245 </startupAction>
1246 <startupAction type="DynamicallyLoadedAssembly1.Implementations.StartupAction2">
1247 </startupAction>
1248 </startupActions>
1249
1250 <pluginsSetup>
1251 <pluginSetup plugin="Plugin1">
1252 <!--The type in pluginImplementation should be non-abstract class
1253 that implements IoC.Configuration.IPlugin and which has a public constructor-->
1254 <pluginImplementation type="TestPluginAssembly1.Implementations.Plugin1">
1255 <parameters>
1256 <int64 name="param1" value="25" />
1257 </parameters>
1258 <injectedProperties>
1259 <int64 name="Property2" value="35"/>
1260 </injectedProperties>
1261 </pluginImplementation>
1262 <settings>
1263 <int32 name="Int32Setting1" value="25" />
1264 <int64 name="Int64Setting1" value="38" />
1265 <string name="StringSetting1" value="String Value 1" />
1266 </settings>
1267
1268 <webApi>
1269 <controllerAssemblies>
1270 <!--
1271 Specify assemblies with API controllers.
1272 The user of IoC.Configuration should add the assemblies to MVC using
1273 IMvcBuilder.AddApplicationPart(System.Reflection.Assembly)
1274 -->
1275 <controllerAssembly assembly="pluginassm1" />
1276 <controllerAssembly assembly="plugin1api" />
1277 </controllerAssemblies>
1278 </webApi>
1279 <dependencyInjection>
1280 <modules>
1281 <module type="ModulesForPlugin1.Ninject.NinjectModule1">
1282 <parameters>
1283 <int32 name="param1" value="101" />
1284 </parameters>
1285 </module>
1286
1287 <module type="ModulesForPlugin1.Autofac.AutofacModule1" >
1288 <parameters>
1289 <int32 name="param1" value="102" />
1290 </parameters>
1291 </module>
1292
1293 <module type="ModulesForPlugin1.IoC.DiModule1" >
1294 <parameters>
1295 <int32 name="param1" value="103" />
1296 </parameters>
1297 </module>
1298 </modules>
1299 <services>
1300 <service type="TestPluginAssembly1.Interfaces.IDoor">
1301 <implementation type="TestPluginAssembly1.Implementations.Door"
1302 scope="transient">
1303 <parameters>
1304 <int32 name="Color" value="3" />
1305 <double name="Height" value="180" />
1306 </parameters>
1307 </implementation>
1308 </service>
1309 <service type="TestPluginAssembly1.Interfaces.IRoom">
1310 <implementation type="TestPluginAssembly1.Implementations.Room"
1311 scope="transient">
1312 <parameters>
1313 <object name="door1" type="TestPluginAssembly1.Interfaces.IDoor"
1314 value="5,185.1" />
1315 <injectedObject name="door2" type="TestPluginAssembly1.Interfaces.IDoor" />
1316 </parameters>
1317 <injectedProperties>
1318 <object name="Door2" type="TestPluginAssembly1.Interfaces.IDoor"
1319 value="7,187.3" />
1320 </injectedProperties>
1321 </implementation>
1322 </service>
1323 </services>
1324 <autoGeneratedServices>
1325 <!--The scope for autoService implementations is always singleton -->
1326 <autoService interface="TestPluginAssembly1.Interfaces.IResourceAccessValidatorFactory">
1327 <autoMethod name="GetValidators"
1328 returnType="System.Collections.Generic.IEnumerable[TestPluginAssembly1.Interfaces.IResourceAccessValidator]"
1329 reuseValue="true" >
1330 <methodSignature>
1331 <string paramName="resourceName"/>
1332 </methodSignature>
1333 <if parameter1="public_pages">
1334 <collection>
1335 <injectedObject type="TestPluginAssembly1.Interfaces.ResourceAccessValidator1"/>
1336 </collection>
1337
1338 </if>
1339 <if parameter1="admin_pages">
1340 <collection>
1341 <injectedObject type="TestPluginAssembly1.Interfaces.ResourceAccessValidator1"/>
1342 <injectedObject type="TestPluginAssembly1.Interfaces.ResourceAccessValidator2"/>
1343 </collection>
1344 </if>
1345 <default>
1346 <collection>
1347 <injectedObject type="TestPluginAssembly1.Interfaces.ResourceAccessValidator2"/>
1348 <injectedObject type="TestPluginAssembly1.Interfaces.ResourceAccessValidator1"/>
1349 </collection>
1350 </default>
1351 </autoMethod>
1352 </autoService>
1353 </autoGeneratedServices>
1354 </dependencyInjection>
1355 </pluginSetup>
1356
1357 <pluginSetup plugin="Plugin2">
1358 <pluginImplementation type="TestPluginAssembly2.Implementations.Plugin2">
1359 <parameters>
1360 <boolean name="param1" value="true" />
1361 <double name="param2" value="25.3" />
1362 <string name="param3" value="String value" />
1363 </parameters>
1364 <injectedProperties>
1365 <double name="Property2" value="5.3" />
1366 </injectedProperties>
1367 </pluginImplementation>
1368 <settings>
1369 </settings>
1370
1371 <dependencyInjection>
1372 <modules>
1373 </modules>
1374 <services>
1375 <service type="TestPluginAssembly2.Interfaces.IWheel">
1376 <implementation type="TestPluginAssembly2.Implementations.Wheel"
1377 scope="transient">
1378 <parameters>
1379 <int32 name="Color" value="5" />
1380 <double name="Height" value="48" />
1381 </parameters>
1382 </implementation>
1383 </service>
1384 <service type="TestPluginAssembly2.Interfaces.ICar">
1385 <implementation type="TestPluginAssembly2.Implementations.Car"
1386 scope="transient">
1387 <parameters>
1388 <object name="wheel1" type="TestPluginAssembly2.Interfaces.IWheel" value="248,40" />
1389 </parameters>
1390 <injectedProperties>
1391 <object name="Wheel1" type="TestPluginAssembly2.Interfaces.IWheel" value="27,45" />
1392 <injectedObject name="Wheel2" type="TestPluginAssembly2.Interfaces.IWheel"/>
1393 </injectedProperties>
1394 </implementation>
1395 </service>
1396 </services>
1397 <autoGeneratedServices>
1398
1399 </autoGeneratedServices>
1400 </dependencyInjection>
1401 </pluginSetup>
1402
1403 <pluginSetup plugin="Plugin3">
1404 <pluginImplementation type="TestPluginAssembly3.Implementations.Plugin3">
1405 </pluginImplementation>
1406 <settings></settings>
1407 <webApi>
1408 <controllerAssemblies>
1409 <!--
1410 Specify assemblies with API controllers.
1411 The user of IoC.Configuration should add the assemblies to MVC using
1412 IMvcBuilder.AddApplicationPart(System.Reflection.Assembly)
1413 -->
1414 <controllerAssembly assembly="pluginassm3" />
1415 </controllerAssemblies>
1416 </webApi>
1417 <dependencyInjection>
1418 <modules>
1419 </modules>
1420 <services>
1421 </services>
1422 <autoGeneratedServices>
1423 </autoGeneratedServices>
1424 </dependencyInjection>
1425 </pluginSetup>
1426 </pluginsSetup>
1427</iocConfiguration>