IoC.Configuration
2.1.0
dotnet add package IoC.Configuration --version 2.1.0
NuGet\Install-Package IoC.Configuration -Version 2.1.0
<PackageReference Include="IoC.Configuration" Version="2.1.0" />
paket add IoC.Configuration --version 2.1.0
#r "nuget: IoC.Configuration, 2.1.0"
// Install IoC.Configuration as a Cake Addin #addin nuget:?package=IoC.Configuration&version=2.1.0 // Install IoC.Configuration as a Cake Tool #tool nuget:?package=IoC.Configuration&version=2.1.0
The main functions of IoC.Configuration library are:
1) Container agnostic configuration of dependency injection using XML configuration file. The file has section where container can be specified, that will be handling dependency injection resolutions.
Currently two popular containers are supported, Ninject and Autofac, via extension libraries IoC.Configuration.Ninject and IoC.Configuration.Autofac, that are available in Nuget.org.
The dependency injection container (e.g., Autofac, Ninject) can be easily switched in configuration file.
In addition, the configuration file has sections for settings, plugins, startup actions, dynamically generated implementations of interfaces (see autoService elements under iocConfiguration/dependencyInjection/autoGeneratedServices in example configuration files in GitHub test projects in https://github.com/artakhak/IoC.Configuration/tree/master/IoC.Configuration.Tests).
2) Container agnostic configuration of dependency injection in code.
The bindings are specified using IoC.Configuration chained methods, however the actual resolutions are done using one of the popular dependency injection containers, Ninject and Autofac, via extension libraries IoC.Configuration.Ninject and IoC.Configuration.Autofac.
Note: Use either IoC.Configuration.Ninject 2.0.0 or higher, or IoC.Configuration.Autofac 2.0.0 with IoC.Configuration.Autofac 2.x.x.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.CodeAnalysis (>= 2.3.2)
- OROptimizer.Shared (>= 2.1.1)
- System.Runtime.Loader (>= 4.3.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on IoC.Configuration:
Package | Downloads |
---|---|
IoC.Configuration.Autofac
An Autofac extension for IoC.Configuration 2. Detailed documentation on IoC.Configuration is available at http://iocconfiguration.readthedocs.io Look at http://iocconfiguration.readthedocs.io/ |
|
IoC.Configuration.Ninject
A Ninject extension for IoC.Configuration 2. Source code can be found at https://github.com/artakhak/IoC.Configuration Detailed documentation on IoC.Configuration is available at http://iocconfiguration.readthedocs.io Look at http://iocconfiguration.readthedocs.io/ |
|
IoC.Configuration.Extensions
An extension for IoC.Configuration library at https://www.nuget.org/packages/IoC.Configuration/. Detailed documentation on IoC.Configuration is available at http://iocconfiguration.readthedocs.io. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.1.0 | 1,395 | 4/10/2022 |
2.0.2 | 941 | 3/17/2019 |
2.0.1 | 866 | 3/17/2019 |
2.0.0 | 1,499 | 2/27/2019 |
1.0.6 | 1,208 | 6/12/2018 |
1.0.5 | 1,171 | 6/11/2018 |
1.0.4 | 1,170 | 6/5/2018 |
1.0.3 | 2,366 | 5/9/2018 |
1.0.2 | 1,187 | 5/9/2018 |
1.0.1 | 1,789 | 4/18/2018 |
1.0.0 | 1,292 | 4/18/2018 |
1.0.0-beta4 | 970 | 4/4/2018 |
1.0.0-beta3 | 969 | 4/2/2018 |
1.0.0-beta2 | 1,356 | 4/1/2018 |
1.0.0-beta | 902 | 4/1/2018 |
1) Added a new element 'autoServiceCustom' that can be placed under 'iocConfiguration/autoGeneratedServices' in configuration file to provide a custom implementation for a service in attribute 'interface'.
This element has some similarity to element 'autoService', however can be used when more control is necessary over the autogenerated implementation.
'autoService' provides auto-generated implementation of interface methods and properties by using the information in elements like 'if', 'default', 'object', etc under elements 'autoService/autoProperty' and 'autoService/autoMethod'.
On the other hand, 'autoServiceCustom' generates the interface implementation by using the code generator class IoC.Configuration.ConfigurationFile.ICustomAutoServiceCodeGenerator that is setup in element 'autoServiceCodeGenerator' under element 'autoServiceCustom'.
The interface IoC.Configuration.ConfigurationFile.ICustomAutoServiceCodeGenerator has method GenerateCSharp(ICustomAutoGeneratedServiceInfo customAutoGeneratedServiceInfo, IDynamicAssemblyBuilder dynamicAssemblyBuilder, string generatedClassNamespace, string generatedClassName) which generates C# implementation for the
interface in 'autoServiceCustom', as well as other methods for validation. See the configuration file "IoCConfiguration_autoServiceCustom.xml" as well as tests in folder 'AutoServiceCustom' in test project 'IoC.Configuration.Tests' for examples on using this element.
A good application of 'autoServiceCustom' is to generate an interface implementation, based on C# attributes, as demonstrated by examples in AutoServiceCustom folder in test project.
Element 'autoServiceCustom' requires more work than configuring auto-generated service using the element 'autoService', however element 'autoServiceCustom' provides more flexibility than 'autoService'.
2) Added a new overloaded method "IFileBasedDiContainerConfigurator IoC.Configuration.DiContainerBuilder.DiContainerBuilder.StartFileBasedDi(FileBasedConfigurationParameters fileBasedConfigurationParameters,
out IoC.Configuration.ConfigurationFile.IConfiguration loadedConfiguration)". This method is using a parameter of a new type "IoC.Configuration.DiContainerBuilder.FileBased.FileBasedConfigurationParameters" instead of using multiple
parameters that old overloaded methods use. In addition to supporting all the features the old overloaded methods provided, FileBasedConfigurationParameters has the following new properties and methods to support some new features:
-Property "OROptimizer.ILoadedAssemblies LoadedAssemblies { get; }". The property value OROptimizer.ILoadedAssemblies provides a list of currently loaded assemblies that should be added to dynamically generated assembly as references.
If the value of LoadedAssemblies is set to "OROptimizer.AllLoadedAssemblies", all assemblies loaded in current app domain will be added as references to dynamically generated assembly.
See tests in IoC.Configuration.Tests.AssemblyReferences.AssemblyReferencesTests for examples on using FileBasedConfigurationParameters.LoadedAssemblies.
-Property "IEnumerable<string>
AdditionalReferencedAssemblies { get; set; }". This property value provides a list of absolute paths of assemblies that will be added to dynamically generated assembly as references.
See tests in IoC.Configuration.Tests.AssemblyReferences.AssemblyReferencesTests for examples on using FileBasedConfigurationParameters. AdditionalReferencedAssemblies.
-Property "IEnumerable<IAttributeValueTransformer> AttributeValueTransformers { get; set; }". This property is a list of "IoC.Configuration.AttributeValueTransformer.IAttributeValueTransformer" (a new interface in this release) items, which are used to transform attribute values in XML configuration file to some other values, before the DI is loaded form the configuration.
See tests in "IoC.Configuration.Tests.AttributeValueTransformers.AttributeValueTransformersTests" for examples on how to use this property.
-Property "Delegates.OnDynamicAssemblyEmitComplete OnDynamicAssemblyEmitComplete { get; set; }". This property value can be configured to process the results of dynamic assembly generation (e.g., log compilation errors, etc.).
-NOTE: IoC.Configuration.DiContainerBuilder.FileBased.FileBasedConfigurationParameters is a sealed class, and in the future new properties might be added to provided more features.
3) Added OROptimizer.ServiceResolver.IDiBasedObjectFactory in package OROptimizer.Shared for DI resolution that does not require binding configuration and always resolves the types using non-singletone binding.
This interface can be used in cases when we want to guarantee non-singletone resolution. The CreateInstance(...) methods in this interface use DI resolution to inject constructor parameters in created instance.
4) Added a new extensions package "IoC.Configuration.Extensions" with a class IoC.Configuration.Extensions.AssemblyScanning.AssemblyScannerForSelfBoundTypesModule that can be used to scan the assemblies and register types using self-binding.
5) Removed 'typeFactory' element and related classes (e.g., IoC.Configuration.ConfigurationFile.ITypeFactory, etc) that have been deprecated in 2019. Use autoService element under autoGeneratedServices instead.
6) Replaced the XML schema file IoC.Configuration.Schema.7579ADB2-0FBD-4210-A8CA-EE4B4646DB3F.xsd with IoC.Configuration.Schema.7579ADB2-0FBD-4210-A8CA-EE4B4646DB3F.xsd.
This matters only if the schema file is used in Visual Studio for code completion support (the library always load the most recent XML schema from a resource file). The latest XML schema can be accessed at
http://oroptimizer.com/ioc.configuration/V2/IoC.Configuration.Schema.7579ADB2-0FBD-4210-A8CA-EE4B4646DB3F.xsd.
7) Removed number of interfaces, methods and properties that were deprecated since 2019.
8) Depricated the attribute 'loadAlways' in element 'iocConfiguration/assemblies/assembly'. Using this attribute will have no effect, and the attribute will be removed from the schema in the future. The attribute was used to force load an assembly and add it to dynamically generated assembly. IoC.COnfiguration was modified to add all assemblies in 'iocConfiguration/assemblies/assembly' elements to dynamically generated assembly, so this attribute is not needed anymore. See the https://iocconfiguration.readthedocs.io/en/latest/troubleshooting/troubleshooting-dynamically-generated-assembly.generated.html or the tests in folder AssemblyReferencesInDynamicallyGeneratedAssembly for more details on adding references to dynamic assembly.