IoCConfiguration_proxyService.xml

This configuration file can be downloaded downloaded from IoCConfiguration_proxyService.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_ProxyServiceTests"/>
 29
 30    <plugins
 31            pluginsDirPath="TestFiles\PluginDlls">
 32
 33        <!--
 34            Plugin assemblies will be in a folder with similar name under pluginsDirPath folder.
 35            The plugin folders will be included in assembly resolution mechanism.
 36            -->
 37
 38        <!--A folder K:\...\IoC.Configuration\Tests\IoC.Configuration.Tests\bin\TestFiles\PluginDlls\Plugin1 should exist.  -->
 39        <plugin name="Plugin1"/>
 40        <plugin name="Plugin2" enabled="true"/>
 41        <plugin name="Plugin3" enabled="false"/>
 42    </plugins>
 43
 44    <additionalAssemblyProbingPaths>
 45        <probingPath
 46                path="TestFiles\ThirdPartyLibs"/>
 47        <probingPath
 48                path="TestFiles\ContainerImplementations\Autofac"/>
 49        <probingPath
 50                path="TestFiles\ContainerImplementations\Ninject"/>
 51        <probingPath
 52                path="TestFiles\DynamicallyLoadedDlls"/>
 53    </additionalAssemblyProbingPaths>
 54
 55    <assemblies>
 56        <!--Assemblies should be in one of the following locations:
 57            1) Executable's folder
 58            2) In folder specified in additionalAssemblyProbingPaths element.
 59            3) In one of the plugin folders specified in plugins element (only for assemblies with plugin attribute) -->
 60
 61        <!--
 62        Use "overrideDirectory" attribute, to make the assembly path explicit, rather then searching for
 63        an assembly in predefined folders, which also include probing paths specified in additionalAssemblyProbingPaths element.
 64        -->
 65        <assembly name="IoC.Configuration.Autofac" alias="autofac_ext"/>
 66        <assembly name="IoC.Configuration.Ninject" alias="ninject_ext"/>
 67
 68        <assembly name="TestProjects.Modules" alias="modules"/>
 69
 70        <assembly name="TestProjects.DynamicallyLoadedAssembly1"
 71                  alias="dynamic1"/>
 72
 73        <assembly name="TestProjects.DynamicallyLoadedAssembly2"
 74                  alias="dynamic2"/>
 75
 76        <assembly name="TestProjects.TestPluginAssembly1"
 77                  alias="pluginassm1" plugin="Plugin1"/>
 78
 79        <assembly name="TestProjects.TestPluginAssembly2"
 80                  alias="pluginassm2" plugin="Plugin2"/>
 81
 82        <assembly name="TestProjects.TestPluginAssembly3"
 83                  alias="pluginassm3" plugin="Plugin3"/>
 84
 85        <assembly name="TestProjects.ModulesForPlugin1"
 86                  alias="modules_plugin1" plugin="Plugin1"/>
 87
 88        <assembly name="TestProjects.SharedServices" alias="shared_services"/>
 89
 90        <assembly name="IoC.Configuration.Tests" alias="tests"/>
 91    </assemblies>
 92
 93    <typeDefinitions>
 94        <typeDefinition alias="IAppData" type="IoC.Configuration.Tests.ProxyService.Services.IAppData"/>
 95        <typeDefinition alias="AppData" type="IoC.Configuration.Tests.ProxyService.Services.AppData"/>
 96        <typeDefinition alias="Guid" type="System.Guid"/>
 97        <typeDefinition alias="ListOfInt" type="System.Collections.Generic.List[System.Int32]"/>
 98    </typeDefinitions>
 99
