IoCConfiguration_collection.xml

This configuration file can be downloaded downloaded from IoCConfiguration_collection.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_CollectionTests" />
 29
 30  <plugins pluginsDirPath="TestFiles\PluginDlls">
 31
 32    <!--
 33        Plugin assemblies will be in a folder with similar name under pluginsDirPath folder.
 34        The plugin folders will be included in assembly resolution mechanism.
 35        -->
 36
 37    <!--A folder K:\...\IoC.Configuration\Tests\IoC.Configuration.Tests\bin\TestFiles\PluginDlls\Plugin1 should exist.  -->
 38    <plugin name="Plugin1" />
 39    <plugin name="Plugin2" />
 40    <plugin name="Plugin3" enabled="false" />
 41  </plugins>
 42
 43  <additionalAssemblyProbingPaths>
 44    <probingPath
 45      path="TestFiles\ThirdPartyLibs" />
 46    <probingPath
 47      path="TestFiles\ContainerImplementations\Autofac" />
 48    <probingPath
 49      path="TestFiles\ContainerImplementations\Ninject" />
 50    <probingPath
 51      path="TestFiles\DynamicallyLoadedDlls" />
 52  </additionalAssemblyProbingPaths>
 53
 54  <assemblies>
 55    <!--Assemblies should be in one of the following locations:
 56        1) Executable's folder
 57        2) In folder specified in additionalAssemblyProbingPaths element.
 58        3) In one of the plugin folders specified in plugins element (only for assemblies with plugin attribute) -->
 59
 60    <!--
 61    Use "overrideDirectory" attribute, to make the assembly path explicit, rather then searching for
 62    an assembly in predefined folders, which also include probing paths specified in additionalAssemblyProbingPaths element.
 63    -->
 64    <assembly name="IoC.Configuration.Autofac" alias="autofac_ext" />
 65    <assembly name="IoC.Configuration.Ninject" alias="ninject_ext" />
 66
 67    <assembly name="TestProjects.Modules" alias="modules" />
 68
 69    <assembly name="TestProjects.DynamicallyLoadedAssembly1"
 70              alias="dynamic1" />
 71
 72    <assembly name="TestProjects.DynamicallyLoadedAssembly2"
 73              alias="dynamic2" />
 74
 75    <assembly name="TestProjects.TestPluginAssembly1"
 76              alias="pluginassm1" plugin="Plugin1" />
 77
 78    <assembly name="TestProjects.ModulesForPlugin1"
 79              alias="modules_plugin1" plugin="Plugin1" />
 80
 81    <assembly name="TestProjects.TestPluginAssembly2"
 82              alias="pluginassm2" plugin="Plugin2" />
 83
 84    <assembly name="TestProjects.TestPluginAssembly3"
 85              alias="pluginassm3" plugin="Plugin3" />
 86
 87    <assembly name="TestProjects.SharedServices" alias="shared_services" />
 88
 89    <assembly name="IoC.Configuration.Tests" alias="tests" />
 90
 91    <assembly name="System.Threading.Tasks.Extensions" alias="threading_tasks_extensions" />
 92  </assemblies>
 93
 94  <typeDefinitions>
 95    <typeDefinition alias="IInterface1" type="SharedServices.Interfaces.IInterface1"></typeDefinition>
 96    <typeDefinition alias="Interface1_Impl" type="IoC.Configuration.Tests.Collection.Services.Interface1_Impl"></typeDefinition>
 97  </typeDefinitions>
 98  <parameterSerializers>
 99    <!--
