IoCConfiguration_providedValue.xml

This configuration file can be downloaded downloaded from IoCConfiguration_constructedValue.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. constructed
  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_constructedValueTests" />
 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  </plugins>
 39
 40  <additionalAssemblyProbingPaths>
 41    <probingPath
 42      path="TestFiles\ThirdPartyLibs" />
 43    <probingPath
 44      path="TestFiles\ContainerImplementations\Autofac" />
 45    <probingPath
 46      path="TestFiles\ContainerImplementations\Ninject" />
 47    <probingPath
 48      path="TestFiles\DynamicallyLoadedDlls" />
 49  </additionalAssemblyProbingPaths>
 50
 51  <assemblies>
 52    <!--Assemblies should be in one of the following locations:
 53        1) Executable's folder
 54        2) In folder specified in additionalAssemblyProbingPaths element.
 55        3) In one of the plugin folders specified in plugins element (only for assemblies with plugin attribute) -->
 56
 57    <!--
 58    Use "overrideDirectory" attribute, to make the assembly path explicit, rather then searching for
 59    an assembly in predefined folders, which also include probing paths specified in additionalAssemblyProbingPaths element.
 60    -->
 61    <assembly name="IoC.Configuration.Autofac" alias="autofac_ext" />
 62    <assembly name="IoC.Configuration.Ninject" alias="ninject_ext" />
 63
 64    <assembly name="TestProjects.Modules" alias="modules" />
 65
 66    <assembly name="TestProjects.DynamicallyLoadedAssembly1"
 67              alias="dynamic1" />
 68
 69    <assembly name="TestProjects.DynamicallyLoadedAssembly2"
 70              alias="dynamic2" />
 71
 72    <assembly name="TestProjects.SharedServices" alias="shared_services" />
 73
 74    <assembly name="IoC.Configuration.Tests" alias="tests" />
 75  </assemblies>
 76
 77  <typeDefinitions>
 78    <typeDefinition alias="IAppInfo" type="IoC.Configuration.Tests.ConstructedValue.Services.IAppInfo" />
 79    <typeDefinition alias="AppInfo" type="IoC.Configuration.Tests.ConstructedValue.Services.AppInfo" />
 80  </typeDefinitions>
 81
 82  <parameterSerializers>
 83    <serializers>
 84      <!--Serializer IoC.Configuration.Tests.ConstructedValue.Services.AppInfoSerializer will be used to de-serialize value
 85      provided in element <object> into instance of type IoC.Configuration.Tests.ConstructedValue.Services.AppInfo-->
 86      <parameterSerializer type="IoC.Configuration.Tests.ConstructedValue.Services.AppInfoSerializer">
 87        <parameters>
 88          <!--Demo of using constructedValue to inject constructor parameter value into parameter serializer.-->
 89          <constructedValue name="appDescriptionFormatter" type="IoC.Configuration.Tests.ConstructedValue.Services.AppDescriptionFormatter">
 90            <parameters>
 91              <string name="prefixToAddToDescription" value="AppData::"/>
 92            </parameters>
 93            <injectedProperties>
 94              <string name="PostfixToAddToDescription" value="::AppDataEnd"/>
 95            </injectedProperties>
 96          </constructedValue>
 97        </parameters>
 98      </parameterSerializer>
 99    </serializers>