100    <parameterSerializers>
101        <serializers></serializers>
102    </parameterSerializers>
103
104    <!--The value of type attribute should be a type that implements
105      IoC.Configuration.DiContainer.IDiManager-->
106    <diManagers activeDiManagerName="Autofac">
107        <!-- TODO:-->
108        <diManager name="Ninject" type="IoC.Configuration.Ninject.NinjectDiManager"
109                   assembly="ninject_ext">
110            <!--
111                  Use parameters element to specify constructor parameters,
112                  if the type specified in 'type' attribute has non-default constructor.
113                  -->
114            <!--<parameters>
115                  </parameters>-->
116        </diManager>
117
118        <diManager name="Autofac" type="IoC.Configuration.Autofac.AutofacDiManager"
119                   assembly="autofac_ext">
120        </diManager>
121    </diManagers>
122
123    <!--
124      If settingsRequestor element is used, the type in type attribute should
125      specify a type that implements IoC.Configuration.ISettingsRequestor.
126      The implementation specifies a collection of required settings that should be present
127      in settings element.
128      Note, the type specified in type attribute is fully integrated into a dependency
129      injection framework. In other words, constructor parameters will be injected using
130      bindings specified in dependencyInjection element.
131      -->
132
133    <settings>
134        <constructedValue name="DefaultAppData" typeRef="AppData">
135            <injectedProperties>
136                <object name="ApplicationId" typeRef="Guid" value="09E7ABD4-1BA1-4683-BEF5-EFA8266D7308"/>
137                <string name="Name" value="Default Application"/>
138            </injectedProperties>
139        </constructedValue>
140
141    </settings>
142
143    <dependencyInjection>
144        <modules>
145            <!--<module type="IoC.Configuration.Tests.AutoService.AutoServiceTestsModule" />-->
146        </modules>
147        <services>
148
149            <!--IoC.Configuration.Tests.ProxyService.Services.IAppManager will be resolved
150            by resolving IoC.Configuration.Tests.ProxyService.Services.IAppManager_Extension.-->
151            <proxyService type="IoC.Configuration.Tests.ProxyService.Services.IAppManager">
152                <serviceToProxy type="IoC.Configuration.Tests.ProxyService.Services.IAppManager_Extension"/>
153            </proxyService>
154
155            <!--IoC.Configuration.Tests.ProxyService.Services.IAppManager2 will also be resolved to
156                IoC.Configuration.Tests.ProxyService.Services.IAppManager_Extension.-->
157            <proxyService type="IoC.Configuration.Tests.ProxyService.Services.IAppManager2">
158                <serviceToProxy type="IoC.Configuration.Tests.ProxyService.Services.IAppManager_Extension"/>
159            </proxyService>
160
161            <!--
162                AppManagerUser has a constructor with parameter of type IAppManager.
163                Since we have a proxyService element that resolves IAppManager to IAppManager_Extension,
164                the object injected into constructor will be resolved by resolving the service IAppManager_Extension.
165                IAppManager_Extension is auto-implemented in autoGeneratedServices element, however, it
166                can have regular implementation in code as well.
167                -->
168            <selfBoundService type="IoC.Configuration.Tests.ProxyService.Services.AppManagerUser" scope="singleton"/>
169
170            <!--
171                AppManagerUser2 has a constructor with parameter of type  IAppManager2.
172                Since we have a proxyService element that resolves IAppManager2 to IAppManager_Extension,
173                the object injected into will be resolved by resolving the service IAppManager_Extension.
174                -->
175            <selfBoundService type="IoC.Configuration.Tests.ProxyService.Services.AppManager2User" scope="singleton"/>
176
177            <service type="IoC.Configuration.Tests.ProxyService.Services.IInterface1_Extension">
178                <implementation type="IoC.Configuration.Tests.ProxyService.Services.Interface1_Extension_Impl1"
179                                scope="singleton"/>
180            </service>
181
182            <!--IoC.Configuration.Tests.ProxyService.Services.IInterface1 will be resolved by
183              resolving IoC.Configuration.Tests.ProxyService.Services.IInterface1_Extension.-->
184            <proxyService type="IoC.Configuration.Tests.ProxyService.Services.IInterface1">
185                <serviceToProxy type="IoC.Configuration.Tests.ProxyService.Services.IInterface1_Extension"/>
186            </proxyService>
187
188            <!--
189                Interface1User has a constructor with parameter of type IInterface1.
190                Since we have a proxyService element that resolves IInterface1 to IInterface1_Extension,
191                the object injected into constructor will be resolved by resolving the service IInterface1_Extension.
192                -->
193            <selfBoundService type="IoC.Configuration.Tests.ProxyService.Services.Interface1User" scope="singleton"/>
194
195            <!--System.Collections.Generic.List<System.Int32> will be bound to a list of three integers: 19, 2, 17-->
196            <service typeRef="ListOfInt">
197                <valueImplementation scope="singleton">
198                    <collection>
199                        <int32 value="19"/>
200                        <int32 value="2"/>
201                        <int32 value="17"/>
202                    </collection>
203                </valueImplementation>
204            </service>
205
206            <!--Resolving System.Collections.Generic.IEnumerable<System.Int32> will return the same value as resolving
207                  System.Collections.Generic.List<System.Int32>-->
208            <proxyService type="System.Collections.Generic.IEnumerable[System.Int32]">
209                <serviceToProxy typeRef="ListOfInt"/>
210            </proxyService>
211
212            <!--Resolving System.Collections.Generic.IReadOnlyList<System.Int32> will return the same value as resolving
213                  System.Collections.Generic.List<System.Int32>-->
214            <proxyService type="System.Collections.Generic.IReadOnlyList[System.Int32]">
215                <serviceToProxy typeRef="ListOfInt"/>
216            </proxyService>
217
218            <!--Resolving System.Collections.Generic.IList<System.Int32> will return the same value as resolving
219                  System.Collections.Generic.List<System.Int32>-->
220            <proxyService type="System.Collections.Generic.IList[System.Int32]">
221                <serviceToProxy typeRef="ListOfInt"/>
222            </proxyService>
223
224            <!--START-Test binding an interface to the ame instance to which a self-bound class is bound-->
225            <selfBoundService type="SharedServices.Implementations.Interface13_Impl1" scope="singleton" />
226
227            <!--NOTE: Using proxyService allows us to bind
228            SharedServices.Interfaces.IInterface13 to the same instance of SharedServices.Implementations.Interface13_Impl1 to which
229            SharedServices.Implementations.Interface13_Impl1 was bound using selfBoundService element.
230
231            If we used "implementation" element under service and specified a type SharedServices.Implementations.Interface13_Impl1
232            instead of using "proxyService", then SharedServices.Interfaces.IInterface13 would have been
233            bound to a different instance of SharedServices.Implementations.Interface13_Impl1. In other words resolving
234            SharedServices.Implementations.Interface13_Impl1 and SharedServices.Interfaces.IInterface13 would have resulted in
235            different instances of SharedServices.Implementations.Interface13_Impl1.
236            Using "proxyService" element might be useful when we have module(s) that scan assemblies and self-binds
237            non-abstract classes. In this cases we can use "proxyService" element if we want the interface
238            specified in "proxyService" element to resolve to exactly the same value to which the self bound class is bound.
239            -->
240            <proxyService type="SharedServices.Interfaces.IInterface13">
241                <serviceToProxy type="SharedServices.Implementations.Interface13_Impl1"/>
242            </proxyService>
243
244            <service type="SharedServices.Interfaces.IInterface14">
245                <implementation type="SharedServices.Implementations.Interface14_Impl1" scope="singleton" />
246            </service>
247
248            <!--END-Test binding an interface to the ame instance to which a self-bound class is bound-->
249        </services>
250
251        <autoGeneratedServices>
252            <!--The scope for autoService implementations is always singleton -->
253            <!--IAppManager_Extension extends IAppManager, so can implement properties and method in both
254              IAppManager and IAppManager_Extension
255            -->
256            <autoService interface="IoC.Configuration.Tests.ProxyService.Services.IAppManager_Extension">
257                <!--  IAppData IAppManager.GetApp(System.Guid applicationId):-->
258                <autoMethod name="GetApp"
259                            returnTypeRef="IAppData"
260                            reuseValue="true">
261                    <methodSignature>
262                        <object typeRef="Guid"/>
263                    </methodSignature>
264
265                    <if parameter1="3907D19A-E53C-4471-B1B1-A3E0C36482B6">
266                        <constructedValue typeRef="AppData">
267                            <injectedProperties>
268                                <object name="ApplicationId" typeRef="Guid"
269                                        value="3907D19A-E53C-4471-B1B1-A3E0C36482B6"/>
270                                <string name="Name" value="App1"/>
271                            </injectedProperties>
272                        </constructedValue>
273                    </if>
274
275                    <if parameter1="09E7ABD4-1BA1-4683-BEF5-EFA8266D7308">
276                        <constructedValue typeRef="AppData">
277                            <injectedProperties>
278                                <object name="ApplicationId" typeRef="Guid"
279                                        value="09E7ABD4-1BA1-4683-BEF5-EFA8266D7308"/>
280                                <string name="Name" value="App2"/>
281                            </injectedProperties>
282                        </constructedValue>
283                    </if>
284
285                    <default>
286                        <settingValue settingName="DefaultAppData"/>
287                    </default>
288                </autoMethod>
289
290                <!---bool IAppManager2.IsPublicApp(Guid applicationId):-->
291                <autoMethod name="IsPublicApp" returnType="System.Boolean">
292                    <methodSignature>
293                        <object paramName="applicationId" typeRef="Guid"/>
294                    </methodSignature>
295
296                    <if parameter1="09E7ABD4-1BA1-4683-BEF5-EFA8266D7308">
297                        <boolean value="true"/>
298                    </if>
299
300                    <default>
301                        <boolean value="false"/>
302                    </default>
303                </autoMethod>
304
305                <!-- IAppData IAppManager_Extension.DefaultApp { get; }-->
306                <autoProperty name="DefaultApp" returnTypeRef="IAppData">
307                    <settingValue settingName="DefaultAppData"/>
308                </autoProperty>
309            </autoService>
310        </autoGeneratedServices>
311    </dependencyInjection>
312
313    <startupActions>
314
315    </startupActions>
316
317    <pluginsSetup>
318        <pluginSetup plugin="Plugin1">
319            <!--The type in pluginImplementation should be non-abstract class
320                that implements IoC.Configuration.IPlugin and which has a public constructor-->
321            <pluginImplementation type="TestPluginAssembly1.Implementations.Plugin1_Simple">
322            </pluginImplementation>
323
324            <settings>
325                <int32 name="Int32Setting1" value="10"/>
326                <string name="StringSetting1" value="Some text"/>
327            </settings>
328
329            <dependencyInjection>
330                <modules>
331                </modules>
332
333                <services>
334                    <service type="TestPluginAssembly1.Interfaces.IDemoProxyService_Extension">
335                        <implementation type="TestPluginAssembly1.Implementations.DemoProxyService_Extension_Impl"
336                                        scope="singleton"/>
337                    </service>
338
339                    <!--TestPluginAssembly1.Interfaces.IDemoProxyServicewill be resolved by
340                        resolving TestPluginAssembly1.Interfaces.IDemoProxyService_Extension.-->
341                    <proxyService type="TestPluginAssembly1.Interfaces.IDemoProxyService">
342                        <serviceToProxy type="TestPluginAssembly1.Interfaces.IDemoProxyService_Extension"/>
343                    </proxyService>
344
345                    <!--
346                    DemoProxyServiceUser has a constructor with parameter of type IDemoProxyService.
347                    Since we have a proxyService element that resolves IDemoProxyService to IDemoProxyService_Extension,
348                    the object injected into constructor will be resolved by resolving the service IDemoProxyService_Extension.
349                    -->
350                    <selfBoundService type="TestPluginAssembly1.Implementations.DemoProxyServiceUser"
351                                      scope="singleton"/>
352                </services>
353
354                <autoGeneratedServices>
355
356                </autoGeneratedServices>
357            </dependencyInjection>
358        </pluginSetup>
359
360        <pluginSetup plugin="Plugin2">
361            <pluginImplementation type="TestPluginAssembly2.Implementations.Plugin2" assembly="pluginassm2">
362                <parameters>
363                    <boolean name="param1" value="true"/>
364                    <double name="param2" value="25.3"/>
365                    <string name="param3" value="String value"/>
366                </parameters>
367            </pluginImplementation>
368            <settings>
369            </settings>
370            <dependencyInjection>
371                <modules>
372                </modules>
373                <services>
374                </services>
375                <autoGeneratedServices>
376                </autoGeneratedServices>
377            </dependencyInjection>
378        </pluginSetup>
379
380        <pluginSetup plugin="Plugin3">
381            <pluginImplementation type="TestPluginAssembly3.Implementations.Plugin3" assembly="pluginassm3">
382
383            </pluginImplementation>
384            <settings>
385            </settings>
386            <dependencyInjection>
387                <modules>
388                </modules>
389                <services>
390                </services>
391                <autoGeneratedServices>
392                </autoGeneratedServices>
393            </dependencyInjection>
394        </pluginSetup>
395    </pluginsSetup>
396</iocConfiguration>