IoCConfiguration_settingValue_ReferencingInConfiguration.xml
This configuration file can be downloaded downloaded from IoCConfiguration_settingValue_ReferencingInConfiguration.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_SettingValue" />
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" enabled="true" />
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.TestPluginAssembly2"
79 alias="pluginassm2" plugin="Plugin2" />
80
81 <assembly name="TestProjects.TestPluginAssembly3"
82 alias="pluginassm3" plugin="Plugin3" />
83
84 <assembly name="TestProjects.ModulesForPlugin1"
85 alias="modules_plugin1" plugin="Plugin1" />
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
96 </typeDefinitions>
97
98 <parameterSerializers>
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 <!-- TODO:-->
106 <diManager name="Ninject" type="IoC.Configuration.Ninject.NinjectDiManager"
107 assembly="ninject_ext">
108 <!--
109 Use parameters element to specify constructor parameters,
110 if the type specified in 'type' attribute has non-default constructor.
111 -->
112 <!--<parameters>
113 </parameters>-->
114 </diManager>
115
116 <diManager name="Autofac" type="IoC.Configuration.Autofac.AutofacDiManager"
117 assembly="autofac_ext">
118 </diManager>
119 </diManagers>
120
121 <!--
122 If settingsRequestor element is used, the type in type attribute should
123 specify a type that implements IoC.Configuration.ISettingsRequestor.
124 The implementation specifies a collection of required settings that should be present
125 in settings element.
126 Note, the type specified in type attribute is fully integrated into a dependency
127 injection framework. In other words, constructor parameters will be injected using
128 bindings specified in dependencyInjection element.
129 -->
130
131 <settings>
132 <int32 name="defaultAppId" value="7"/>
133 <string name="defaultAppDescr" value="Default App"/>
134 <int32 name="app1" value="37"/>
135 <string name="android" value="Android"/>
136 <int32 name="defaultInt" value="-1"/>
137
138 <!--This setting is redefined in plugin1 settings section to be of int type.
139 Any services that reference a setting with name defaultColor, will be referencing the setting
140 in plugin1
141 -->
142 <string name="defaultColor" value="Brown" />
143 </settings>
144
145 <dependencyInjection>
146 <modules>
147 </modules>
148 <services>
149 <service type="System.Int32">
150 <valueImplementation scope="transient">
151 <!--Demo of using a setting value in valueImplementation.-->
152 <settingValue settingName="defaultInt"/>
153 </valueImplementation>
154 </service>
155
156 <service type="System.Collections.Generic.IReadOnlyList[System.Int32]">
157 <valueImplementation scope="singleton">
158 <collection>
159 <!--Example of using setting value in collection element-->
160 <settingValue settingName="defaultInt"/>
161 <settingValue settingName="app1"/>
162 <int32 value="78"/>
163 </collection>
164 </valueImplementation>
165 </service>
166
167 <service type="IoC.Configuration.Tests.SettingValue.Services.IAppInfo" >
168 <implementation type="IoC.Configuration.Tests.SettingValue.Services.AppInfo" scope="transient">
169 <parameters>
170 <!--Demo of using settingValue to inject value into an implementation constructor.-->
171 <settingValue name="appId" settingName="defaultAppId"/>
172 </parameters>
173 <injectedProperties>
174 <!--Demo of using settingValue to inject value into an implementation property.-->
175 <settingValue name="AppDescription" settingName="defaultAppDescr"/>
176 </injectedProperties>
177 </implementation>
178 </service>
179
180 <service type="System.Collections.Generic.IReadOnlyList[IoC.Configuration.Tests.SettingValue.Services.IAppInfo]">
181 <valueImplementation scope="singleton">
182 <collection>
183 <constructedValue type="IoC.Configuration.Tests.SettingValue.Services.AppInfo">
184 <parameters>
185 <!--Demo of using settingValue to inject a constructor parameter value in constructedValue element.-->
186 <settingValue name="appId" settingName="defaultAppId"/>
187 </parameters>
188 <injectedProperties>
189 <!--Demo of using settingValue to inject a property parameter value in constructedValue element.-->
190 <settingValue name="AppDescription" settingName="defaultAppDescr"/>
191 </injectedProperties>
192 </constructedValue>
193 </collection>
194 </valueImplementation>
195 </service>
196
197 </services>
198
199 <autoGeneratedServices>
200 <!--The scope for autoService implementations is always singleton -->
201 <autoService interface="IoC.Configuration.Tests.SettingValue.Services.IAppIds">
202
203 <autoMethod name="GetDefaultAppId" returnType="System.Int32">
204 <default>
205 <settingValue settingName="defaultAppId"/>
206 </default>
207 </autoMethod>
208
209 <autoMethod name="GetAppIds" returnType="System.Collections.Generic.IReadOnlyList[System.Int32]">
210 <methodSignature>
211 <string paramName="platformType"/>
212 </methodSignature>
213 <!--Demo of using the value of setting named "android" in if condition in autoMethod-->
214 <if parameter1="_settings:android">
215 <collection>
216 <!--Demo of setting value used as one of returned values in autoMethod if element.-->
217 <settingValue settingName="defaultAppId"/>
218 <settingValue settingName="app1"/>
219 <int32 value="9"/>
220 </collection>
221 </if>
222
223 <default>
224 <collection>
225 <!--Demo of setting value used as one of returned values in autoMethod default element.-->
226 <settingValue settingName="defaultAppId"/>
227 <int32 value="8"/>
228 </collection>
229 </default>
230 </autoMethod>
231
232 <autoProperty name="MainAppId" returnType="System.Int32">
233 <!--Demo of setting value used as return value of autoProperty element.-->
234 <settingValue settingName="defaultAppId"/>
235 </autoProperty>
236
237 </autoService>
238
239 </autoGeneratedServices>
240 </dependencyInjection>
241
242 <startupActions>
243
244 </startupActions>
245
246 <pluginsSetup>
247 <pluginSetup plugin="Plugin1">
248 <!--The type in pluginImplementation should be non-abstract class
249 that implements IoC.Configuration.IPlugin and which has a public constructor-->
250 <pluginImplementation type="TestPluginAssembly1.Implementations.Plugin1_Simple">
251 </pluginImplementation>
252
253 <settings>
254
255 <!--This setting with string type is also defined in non-plugin section.
256 Since we re-defined the setting, any the references in plugin section to setting with name defaultColor,
257 will be referencing the setting redefined here.
258 -->
259 <int32 name="defaultColor" value="4997399" />
260
261 <int32 name="Int32Setting1" value="10"/>
262 <string name="StringSetting1" value="Some text"/>
263 </settings>
264
265 <dependencyInjection>
266 <modules>
267 </modules>
268
269 <services>
270 <service type="TestPluginAssembly1.Interfaces.IDoor">
271 <implementation type="TestPluginAssembly1.Implementations.Door" scope="transient">
272 <parameters>
273 <settingValue name="color" settingName="defaultColor"/>
274 <int32 name="height" value="80"/>
275 </parameters>
276 </implementation>
277
278 </service>
279 </services>
280
281 <autoGeneratedServices>
282
283 </autoGeneratedServices>
284 </dependencyInjection>
285 </pluginSetup>
286
287 <pluginSetup plugin="Plugin2">
288 <pluginImplementation type="TestPluginAssembly2.Implementations.Plugin2" assembly="pluginassm2">
289 <parameters>
290 <boolean name="param1" value="true" />
291 <double name="param2" value="25.3" />
292 <string name="param3" value="String value" />
293 </parameters>
294 </pluginImplementation>
295 <settings>
296 </settings>
297 <dependencyInjection>
298 <modules>
299 </modules>
300 <services>
301 </services>
302 <autoGeneratedServices>
303 </autoGeneratedServices>
304 </dependencyInjection>
305 </pluginSetup>
306
307 <pluginSetup plugin="Plugin3">
308 <pluginImplementation type="TestPluginAssembly3.Implementations.Plugin3" assembly="pluginassm3">
309
310 </pluginImplementation>
311 <settings>
312 </settings>
313 <dependencyInjection>
314 <modules>
315 </modules>
316 <services>
317 </services>
318 <autoGeneratedServices>
319 </autoGeneratedServices>
320 </dependencyInjection>
321 </pluginSetup>
322 </pluginsSetup>
323</iocConfiguration>