100  </parameterSerializers>
101
102  <!--The value of type attribute should be a type that implements
103    IoC.Configuration.DiContainer.IDiManager-->
104  <diManagers activeDiManagerName="Autofac">
105    <diManager name="Ninject" type="IoC.Configuration.Ninject.NinjectDiManager"
106               assembly="ninject_ext">
107      <!--
108            Use parameters element to specify constructor parameters,
109            if the type specified in 'type' attribute has non-default constructor.
110            -->
111      <!--<parameters>
112            </parameters>-->
113    </diManager>
114
115    <diManager name="Autofac" type="IoC.Configuration.Autofac.AutofacDiManager"
116               assembly="autofac_ext">
117    </diManager>
118  </diManagers>
119
120  <!--
121    If settingsRequestor element is used, the type in type attribute should
122    specify a type that implements IoC.Configuration.ISettingsRequestor.
123    The implementation specifies a collection of required settings that should be present
124    in settings element.
125    Note, the type specified in type attribute is fully integrated into a dependency
126    injection framework. In other words, constructor parameters will be injected using
127    bindings specified in dependencyInjection element.
128    -->
129
130  <settings>
131    <object name="App1" typeRef="IAppInfo" value="1, App 1"/>
132
133    <!--Demo of constructedValue in settings element. -->
134    <constructedValue name="App2" typeRef="AppInfo" >
135      <parameters>
136        <int32 name="Id" value="2"/>
137      </parameters>
138      <injectedProperties>
139        <string name="Description" value="App 2"/>
140      </injectedProperties>
141    </constructedValue>
142
143    <!--Demo of constructedValue used as a parameter value in another constructedValue.
144    Constructing DecoratedAppInfo setting below is similar to creating an instance of AppInfoDecorator using the following C# code:
145    new AppInfoDecorator(new AppInfoDecorator(new AppInfo(25, "App 25")))
146    -->
147    <constructedValue name="DecoratedAppInfo" type="IoC.Configuration.Tests.ConstructedValue.Services.AppInfoDecorator">
148      <parameters>
149        <constructedValue name="appInfo" type="IoC.Configuration.Tests.ConstructedValue.Services.AppInfoDecorator">
150          <parameters>
151            <constructedValue name="appInfo" typeRef="AppInfo">
152              <parameters>
153                <int32 name="id" value="25"/>
154              </parameters>
155              <injectedProperties>
156                <string name="Description" value="App 25"/>
157              </injectedProperties>
158            </constructedValue>
159          </parameters>
160        </constructedValue>
161      </parameters>
162    </constructedValue>
163  </settings>
164
165  <dependencyInjection>
166    <modules>
167      <module type="IoC.Configuration.Tests.ConstructedValue.Module1">
168        <parameters>
169          <!--Demo of constructedValue to inject constructor parameter and property into module. -->
170          <constructedValue name="appInfo" typeRef="AppInfo">
171            <parameters>
172              <int32 name="id" value="3"/>
173            </parameters>
174            <injectedProperties>
175              <string name="Description" value="App 3"/>
176            </injectedProperties>
177          </constructedValue>
178        </parameters>
179      </module>
180    </modules>
181
182    <services>
183      <service typeRef="IAppInfo">
184        <valueImplementation scope="singleton">
185
186          <!--Demo of constructedValue to provide an implementation for a service under valueImplementation element.-->
187          <constructedValue typeRef="AppInfo">
188            <parameters>
189              <int32 name="id" value="8"/>
190            </parameters>
191            <injectedProperties>
192              <string name="Description" value="App 8"/>
193            </injectedProperties>
194          </constructedValue>
195        </valueImplementation>
196      </service>
197
198      <service type="System.Collections.Generic.IReadOnlyList[IoC.Configuration.Tests.ConstructedValue.Services.IAppInfo]">
199        <valueImplementation scope="singleton">
200          <collection>
201            <!--Demo of constructedValue in collection-->
202            <constructedValue typeRef="AppInfo">
203              <parameters>
204                <int32 name="id" value="10"/>
205              </parameters>
206              <injectedProperties>
207                <string name="Description" value="App 10"/>
208              </injectedProperties>
209            </constructedValue>
210
211            <settingValue settingName="App1"/>
212          </collection>
213        </valueImplementation>
214
215      </service>
216
217    </services>
218
219    <autoGeneratedServices>
220      <!--The scope for autoService implementations is always singleton -->
221
222      <autoService interface="IoC.Configuration.Tests.ConstructedValue.Services.IAppInfoFactory">
223        <autoProperty name="DefaultAppInfo" returnTypeRef="IAppInfo">
224
225          <!--Demo of constructedValue in autoProperty-->
226          <constructedValue typeRef="AppInfo" >
227            <parameters>
228              <int32 name="id" value="11"/>
229            </parameters>
230            <injectedProperties>
231              <string name="Description" value="App 11"/>
232            </injectedProperties>
233          </constructedValue>
234        </autoProperty>
235
236        <!--Demo of constructedValue in autoMethod-->
237        <autoMethod name="CreateAppInfo" returnTypeRef="IAppInfo">
238          <default>
239            <constructedValue  typeRef="AppInfo" >
240              <parameters>
241                <int32 name="id" value="12"/>
242              </parameters>
243              <injectedProperties>
244                <string name="Description" value="App 12"/>
245              </injectedProperties>
246            </constructedValue>
247          </default>
248        </autoMethod>
249      </autoService>
250
251    </autoGeneratedServices>
252  </dependencyInjection>
253
254  <startupActions>
255    <startupAction type="IoC.Configuration.Tests.ConstructedValue.Services.StartupAction1">
256      <parameters>
257        <constructedValue name="appInfo" typeRef="AppInfo">
258          <parameters>
259            <int32 name="id" value="9"/>
260          </parameters>
261          <injectedProperties>
262            <string name="Description" value="App 9"/>
263          </injectedProperties>
264        </constructedValue>
265      </parameters>
266    </startupAction>
267
268  </startupActions>
269
270  <pluginsSetup>
271  </pluginsSetup>
272</iocConfiguration>