100        Use parameters element to specify constructor parameters, if the type specified in 'serializerAggregatorType' attribute
101        has non-default constructor.
102        -->
103    <!--<parameters>
104        </parameters>-->
105    <serializers></serializers>
106  </parameterSerializers>
107
108  <!--The value of type attribute should be a type that implements
109    IoC.Configuration.DiContainer.IDiManager-->
110  <diManagers activeDiManagerName="Autofac">
111    <diManager name="Ninject" type="IoC.Configuration.Ninject.NinjectDiManager"
112               assembly="ninject_ext">
113      <!--
114            Use parameters element to specify constructor parameters,
115            if the type specified in 'type' attribute has non-default constructor.
116            -->
117      <!--<parameters>
118      </parameters>-->
119    </diManager>
120
121    <diManager name="Autofac" type="IoC.Configuration.Autofac.AutofacDiManager"
122               assembly="autofac_ext">
123    </diManager>
124  </diManagers>
125
126  <!--
127    If settingsRequestor element is used, the type in type attribute should
128    specify a type that implements IoC.Configuration.ISettingsRequestor.
129    The implementation specifies a collection of required settings that should be present
130    in settings element.
131    Note, the type specified in type attribute is fully integrated into a dependency
132    injection framework. In other words, constructor parameters will be injected using
133    bindings specified in dependencyInjection element.
134    -->
135
136  <settings>
137    <constructedValue name="DefaultDBConnection" type="SharedServices.Implementations.SqliteDbConnection"
138                      assembly="shared_services">
139      <parameters>
140        <string name="filePath" value="c:\SQLiteFiles\MySqliteDb.sqlite"/>
141      </parameters>
142    </constructedValue>
143
144    <constructedValue name="DefaultInterface1Value" typeRef="Interface1_Impl">
145      <parameters>
146        <int32 name="param1" value="21"/>
147      </parameters>
148    </constructedValue>
149
150    <constructedValue name="Collections" type="IoC.Configuration.Tests.Collection.Services.DemoCollectionInjection">
151      <parameters>
152        <!--Demo of injecting a collection into a constructor of DemoCollectionInjection in constructedValue element-->
153        <collection name="intValues" collectionType="readOnlyList" itemType="System.Int32">
154          <int32 value="17"/>
155          <int32 value="14"/>
156        </collection>
157      </parameters>
158      <injectedProperties>
159        <!--Demo of injecting a collection into a property of DemoCollectionInjection in constructedValue element.-->
160        <collection name="Texts" collectionType="readOnlyList" itemType="System.String">
161          <string value="Microsoft"/>
162          <string value="Google"/>
163          <string value="Amazon"/>
164        </collection>
165      </injectedProperties>
166    </constructedValue>
167  </settings>
168
169  <dependencyInjection>
170    <modules>
171      <module type="IoC.Configuration.Tests.Collection.Module1">
172        <parameters>
173          <collection name="values" collectionType="enumerable" itemType="System.Int32">
174            <int32 value="5"/>
175            <int32 value="7"/>
176          </collection>
177        </parameters>
178
179      </module>
180    </modules>
181    <services>
182      <service type="SharedServices.Interfaces.IInterface1">
183        <implementation type="IoC.Configuration.Tests.Collection.Services.Interface1_Impl" scope="singleton">
184          <parameters>
185            <int32 name="param1" value="37"/>
186          </parameters>
187        </implementation>
188      </service>
189
190      <!--Demo of collection element used as an implementation for a service of collection type.-->
191      <service type="System.Collections.Generic.IReadOnlyList[SharedServices.Interfaces.IDbConnection]">
192        <valueImplementation scope="singleton">
193          <collection>
194            <settingValue settingName="DefaultDBConnection"/>
195            <constructedValue type="SharedServices.Implementations.SqlServerDbConnection">
196              <parameters>
197                <string name="serverName" value="SQLSERVER2012"/>
198                <string name="databaseName" value="DB1"/>
199                <string name="userName" value="user1"/>
200                <string name="password" value="password123"/>
201              </parameters>
202            </constructedValue>
203            <constructedValue type="SharedServices.Implementations.SqlServerDbConnection">
204              <parameters>
205                <string name="serverName" value="SQLSERVER2016"/>
206                <string name="databaseName" value="DB2"/>
207                <string name="userName" value="user2"/>
208                <string name="password" value="password456"/>
209              </parameters>
210            </constructedValue>
211
212            <!--This value will be added to collection since Plugin1 is enabled-->
213            <constructedValue type="TestPluginAssembly1.Implementations.MySqlDbConnection">
214              <parameters>
215                <string name="connectionString" value="user=User1;password=123"/>
216              </parameters>
217            </constructedValue>
218
219            <!--This value will not be added to collection since Plugin3 is disabled-->
220            <constructedValue type="TestPluginAssembly3.Implementations.OracleDbConnection" >
221              <parameters>
222                <string name="connectionString" value="user=User1;password=123"/>
223              </parameters>
224            </constructedValue>
225          </collection>
226        </valueImplementation>
227      </service>
228
229      <!--Demo of collection element used as an implementation for a service of array type.-->
230      <!--The service type below is similar to C# type IoC.Configuration.Tests.Collection.Services.TestLocalTypesClass.IInterface1[]-->
231      <service type="IoC.Configuration.Tests.Collection.Services.TestLocalTypesClass.IInterface1#">
232        <valueImplementation scope="transient">
233          <collection>
234            <constructedValue type="IoC.Configuration.Tests.Collection.Services.TestLocalTypesClass.Interface1_Impl1">
235              <parameters>
236                <int32 name="value" value="13"/>
237              </parameters>
238            </constructedValue>
239            <constructedValue type="IoC.Configuration.Tests.Collection.Services.TestLocalTypesClass.Interface1_Impl1">
240              <parameters>
241                <int32 name="value" value="17"/>
242              </parameters>
243            </constructedValue>
244          </collection>
245        </valueImplementation>
246      </service>
247
248      <selfBoundService type="IoC.Configuration.Tests.Collection.Services.CollectionsTestClass1" scope="singleton" >
249        <parameters>
250          <!--Demo of collection element used as a constructor parameter.-->
251          <collection name="readOnlyListParam" collectionType="readOnlyList" itemType="System.Int32">
252            <int32 value="17"/>
253            <int32 value="24"/>
254            <int32 value="27"/>
255          </collection>
256
257          <!--Demo of collection element used as a constructor parameter.-->
258          <collection name="arrayParam" collectionType="array" itemTypeRef="IInterface1">
259            <injectedObject typeRef="IInterface1"/>
260            <constructedValue typeRef="Interface1_Impl">
261              <parameters>
262                <int32 name="param1" value="29"/>
263              </parameters>
264            </constructedValue>
265          </collection>
266        </parameters>
267        <injectedProperties>
268          <!--Demo of collection element used to initialize the value of injected property.-->
269          <collection name="EnumerableValues" collectionType="enumerable" itemType="SharedServices.Interfaces.IInterface1" >
270            <constructedValue typeRef="Interface1_Impl">
271              <parameters>
272                <int32 name="param1" value="18"/>
273              </parameters>
274            </constructedValue>
275            <settingValue settingName="DefaultInterface1Value"/>
276            <injectedObject typeRef="IInterface1"/>
277          </collection>
278
279          <!--Demo of collection element used to initialize the value of injected property.-->
280          <collection name="ListValues" collectionType="list" itemTypeRef="IInterface1">
281            <injectedObject typeRef="IInterface1"/>
282            <settingValue settingName="DefaultInterface1Value"/>
283            <constructedValue typeRef="Interface1_Impl">
284              <parameters>
285                <int32 name="param1" value="139"/>
286              </parameters>
287            </constructedValue>
288          </collection>
289        </injectedProperties>
290      </selfBoundService>
291    </services>
292    <autoGeneratedServices>
293      <!--Demo of collection element used in auto-implemented method and property return values.-->
294      <autoService interface="IoC.Configuration.Tests.Collection.Services.IAutoService1">
295        <autoMethod name="GetAllActionIds" returnType="System.Collections.Generic.IReadOnlyList[System.Int32]">
296          <methodSignature>
297            <int32 paramName="appId"/>
298          </methodSignature>
299          <if parameter1="3">
300            <collection>
301              <int32 value="27"/>
302              <int32 value="17"/>
303            </collection>
304          </if>
305          <default>
306            <collection>
307              <int32 value="13"/>
308              <int32 value="27"/>
309              <int32 value="17"/>
310            </collection>
311          </default>
312        </autoMethod>
313      </autoService>
314    </autoGeneratedServices>
315  </dependencyInjection>
316
317  <startupActions>
318
319  </startupActions>
320
321  <pluginsSetup>
322    <pluginSetup plugin="Plugin1">
323      <!--The type in pluginImplementation should be non-abstract class
324                that implements IoC.Configuration.IPlugin and which has a public constructor-->
325      <pluginImplementation type="TestPluginAssembly1.Implementations.Plugin1_Simple">
326      </pluginImplementation>
327
328      <settings>
329        <int32 name="Int32Setting1" value="10"/>
330        <string name="StringSetting1" value="Some text"/>
331      </settings>
332
333      <dependencyInjection>
334        <modules>
335
336        </modules>
337        <services>
338
339        </services>
340        <autoGeneratedServices>
341
342        </autoGeneratedServices>
343      </dependencyInjection>
344    </pluginSetup>
345
346    <pluginSetup plugin="Plugin2">
347      <pluginImplementation type="TestPluginAssembly2.Implementations.Plugin2" assembly="pluginassm2">
348        <parameters>
349          <boolean name="param1" value="true" />
350          <double name="param2" value="25.3" />
351          <string name="param3" value="String value" />
352        </parameters>
353      </pluginImplementation>
354      <settings>
355      </settings>
356      <dependencyInjection>
357        <modules>
358        </modules>
359        <services>
360        </services>
361        <autoGeneratedServices>
362        </autoGeneratedServices>
363      </dependencyInjection>
364    </pluginSetup>
365
366    <pluginSetup plugin="Plugin3">
367      <pluginImplementation type="TestPluginAssembly3.Implementations.Plugin3" assembly="pluginassm3">
368
369      </pluginImplementation>
370      <settings>
371      </settings>
372      <dependencyInjection>
373        <modules>
374        </modules>
375        <services>
376        </services>
377        <autoGeneratedServices>
378        </autoGeneratedServices>
379      </dependencyInjection>
380    </pluginSetup>
381  </pluginsSetup>
382</iocConfiguration>