diff --git a/Snap.SimpleInjector/Properties/AssemblyInfo.cs b/Snap.SimpleInjector/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b9c5db5 --- /dev/null +++ b/Snap.SimpleInjector/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Snap.SimpleInjector")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Snap.SimpleInjector")] +[assembly: AssemblyCopyright("Copyright © Tyler Brinks 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("0b56faaa-6910-4d62-812e-cd30814ceff7")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.7.*")] +[assembly: AssemblyFileVersion("1.7.*")] diff --git a/Snap.SimpleInjector/SampleSimpleInjectorAopConfig.cs b/Snap.SimpleInjector/SampleSimpleInjectorAopConfig.cs new file mode 100644 index 0000000..e686706 --- /dev/null +++ b/Snap.SimpleInjector/SampleSimpleInjectorAopConfig.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Snap.SimpleInjector +{ + class SampleSimpleInjectorAopConfig + { + } +} diff --git a/Snap.SimpleInjector/SimpleInjectorAspectContainer.cs b/Snap.SimpleInjector/SimpleInjectorAspectContainer.cs new file mode 100644 index 0000000..2956c6f --- /dev/null +++ b/Snap.SimpleInjector/SimpleInjectorAspectContainer.cs @@ -0,0 +1,90 @@ +/* +Snap v1.0 + +Copyright (c) 2010 Tyler Brinks + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +using System; +using System.Linq.Expressions; +using Castle.DynamicProxy; +using CommonServiceLocator.SimpleInjectorAdapter; +using SimpleInjector; + +namespace Snap.SimpleInjector +{ + /// + /// Simple Injector Aspect Container for AoP interception registration. + /// + public class SimpleInjectorAspectContainer : AspectContainer + { + private readonly ProxyFactory _proxyFactory = new ProxyFactory(new ProxyGenerator()); + + private readonly Func _createProxy; + + /// + /// Initializes a new instance of the class. + /// + /// The builder. + public SimpleInjectorAspectContainer(Container container) + { + if (container == null) + { + throw new ArgumentNullException("container"); + } + + Proxy = new MasterProxy(); + Container = container; + + Proxy = new MasterProxy { Container = new SimpleInjectorServiceLocatorAdapter(container) }; + + _createProxy = instanceToProxy => _proxyFactory.CreateProxy(instanceToProxy, Proxy); + + container.ExpressionBuilding += Intercept; + } + + void Intercept(object sender, ExpressionBuildingEventArgs e) + { + if (AspectUtility.IsDecorated(e.KnownImplementationType, Proxy.Configuration)) + { + e.Expression = Expression.Convert( + Expression.Invoke(Expression.Constant(_createProxy), e.Expression), + e.RegisteredServiceType); + } + } + + /// + /// Gets or sets the container builder. + /// + /// The builder. + public Container Container { get; private set; } + + /// + /// Sets the aspect configuration. + /// + /// The config. + public override void SetConfiguration(AspectConfiguration config) + { + Proxy.Configuration = config; + Container.RegisterSingle((MasterProxy)Proxy); + config.Container = this; + } + } +} diff --git a/Snap.SimpleInjector/Snap.SimpleInjector.csproj b/Snap.SimpleInjector/Snap.SimpleInjector.csproj new file mode 100644 index 0000000..dc6e77b --- /dev/null +++ b/Snap.SimpleInjector/Snap.SimpleInjector.csproj @@ -0,0 +1,148 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {8ADE2FD7-93B9-4936-8B7B-34DB14443C9A} + Library + Properties + Snap.SimpleInjector + Snap.SimpleInjector + 512 + + + + + 3.5 + + ..\ + false + true + + + v4.0 + true + full + false + bin\NET40-Debug\ + DEBUG;TRACE;DOTNET40 + prompt + 4 + AllRules.ruleset + + + v4.0 + pdbonly + true + bin\NET40-Release\ + TRACE;DOTNET40 + prompt + 4 + AllRules.ruleset + + + v3.5 + true + full + false + bin\NET35-Debug\ + DEBUG;TRACE;DOTNET35 + prompt + 4 + AllRules.ruleset + + + v3.5 + pdbonly + true + bin\NET35-Release\ + TRACE;DOTNET35 + prompt + 4 + AllRules.ruleset + + + NET40 + NET35 + + + true + bin\NET45-Debug\ + DEBUG;TRACE;DOTNET40 + full + AnyCPU + prompt + AllRules.ruleset + + + bin\NET45-Release\ + TRACE;DOTNET40 + true + pdbonly + AnyCPU + prompt + AllRules.ruleset + + + + ..\packages\Castle.Core.3.2.2\lib\net40-client\Castle.Core.dll + + + ..\packages\CommonServiceLocator.SimpleInjectorAdapter.2.6.1\lib\portable-net4+sl4+wp8+win8+wpa81\CommonServiceLocator.SimpleInjectorAdapter.dll + + + ..\packages\fasterflect.2.1.3\lib\net40\Fasterflect.dll + + + False + ..\packages\Portable.CommonServiceLocator.1.2.2\lib\net35\Microsoft.Practices.ServiceLocation.dll + + + ..\packages\SimpleInjector.2.6.1\lib\net40-client\SimpleInjector.dll + + + ..\packages\SimpleInjector.2.6.1\lib\net40-client\SimpleInjector.Diagnostics.dll + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + + {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC} + Snap + + + + + + + + + + + + + \ No newline at end of file diff --git a/Snap.SimpleInjector/packages.config b/Snap.SimpleInjector/packages.config new file mode 100644 index 0000000..74b2d6a --- /dev/null +++ b/Snap.SimpleInjector/packages.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Snap.Tests/SimpleInjectorTests.cs b/Snap.Tests/SimpleInjectorTests.cs new file mode 100644 index 0000000..b73c4e8 --- /dev/null +++ b/Snap.Tests/SimpleInjectorTests.cs @@ -0,0 +1,281 @@ +/* +Snap v1.0 + +Copyright (c) 2010 Tyler Brinks + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ +using System; +using System.Linq; +using NUnit.Framework; +using Snap.SimpleInjector; +using SnapTests.Fakes; +using Snap.Tests.Interceptors; +using SimpleInjector; + +namespace Snap.Tests +{ + [TestFixture] + public class SimpleInjectorTests : TestBase + { + [Test] + public void SimpleInjector_Container_Supports_Method_Aspects() + { + var container = new SimpleInjectorAspectContainer(new Container()); + + SnapConfiguration.For(container).Configure(c => + { + c.IncludeNamespace("SnapTests*"); + c.Bind().To(); + }); + + container.Container.Register(); + var badCode = container.Container.GetInstance(); + + Assert.DoesNotThrow(badCode.GiddyUp); + Assert.IsTrue(badCode.GetType().Name.Equals("IBadCodeProxy")); + } + + [Test] + public void SimpleInjector_Container_Supports_Multiple_Method_Aspects() + { + var container = new SimpleInjectorAspectContainer(new Container()); + + SnapConfiguration.For(container).Configure(c => + { + c.IncludeNamespace("SnapTests*"); + c.Bind().To(); + c.Bind().To(); + }); + + container.Container.Register(); + var badCode = container.Container.GetInstance(); + badCode.RunInOrder(); + Assert.AreEqual("First", OrderedCode.Actions[0]); + Assert.AreEqual("Second", OrderedCode.Actions[1]); + } + + [Test] + public void SimpleInjector_Container_Supports_Class_Aspects() + { + var container = new SimpleInjectorAspectContainer(new Container()); + + SnapConfiguration.For(container).Configure(c => + { + c.IncludeNamespace("SnapTests*"); + c.Bind().To + (); + }); + + container.Container.Register(); + var code = container.Container.GetInstance(); + code.RunInOrder(); + + Assert.AreEqual("Fourth", OrderedCode.Actions[0]); + } + + [Test] + public void SimpleInjector_Container_Ignores_Types_Without_Decoration() + { + var container = new SimpleInjectorAspectContainer(new Container()); + + SnapConfiguration.For(container).Configure(c => + { + c.IncludeNamespace("SnapTests*"); + c.Bind().To + (); + }); + + container.Container.Register(); + var code = container.Container.GetInstance(); + + Assert.IsFalse(code.GetType().Name.Equals("INotInterceptableProxy")); + } + + [Test] + public void SimpleInjector_Container_Allow_Wildcard_Matching() + { + var container = new SimpleInjectorAspectContainer(new Container()); + + SnapConfiguration.For(container).Configure(c => + { + c.IncludeNamespace("SnapTests*"); + c.Bind().To + (); + }); + + container.Container.Register(); + var badCode = container.Container.GetInstance(); + + Assert.DoesNotThrow(badCode.GiddyUp); + Assert.IsTrue(badCode.GetType().Name.Equals("IBadCodeProxy")); + } + + [Test] + public void SimpleInjector_Container_Allow_Strict_Matching() + { + var container = new SimpleInjectorAspectContainer(new Container()); + + SnapConfiguration.For(container).Configure(c => + { + c.IncludeNamespace("SnapTests.Fakes.IBadCode"); + c.Bind().To + (); + }); + + container.Container.Register(); + Assert.DoesNotThrow(() => container.Container.GetInstance()); + } + + [Test] + public void SimpleInjector_Container_Fails_Without_Match() + { + var container = new SimpleInjectorAspectContainer(new Container()); + + SnapConfiguration.For(container).Configure(c => + { + c.IncludeNamespace("Does.Not.Work"); + c.Bind().To + (); + }); + + container.Container.Register(); + Assert.Throws(() => container.Container.GetInstance()); + } + + [Test] + public void SimpleInjector_Supports_Types_Without_Interfaces() + { + var container = new SimpleInjectorAspectContainer(new Container()); + + SnapConfiguration.For(container).Configure(c => + { + c.IncludeNamespace("SnapTests.Fakes*"); + c.Bind().To(); + }); + + container.Container.Register(); + + container.Container.Register(); + container.Container.Register(); + + var typeWithoutInterface = container.Container.GetInstance(); + + Assert.DoesNotThrow(typeWithoutInterface.Foo); + Assert.IsTrue(typeWithoutInterface.GetType().Name.Equals("TypeWithoutInterfaceProxy")); + + var typeWithInterfaceInBaseClass = container.Container.GetInstance(); + + Assert.DoesNotThrow(typeWithInterfaceInBaseClass.Foo); + Assert.IsTrue(typeWithInterfaceInBaseClass.GetType().Name.Equals("TypeWithInterfaceInBaseClassProxy")); + } + + [Test] + public void SimpleInjector_Supports_Resolving_All_Aspects_From_Container() + { + var container = new SimpleInjectorAspectContainer(new Container()); + + SnapConfiguration.For(container).Configure(c => + { + c.IncludeNamespace("SnapTests.*"); + c.Bind().To(); + c.Bind().To(); + c.AllAspects().KeepInContainer(); + }); + + container.Container.Register(); + container.Container.RegisterSingle(new FirstInterceptor("first_kept_in_container")); + container.Container.RegisterSingle(new SecondInterceptor("second_kept_in_container")); + + var orderedCode = container.Container.GetInstance(); + orderedCode.RunInOrder(); + + // both interceptors are resolved from container + CollectionAssert.AreEquivalent( + OrderedCode.Actions, + new[] {"first_kept_in_container", "second_kept_in_container"}); + } + + [Test] + public void SimpleInjector_Supports_Resolving_Only_Selected_Aspects_From_Container() + { + var container = new SimpleInjectorAspectContainer(new Container()); + + SnapConfiguration.For(container).Configure(c => + { + c.IncludeNamespace("SnapTests.*"); + c.Bind().To(); + c.Bind().To(); + c.Aspects(typeof (FirstInterceptor)).KeepInContainer(); + }); + + container.Container.Register(); + container.Container.RegisterSingle(new FirstInterceptor("first_kept_in_container")); + container.Container.RegisterSingle(new SecondInterceptor("second_kept_in_container")); + + var orderedCode = container.Container.GetInstance(); + orderedCode.RunInOrder(); + + // first interceptor is resolved from container, while second one is via new() + CollectionAssert.AreEquivalent( + OrderedCode.Actions, + new[] {"first_kept_in_container", "Second"}); + } + + [Test] + [Explicit( + "No way to unload given assembly from domain w/o destroying domain. Cannot make this test independent from others when all test suite is run." + )] + public void + When_resolving_services_from_container_SNAP_should_load_dynamicproxygenassebmly2_in_appdomain_only_once() + { + var container = new SimpleInjectorAspectContainer(new Container()); + + SnapConfiguration.For(container).Configure(c => + { + c.IncludeNamespaceOf(); + c.Bind().To(); + c.Bind().To(); + c.Bind().To(); + }); + + container.Container.Register(); + container.Container.Register(); + + var orderedCode = container.Container.GetInstance(); + var badCode = container.Container.GetInstance(); + + orderedCode.RunInOrder(); + Assert.AreEqual("First", OrderedCode.Actions[1]); + Assert.AreEqual("Second", OrderedCode.Actions[0]); + + Assert.DoesNotThrow(badCode.GiddyUp); + + var dynamicProxyGenerationAssemblies = AppDomain.CurrentDomain + .GetAssemblies() + .Where(assembly => assembly.GetName().Name == "DynamicProxyGenAssembly2") + .ToList(); + + Assert.That(dynamicProxyGenerationAssemblies.Count, Is.EqualTo(2)); + // both signed and unsigned. + Assert.IsNotNull(dynamicProxyGenerationAssemblies.FirstOrDefault(a => a.GetName().GetPublicKey().Length > 0)); + Assert.IsNotNull(dynamicProxyGenerationAssemblies.FirstOrDefault(a => a.GetName().GetPublicKey().Length == 0)); + } + } +} \ No newline at end of file diff --git a/Snap.Tests/Snap.Tests.csproj b/Snap.Tests/Snap.Tests.csproj index 31b5c67..cc1393f 100644 --- a/Snap.Tests/Snap.Tests.csproj +++ b/Snap.Tests/Snap.Tests.csproj @@ -113,6 +113,12 @@ ..\packages\NUnit.2.6.3\lib\nunit.framework.dll + + ..\packages\SimpleInjector.2.6.1\lib\net40-client\SimpleInjector.dll + + + ..\packages\SimpleInjector.2.6.1\lib\net40-client\SimpleInjector.Diagnostics.dll + ..\packages\structuremap.2.6.4.1\lib\net40\StructureMap.dll @@ -158,6 +164,7 @@ + @@ -180,6 +187,10 @@ {C8C529ED-68D6-4877-9D1A-78E34AA1465F} Snap.Ninject + + {8ade2fd7-93b9-4936-8b7b-34db14443c9a} + Snap.SimpleInjector + {9B28439F-F207-4669-8C89-E5CD86098FCC} Snap.StructureMap diff --git a/Snap.Tests/packages.config b/Snap.Tests/packages.config index f08152c..1fae116 100644 --- a/Snap.Tests/packages.config +++ b/Snap.Tests/packages.config @@ -1,12 +1,13 @@ - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/Snap.sln b/Snap.sln index cd68f84..d6bac03 100644 --- a/Snap.sln +++ b/Snap.sln @@ -1,103 +1,145 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Snap", "Snap\Snap.csproj", "{C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Snap.Autofac", "Snap.Autofac\Snap.Autofac.csproj", "{47681067-0B27-4B18-819C-0A2F3D0DB2D6}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Snap.CastleWindsor", "Snap.CastleWindsor\Snap.CastleWindsor.csproj", "{D1102CFD-63B5-4587-AB70-AF59B7FB28E1}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Snap.LinFu", "Snap.LinFu\Snap.LinFu.csproj", "{B6C02C50-E493-408C-9649-2872CB591FA0}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Snap.Ninject", "Snap.Ninject\Snap.Ninject.csproj", "{C8C529ED-68D6-4877-9D1A-78E34AA1465F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Snap.StructureMap", "Snap.StructureMap\Snap.StructureMap.csproj", "{9B28439F-F207-4669-8C89-E5CD86098FCC}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Snap.Tests", "Snap.Tests\Snap.Tests.csproj", "{3F3A6A53-D90C-41B6-88FF-D211DE0857D3}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{558C50A4-F5C9-4B52-8414-69E08CA86994}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Specs", "Specs", "{CF658F2A-8ACD-4328-85B4-122C9429D535}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{5EBFCC82-B3AE-4B51-AFC0-0BFFDD262DF7}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{84EE23F7-9EA4-42BD-97E5-BB208468631D}" - ProjectSection(SolutionItems) = preProject - .nuget\packages.config = .nuget\packages.config - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - NET40-Debug|Any CPU = NET40-Debug|Any CPU - NET40-Release|Any CPU = NET40-Release|Any CPU - NET45-Debug|Any CPU = NET45-Debug|Any CPU - NET45-Release|Any CPU = NET45-Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}.NET40-Debug|Any CPU.ActiveCfg = NET40-Debug|Any CPU - {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}.NET40-Debug|Any CPU.Build.0 = NET40-Debug|Any CPU - {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}.NET40-Release|Any CPU.ActiveCfg = NET40-Release|Any CPU - {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}.NET40-Release|Any CPU.Build.0 = NET40-Release|Any CPU - {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}.NET45-Debug|Any CPU.ActiveCfg = NET45-Debug|Any CPU - {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}.NET45-Debug|Any CPU.Build.0 = NET45-Debug|Any CPU - {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}.NET45-Release|Any CPU.ActiveCfg = NET45-Release|Any CPU - {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}.NET45-Release|Any CPU.Build.0 = NET45-Release|Any CPU - {47681067-0B27-4B18-819C-0A2F3D0DB2D6}.NET40-Debug|Any CPU.ActiveCfg = NET40-Debug|Any CPU - {47681067-0B27-4B18-819C-0A2F3D0DB2D6}.NET40-Debug|Any CPU.Build.0 = NET40-Debug|Any CPU - {47681067-0B27-4B18-819C-0A2F3D0DB2D6}.NET40-Release|Any CPU.ActiveCfg = NET40-Release|Any CPU - {47681067-0B27-4B18-819C-0A2F3D0DB2D6}.NET40-Release|Any CPU.Build.0 = NET40-Release|Any CPU - {47681067-0B27-4B18-819C-0A2F3D0DB2D6}.NET45-Debug|Any CPU.ActiveCfg = NET45-Debug|Any CPU - {47681067-0B27-4B18-819C-0A2F3D0DB2D6}.NET45-Debug|Any CPU.Build.0 = NET45-Debug|Any CPU - {47681067-0B27-4B18-819C-0A2F3D0DB2D6}.NET45-Release|Any CPU.ActiveCfg = NET45-Release|Any CPU - {47681067-0B27-4B18-819C-0A2F3D0DB2D6}.NET45-Release|Any CPU.Build.0 = NET45-Release|Any CPU - {D1102CFD-63B5-4587-AB70-AF59B7FB28E1}.NET40-Debug|Any CPU.ActiveCfg = NET40-Debug|Any CPU - {D1102CFD-63B5-4587-AB70-AF59B7FB28E1}.NET40-Debug|Any CPU.Build.0 = NET40-Debug|Any CPU - {D1102CFD-63B5-4587-AB70-AF59B7FB28E1}.NET40-Release|Any CPU.ActiveCfg = NET40-Release|Any CPU - {D1102CFD-63B5-4587-AB70-AF59B7FB28E1}.NET40-Release|Any CPU.Build.0 = NET40-Release|Any CPU - {D1102CFD-63B5-4587-AB70-AF59B7FB28E1}.NET45-Debug|Any CPU.ActiveCfg = NET45-Debug|Any CPU - {D1102CFD-63B5-4587-AB70-AF59B7FB28E1}.NET45-Debug|Any CPU.Build.0 = NET45-Debug|Any CPU - {D1102CFD-63B5-4587-AB70-AF59B7FB28E1}.NET45-Release|Any CPU.ActiveCfg = NET45-Release|Any CPU - {D1102CFD-63B5-4587-AB70-AF59B7FB28E1}.NET45-Release|Any CPU.Build.0 = NET45-Release|Any CPU - {B6C02C50-E493-408C-9649-2872CB591FA0}.NET40-Debug|Any CPU.ActiveCfg = NET40-Debug|Any CPU - {B6C02C50-E493-408C-9649-2872CB591FA0}.NET40-Debug|Any CPU.Build.0 = NET40-Debug|Any CPU - {B6C02C50-E493-408C-9649-2872CB591FA0}.NET40-Release|Any CPU.ActiveCfg = NET40-Release|Any CPU - {B6C02C50-E493-408C-9649-2872CB591FA0}.NET40-Release|Any CPU.Build.0 = NET40-Release|Any CPU - {B6C02C50-E493-408C-9649-2872CB591FA0}.NET45-Debug|Any CPU.ActiveCfg = NET45-Debug|Any CPU - {B6C02C50-E493-408C-9649-2872CB591FA0}.NET45-Debug|Any CPU.Build.0 = NET45-Debug|Any CPU - {B6C02C50-E493-408C-9649-2872CB591FA0}.NET45-Release|Any CPU.ActiveCfg = NET45-Release|Any CPU - {B6C02C50-E493-408C-9649-2872CB591FA0}.NET45-Release|Any CPU.Build.0 = NET45-Release|Any CPU - {C8C529ED-68D6-4877-9D1A-78E34AA1465F}.NET40-Debug|Any CPU.ActiveCfg = NET40-Debug|Any CPU - {C8C529ED-68D6-4877-9D1A-78E34AA1465F}.NET40-Debug|Any CPU.Build.0 = NET40-Debug|Any CPU - {C8C529ED-68D6-4877-9D1A-78E34AA1465F}.NET40-Release|Any CPU.ActiveCfg = NET40-Release|Any CPU - {C8C529ED-68D6-4877-9D1A-78E34AA1465F}.NET40-Release|Any CPU.Build.0 = NET40-Release|Any CPU - {C8C529ED-68D6-4877-9D1A-78E34AA1465F}.NET45-Debug|Any CPU.ActiveCfg = NET45-Debug|Any CPU - {C8C529ED-68D6-4877-9D1A-78E34AA1465F}.NET45-Debug|Any CPU.Build.0 = NET45-Debug|Any CPU - {C8C529ED-68D6-4877-9D1A-78E34AA1465F}.NET45-Release|Any CPU.ActiveCfg = NET45-Release|Any CPU - {C8C529ED-68D6-4877-9D1A-78E34AA1465F}.NET45-Release|Any CPU.Build.0 = NET45-Release|Any CPU - {9B28439F-F207-4669-8C89-E5CD86098FCC}.NET40-Debug|Any CPU.ActiveCfg = NET40-Debug|Any CPU - {9B28439F-F207-4669-8C89-E5CD86098FCC}.NET40-Debug|Any CPU.Build.0 = NET40-Debug|Any CPU - {9B28439F-F207-4669-8C89-E5CD86098FCC}.NET40-Release|Any CPU.ActiveCfg = NET40-Release|Any CPU - {9B28439F-F207-4669-8C89-E5CD86098FCC}.NET40-Release|Any CPU.Build.0 = NET40-Release|Any CPU - {9B28439F-F207-4669-8C89-E5CD86098FCC}.NET45-Debug|Any CPU.ActiveCfg = NET45-Debug|Any CPU - {9B28439F-F207-4669-8C89-E5CD86098FCC}.NET45-Debug|Any CPU.Build.0 = NET45-Debug|Any CPU - {9B28439F-F207-4669-8C89-E5CD86098FCC}.NET45-Release|Any CPU.ActiveCfg = NET45-Release|Any CPU - {9B28439F-F207-4669-8C89-E5CD86098FCC}.NET45-Release|Any CPU.Build.0 = NET45-Release|Any CPU - {3F3A6A53-D90C-41B6-88FF-D211DE0857D3}.NET40-Debug|Any CPU.ActiveCfg = NET40-Debug|Any CPU - {3F3A6A53-D90C-41B6-88FF-D211DE0857D3}.NET40-Debug|Any CPU.Build.0 = NET40-Debug|Any CPU - {3F3A6A53-D90C-41B6-88FF-D211DE0857D3}.NET40-Release|Any CPU.ActiveCfg = NET40-Release|Any CPU - {3F3A6A53-D90C-41B6-88FF-D211DE0857D3}.NET40-Release|Any CPU.Build.0 = NET40-Release|Any CPU - {3F3A6A53-D90C-41B6-88FF-D211DE0857D3}.NET45-Debug|Any CPU.ActiveCfg = NET45-Debug|Any CPU - {3F3A6A53-D90C-41B6-88FF-D211DE0857D3}.NET45-Debug|Any CPU.Build.0 = NET45-Debug|Any CPU - {3F3A6A53-D90C-41B6-88FF-D211DE0857D3}.NET45-Release|Any CPU.ActiveCfg = NET45-Release|Any CPU - {3F3A6A53-D90C-41B6-88FF-D211DE0857D3}.NET45-Release|Any CPU.Build.0 = NET45-Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {CF658F2A-8ACD-4328-85B4-122C9429D535} = {558C50A4-F5C9-4B52-8414-69E08CA86994} - {5EBFCC82-B3AE-4B51-AFC0-0BFFDD262DF7} = {558C50A4-F5C9-4B52-8414-69E08CA86994} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Snap", "Snap\Snap.csproj", "{C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Snap.Autofac", "Snap.Autofac\Snap.Autofac.csproj", "{47681067-0B27-4B18-819C-0A2F3D0DB2D6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Snap.CastleWindsor", "Snap.CastleWindsor\Snap.CastleWindsor.csproj", "{D1102CFD-63B5-4587-AB70-AF59B7FB28E1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Snap.LinFu", "Snap.LinFu\Snap.LinFu.csproj", "{B6C02C50-E493-408C-9649-2872CB591FA0}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Snap.Ninject", "Snap.Ninject\Snap.Ninject.csproj", "{C8C529ED-68D6-4877-9D1A-78E34AA1465F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Snap.StructureMap", "Snap.StructureMap\Snap.StructureMap.csproj", "{9B28439F-F207-4669-8C89-E5CD86098FCC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Snap.Tests", "Snap.Tests\Snap.Tests.csproj", "{3F3A6A53-D90C-41B6-88FF-D211DE0857D3}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{558C50A4-F5C9-4B52-8414-69E08CA86994}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Specs", "Specs", "{CF658F2A-8ACD-4328-85B4-122C9429D535}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{5EBFCC82-B3AE-4B51-AFC0-0BFFDD262DF7}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{84EE23F7-9EA4-42BD-97E5-BB208468631D}" + ProjectSection(SolutionItems) = preProject + .nuget\packages.config = .nuget\packages.config + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Snap.SimpleInjector", "Snap.SimpleInjector\Snap.SimpleInjector.csproj", "{8ADE2FD7-93B9-4936-8B7B-34DB14443C9A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + NET40-Debug|Any CPU = NET40-Debug|Any CPU + NET40-Release|Any CPU = NET40-Release|Any CPU + NET45-Debug|Any CPU = NET45-Debug|Any CPU + NET45-Release|Any CPU = NET45-Release|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}.Debug|Any CPU.ActiveCfg = NET35-Debug|Any CPU + {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}.Debug|Any CPU.Build.0 = NET35-Debug|Any CPU + {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}.NET40-Debug|Any CPU.ActiveCfg = NET40-Debug|Any CPU + {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}.NET40-Debug|Any CPU.Build.0 = NET40-Debug|Any CPU + {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}.NET40-Release|Any CPU.ActiveCfg = NET40-Release|Any CPU + {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}.NET40-Release|Any CPU.Build.0 = NET40-Release|Any CPU + {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}.NET45-Debug|Any CPU.ActiveCfg = NET45-Debug|Any CPU + {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}.NET45-Debug|Any CPU.Build.0 = NET45-Debug|Any CPU + {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}.NET45-Release|Any CPU.ActiveCfg = NET45-Release|Any CPU + {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}.NET45-Release|Any CPU.Build.0 = NET45-Release|Any CPU + {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}.Release|Any CPU.ActiveCfg = NET35-Release|Any CPU + {C1B09D15-F861-48F4-8DA3-FEC0E03CA0FC}.Release|Any CPU.Build.0 = NET35-Release|Any CPU + {47681067-0B27-4B18-819C-0A2F3D0DB2D6}.Debug|Any CPU.ActiveCfg = NET35-Debug|Any CPU + {47681067-0B27-4B18-819C-0A2F3D0DB2D6}.Debug|Any CPU.Build.0 = NET35-Debug|Any CPU + {47681067-0B27-4B18-819C-0A2F3D0DB2D6}.NET40-Debug|Any CPU.ActiveCfg = NET40-Debug|Any CPU + {47681067-0B27-4B18-819C-0A2F3D0DB2D6}.NET40-Debug|Any CPU.Build.0 = NET40-Debug|Any CPU + {47681067-0B27-4B18-819C-0A2F3D0DB2D6}.NET40-Release|Any CPU.ActiveCfg = NET40-Release|Any CPU + {47681067-0B27-4B18-819C-0A2F3D0DB2D6}.NET40-Release|Any CPU.Build.0 = NET40-Release|Any CPU + {47681067-0B27-4B18-819C-0A2F3D0DB2D6}.NET45-Debug|Any CPU.ActiveCfg = NET45-Debug|Any CPU + {47681067-0B27-4B18-819C-0A2F3D0DB2D6}.NET45-Debug|Any CPU.Build.0 = NET45-Debug|Any CPU + {47681067-0B27-4B18-819C-0A2F3D0DB2D6}.NET45-Release|Any CPU.ActiveCfg = NET45-Release|Any CPU + {47681067-0B27-4B18-819C-0A2F3D0DB2D6}.NET45-Release|Any CPU.Build.0 = NET45-Release|Any CPU + {47681067-0B27-4B18-819C-0A2F3D0DB2D6}.Release|Any CPU.ActiveCfg = NET35-Release|Any CPU + {47681067-0B27-4B18-819C-0A2F3D0DB2D6}.Release|Any CPU.Build.0 = NET35-Release|Any CPU + {D1102CFD-63B5-4587-AB70-AF59B7FB28E1}.Debug|Any CPU.ActiveCfg = NET35-Debug|Any CPU + {D1102CFD-63B5-4587-AB70-AF59B7FB28E1}.Debug|Any CPU.Build.0 = NET35-Debug|Any CPU + {D1102CFD-63B5-4587-AB70-AF59B7FB28E1}.NET40-Debug|Any CPU.ActiveCfg = NET40-Debug|Any CPU + {D1102CFD-63B5-4587-AB70-AF59B7FB28E1}.NET40-Debug|Any CPU.Build.0 = NET40-Debug|Any CPU + {D1102CFD-63B5-4587-AB70-AF59B7FB28E1}.NET40-Release|Any CPU.ActiveCfg = NET40-Release|Any CPU + {D1102CFD-63B5-4587-AB70-AF59B7FB28E1}.NET40-Release|Any CPU.Build.0 = NET40-Release|Any CPU + {D1102CFD-63B5-4587-AB70-AF59B7FB28E1}.NET45-Debug|Any CPU.ActiveCfg = NET45-Debug|Any CPU + {D1102CFD-63B5-4587-AB70-AF59B7FB28E1}.NET45-Debug|Any CPU.Build.0 = NET45-Debug|Any CPU + {D1102CFD-63B5-4587-AB70-AF59B7FB28E1}.NET45-Release|Any CPU.ActiveCfg = NET45-Release|Any CPU + {D1102CFD-63B5-4587-AB70-AF59B7FB28E1}.NET45-Release|Any CPU.Build.0 = NET45-Release|Any CPU + {D1102CFD-63B5-4587-AB70-AF59B7FB28E1}.Release|Any CPU.ActiveCfg = NET35-Release|Any CPU + {D1102CFD-63B5-4587-AB70-AF59B7FB28E1}.Release|Any CPU.Build.0 = NET35-Release|Any CPU + {B6C02C50-E493-408C-9649-2872CB591FA0}.Debug|Any CPU.ActiveCfg = NET35-Debug|Any CPU + {B6C02C50-E493-408C-9649-2872CB591FA0}.Debug|Any CPU.Build.0 = NET35-Debug|Any CPU + {B6C02C50-E493-408C-9649-2872CB591FA0}.NET40-Debug|Any CPU.ActiveCfg = NET40-Debug|Any CPU + {B6C02C50-E493-408C-9649-2872CB591FA0}.NET40-Debug|Any CPU.Build.0 = NET40-Debug|Any CPU + {B6C02C50-E493-408C-9649-2872CB591FA0}.NET40-Release|Any CPU.ActiveCfg = NET40-Release|Any CPU + {B6C02C50-E493-408C-9649-2872CB591FA0}.NET40-Release|Any CPU.Build.0 = NET40-Release|Any CPU + {B6C02C50-E493-408C-9649-2872CB591FA0}.NET45-Debug|Any CPU.ActiveCfg = NET45-Debug|Any CPU + {B6C02C50-E493-408C-9649-2872CB591FA0}.NET45-Debug|Any CPU.Build.0 = NET45-Debug|Any CPU + {B6C02C50-E493-408C-9649-2872CB591FA0}.NET45-Release|Any CPU.ActiveCfg = NET45-Release|Any CPU + {B6C02C50-E493-408C-9649-2872CB591FA0}.NET45-Release|Any CPU.Build.0 = NET45-Release|Any CPU + {B6C02C50-E493-408C-9649-2872CB591FA0}.Release|Any CPU.ActiveCfg = NET35-Release|Any CPU + {B6C02C50-E493-408C-9649-2872CB591FA0}.Release|Any CPU.Build.0 = NET35-Release|Any CPU + {C8C529ED-68D6-4877-9D1A-78E34AA1465F}.Debug|Any CPU.ActiveCfg = NET35-Debug|Any CPU + {C8C529ED-68D6-4877-9D1A-78E34AA1465F}.Debug|Any CPU.Build.0 = NET35-Debug|Any CPU + {C8C529ED-68D6-4877-9D1A-78E34AA1465F}.NET40-Debug|Any CPU.ActiveCfg = NET40-Debug|Any CPU + {C8C529ED-68D6-4877-9D1A-78E34AA1465F}.NET40-Debug|Any CPU.Build.0 = NET40-Debug|Any CPU + {C8C529ED-68D6-4877-9D1A-78E34AA1465F}.NET40-Release|Any CPU.ActiveCfg = NET40-Release|Any CPU + {C8C529ED-68D6-4877-9D1A-78E34AA1465F}.NET40-Release|Any CPU.Build.0 = NET40-Release|Any CPU + {C8C529ED-68D6-4877-9D1A-78E34AA1465F}.NET45-Debug|Any CPU.ActiveCfg = NET45-Debug|Any CPU + {C8C529ED-68D6-4877-9D1A-78E34AA1465F}.NET45-Debug|Any CPU.Build.0 = NET45-Debug|Any CPU + {C8C529ED-68D6-4877-9D1A-78E34AA1465F}.NET45-Release|Any CPU.ActiveCfg = NET45-Release|Any CPU + {C8C529ED-68D6-4877-9D1A-78E34AA1465F}.NET45-Release|Any CPU.Build.0 = NET45-Release|Any CPU + {C8C529ED-68D6-4877-9D1A-78E34AA1465F}.Release|Any CPU.ActiveCfg = NET35-Release|Any CPU + {C8C529ED-68D6-4877-9D1A-78E34AA1465F}.Release|Any CPU.Build.0 = NET35-Release|Any CPU + {9B28439F-F207-4669-8C89-E5CD86098FCC}.Debug|Any CPU.ActiveCfg = NET35-Debug|Any CPU + {9B28439F-F207-4669-8C89-E5CD86098FCC}.Debug|Any CPU.Build.0 = NET35-Debug|Any CPU + {9B28439F-F207-4669-8C89-E5CD86098FCC}.NET40-Debug|Any CPU.ActiveCfg = NET40-Debug|Any CPU + {9B28439F-F207-4669-8C89-E5CD86098FCC}.NET40-Debug|Any CPU.Build.0 = NET40-Debug|Any CPU + {9B28439F-F207-4669-8C89-E5CD86098FCC}.NET40-Release|Any CPU.ActiveCfg = NET40-Release|Any CPU + {9B28439F-F207-4669-8C89-E5CD86098FCC}.NET40-Release|Any CPU.Build.0 = NET40-Release|Any CPU + {9B28439F-F207-4669-8C89-E5CD86098FCC}.NET45-Debug|Any CPU.ActiveCfg = NET45-Debug|Any CPU + {9B28439F-F207-4669-8C89-E5CD86098FCC}.NET45-Debug|Any CPU.Build.0 = NET45-Debug|Any CPU + {9B28439F-F207-4669-8C89-E5CD86098FCC}.NET45-Release|Any CPU.ActiveCfg = NET45-Release|Any CPU + {9B28439F-F207-4669-8C89-E5CD86098FCC}.NET45-Release|Any CPU.Build.0 = NET45-Release|Any CPU + {9B28439F-F207-4669-8C89-E5CD86098FCC}.Release|Any CPU.ActiveCfg = NET35-Release|Any CPU + {9B28439F-F207-4669-8C89-E5CD86098FCC}.Release|Any CPU.Build.0 = NET35-Release|Any CPU + {3F3A6A53-D90C-41B6-88FF-D211DE0857D3}.Debug|Any CPU.ActiveCfg = NET35-Debug|Any CPU + {3F3A6A53-D90C-41B6-88FF-D211DE0857D3}.Debug|Any CPU.Build.0 = NET35-Debug|Any CPU + {3F3A6A53-D90C-41B6-88FF-D211DE0857D3}.NET40-Debug|Any CPU.ActiveCfg = NET40-Debug|Any CPU + {3F3A6A53-D90C-41B6-88FF-D211DE0857D3}.NET40-Debug|Any CPU.Build.0 = NET40-Debug|Any CPU + {3F3A6A53-D90C-41B6-88FF-D211DE0857D3}.NET40-Release|Any CPU.ActiveCfg = NET40-Release|Any CPU + {3F3A6A53-D90C-41B6-88FF-D211DE0857D3}.NET40-Release|Any CPU.Build.0 = NET40-Release|Any CPU + {3F3A6A53-D90C-41B6-88FF-D211DE0857D3}.NET45-Debug|Any CPU.ActiveCfg = NET45-Debug|Any CPU + {3F3A6A53-D90C-41B6-88FF-D211DE0857D3}.NET45-Debug|Any CPU.Build.0 = NET45-Debug|Any CPU + {3F3A6A53-D90C-41B6-88FF-D211DE0857D3}.NET45-Release|Any CPU.ActiveCfg = NET45-Release|Any CPU + {3F3A6A53-D90C-41B6-88FF-D211DE0857D3}.NET45-Release|Any CPU.Build.0 = NET45-Release|Any CPU + {3F3A6A53-D90C-41B6-88FF-D211DE0857D3}.Release|Any CPU.ActiveCfg = NET35-Release|Any CPU + {3F3A6A53-D90C-41B6-88FF-D211DE0857D3}.Release|Any CPU.Build.0 = NET35-Release|Any CPU + {8ADE2FD7-93B9-4936-8B7B-34DB14443C9A}.Debug|Any CPU.ActiveCfg = NET45-Debug|Any CPU + {8ADE2FD7-93B9-4936-8B7B-34DB14443C9A}.Debug|Any CPU.Build.0 = NET45-Debug|Any CPU + {8ADE2FD7-93B9-4936-8B7B-34DB14443C9A}.NET40-Debug|Any CPU.ActiveCfg = NET40-Debug|Any CPU + {8ADE2FD7-93B9-4936-8B7B-34DB14443C9A}.NET40-Debug|Any CPU.Build.0 = NET40-Debug|Any CPU + {8ADE2FD7-93B9-4936-8B7B-34DB14443C9A}.NET40-Release|Any CPU.ActiveCfg = NET40-Release|Any CPU + {8ADE2FD7-93B9-4936-8B7B-34DB14443C9A}.NET40-Release|Any CPU.Build.0 = NET40-Release|Any CPU + {8ADE2FD7-93B9-4936-8B7B-34DB14443C9A}.NET45-Debug|Any CPU.ActiveCfg = NET45-Debug|Any CPU + {8ADE2FD7-93B9-4936-8B7B-34DB14443C9A}.NET45-Debug|Any CPU.Build.0 = NET45-Debug|Any CPU + {8ADE2FD7-93B9-4936-8B7B-34DB14443C9A}.NET45-Release|Any CPU.ActiveCfg = NET45-Release|Any CPU + {8ADE2FD7-93B9-4936-8B7B-34DB14443C9A}.NET45-Release|Any CPU.Build.0 = NET45-Release|Any CPU + {8ADE2FD7-93B9-4936-8B7B-34DB14443C9A}.Release|Any CPU.ActiveCfg = NET45-Release|Any CPU + {8ADE2FD7-93B9-4936-8B7B-34DB14443C9A}.Release|Any CPU.Build.0 = NET45-Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {CF658F2A-8ACD-4328-85B4-122C9429D535} = {558C50A4-F5C9-4B52-8414-69E08CA86994} + {5EBFCC82-B3AE-4B51-AFC0-0BFFDD262DF7} = {558C50A4-F5C9-4B52-8414-69E08CA86994} + EndGlobalSection +EndGlobal diff --git a/Snap/AspectUtility.cs b/Snap/AspectUtility.cs index b20f1ed..6673741 100644 --- a/Snap/AspectUtility.cs +++ b/Snap/AspectUtility.cs @@ -42,14 +42,28 @@ public static class AspectUtility /// true if the specified target is decorated; otherwise, false. /// public static bool IsDecorated(this object target, AspectConfiguration configuration) - { - var type = target.GetType(); - var methods = type.Methods(); + { + return IsDecorated(target.GetType(), configuration); + } + + /// + /// Determines whether the specified target type has methods decorated for interception. + /// + /// The target. + /// The configuration. + /// + /// true if the specified target is decorated; otherwise, false. + /// + public static bool IsDecorated(Type targetType, AspectConfiguration configuration) + { + var methods = targetType.Methods(); + + var isDecorated = methods.Any(m => m.Attributes().Any(a => a is MethodInterceptAttribute)) || targetType.Attributes().Any(p => p is ClassInterceptAttribute); + + return isDecorated; + } - var isDecorated = methods.Any(m => m.Attributes().Any(a => a is MethodInterceptAttribute)) || type.Attributes().Any(p => p is ClassInterceptAttribute); - return isDecorated; - } /// /// Gets the first type that matches the target namespace. /// diff --git a/packages/CommonServiceLocator.SimpleInjectorAdapter.2.6.1/CommonServiceLocator.SimpleInjectorAdapter.2.6.1.nupkg b/packages/CommonServiceLocator.SimpleInjectorAdapter.2.6.1/CommonServiceLocator.SimpleInjectorAdapter.2.6.1.nupkg new file mode 100644 index 0000000..1216f2f Binary files /dev/null and b/packages/CommonServiceLocator.SimpleInjectorAdapter.2.6.1/CommonServiceLocator.SimpleInjectorAdapter.2.6.1.nupkg differ diff --git a/packages/CommonServiceLocator.SimpleInjectorAdapter.2.6.1/lib/portable-net4+sl4+wp8+win8+wpa81/CommonServiceLocator.SimpleInjectorAdapter.xml b/packages/CommonServiceLocator.SimpleInjectorAdapter.2.6.1/lib/portable-net4+sl4+wp8+win8+wpa81/CommonServiceLocator.SimpleInjectorAdapter.xml new file mode 100644 index 0000000..2a9aa19 --- /dev/null +++ b/packages/CommonServiceLocator.SimpleInjectorAdapter.2.6.1/lib/portable-net4+sl4+wp8+win8+wpa81/CommonServiceLocator.SimpleInjectorAdapter.xml @@ -0,0 +1,86 @@ + + + + CommonServiceLocator.SimpleInjectorAdapter + + + + + Translates calls from to Simple Injector's container. + + + + + Initializes a new instance of the class. + + The to adapt. + + + + Get all instances of the given currently + registered in the container. + + Type of object requested. + Thrown when there is are errors resolving + the service instance. + A sequence of instances of the requested . + + + + Get all instances of the given currently + registered in the container. + + Type of object requested. + Thrown when there is are errors resolving + the service instance. + A sequence of instances of the requested . + + + + Get an instance of the given named . + + Type of object requested. + Name the object was registered with. + Thrown when there is are errors resolving + the service instance. + Thrown when a non-null key is requested. Keyed + registration is not supported by the Simple Injector. + The requested service instance. + + + + Get an instance of the given . + + Type of object requested. + Thrown when there is are errors resolving + the service instance. + The requested service instance. + + + + Get an instance of the given named . + + Type of object requested. + Name the object was registered with. + Thrown when there is an error resolving + the service instance. + Thrown when a non-null key is requested. Keyed + registration is not supported by the Simple Injector. + The requested service instance. + + + + Get an instance of the given . + + Type of object requested. + Thrown when there is an error resolving + the service instance. + The requested service instance. + + + Gets the service object of the specified type. + A service object of type serviceType.-or- null if there is no service object of type serviceType. + An object that specifies the type of service object to get. + + + diff --git a/packages/Portable.CommonServiceLocator.1.2.2/Portable.CommonServiceLocator.1.2.2.nupkg b/packages/Portable.CommonServiceLocator.1.2.2/Portable.CommonServiceLocator.1.2.2.nupkg new file mode 100644 index 0000000..678107f Binary files /dev/null and b/packages/Portable.CommonServiceLocator.1.2.2/Portable.CommonServiceLocator.1.2.2.nupkg differ diff --git a/packages/Portable.CommonServiceLocator.1.2.2/lib/net35/Microsoft.Practices.ServiceLocation.XML b/packages/Portable.CommonServiceLocator.1.2.2/lib/net35/Microsoft.Practices.ServiceLocation.XML new file mode 100644 index 0000000..fb5136c --- /dev/null +++ b/packages/Portable.CommonServiceLocator.1.2.2/lib/net35/Microsoft.Practices.ServiceLocation.XML @@ -0,0 +1,280 @@ + + + + Microsoft.Practices.ServiceLocation + + + + + The standard exception thrown when a ServiceLocator has an error in resolving an object. + + + + + Initializes a new instance of the class. + + + + + Initializes a new instance of the class with a specified error message. + + + The message that describes the error. + + + + + Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. + + + The error message that explains the reason for the exception. + + + The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified. + + + + + Initializes a new instance of the class with serialized data. + + + The that holds the serialized object data about the exception being thrown. + + + The that contains contextual information about the source or destination. + + + The parameter is null. + + + The class name is null or is zero (0). + + + + + The generic Service Locator interface. This interface is used + to retrieve services (instances identified by type and optional + name) from a container. + + + + + Get an instance of the given . + + Type of object requested. + if there is an error resolving + the service instance. + The requested service instance. + + + + Get an instance of the given named . + + Type of object requested. + Name the object was registered with. + if there is an error resolving + the service instance. + The requested service instance. + + + + Get all instances of the given currently + registered in the container. + + Type of object requested. + if there is are errors resolving + the service instance. + A sequence of instances of the requested . + + + + Get an instance of the given . + + Type of object requested. + if there is are errors resolving + the service instance. + The requested service instance. + + + + Get an instance of the given named . + + Type of object requested. + Name the object was registered with. + if there is are errors resolving + the service instance. + The requested service instance. + + + + Get all instances of the given currently + registered in the container. + + Type of object requested. + if there is are errors resolving + the service instance. + A sequence of instances of the requested . + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + + Returns the cached ResourceManager instance used by this class. + + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + + Looks up a localized string similar to Activation error occured while trying to get all instances of type {0}. + + + + + Looks up a localized string similar to Activation error occured while trying to get instance of type {0}, key "{1}". + + + + + This class provides the ambient container for this application. If your + framework defines such an ambient container, use ServiceLocator.Current + to get it. + + + + + Set the delegate that is used to retrieve the current container. + + Delegate that, when called, will return + the current ambient container. + + + + The current ambient container. + + + + + This class is a helper that provides a default implementation + for most of the methods of . + + + + + Implementation of . + + The requested service. + if there is an error in resolving the service instance. + The requested object. + + + + Get an instance of the given . + + Type of object requested. + if there is an error resolving + the service instance. + The requested service instance. + + + + Get an instance of the given named . + + Type of object requested. + Name the object was registered with. + if there is an error resolving + the service instance. + The requested service instance. + + + + Get all instances of the given currently + registered in the container. + + Type of object requested. + if there is are errors resolving + the service instance. + A sequence of instances of the requested . + + + + Get an instance of the given . + + Type of object requested. + if there is are errors resolving + the service instance. + The requested service instance. + + + + Get an instance of the given named . + + Type of object requested. + Name the object was registered with. + if there is are errors resolving + the service instance. + The requested service instance. + + + + Get all instances of the given currently + registered in the container. + + Type of object requested. + if there is are errors resolving + the service instance. + A sequence of instances of the requested . + + + + When implemented by inheriting classes, this method will do the actual work of resolving + the requested service instance. + + Type of instance requested. + Name of registered service you want. May be null. + The requested service instance. + + + + When implemented by inheriting classes, this method will do the actual work of + resolving all the requested service instances. + + Type of service requested. + Sequence of service instance objects. + + + + Format the exception message for use in an + that occurs while resolving a single service. + + The actual exception thrown by the implementation. + Type of service requested. + Name requested. + The formatted exception message string. + + + + Format the exception message for use in an + that occurs while resolving multiple service instances. + + The actual exception thrown by the implementation. + Type of service requested. + The formatted exception message string. + + + + This delegate type is used to provide a method that will + return the current container. Used with the + static accessor class. + + An . + + + diff --git a/packages/Portable.CommonServiceLocator.1.2.2/lib/portable-net4+sl4+wp7+win8/Microsoft.Practices.ServiceLocation.XML b/packages/Portable.CommonServiceLocator.1.2.2/lib/portable-net4+sl4+wp7+win8/Microsoft.Practices.ServiceLocation.XML new file mode 100644 index 0000000..d22c86a --- /dev/null +++ b/packages/Portable.CommonServiceLocator.1.2.2/lib/portable-net4+sl4+wp7+win8/Microsoft.Practices.ServiceLocation.XML @@ -0,0 +1,263 @@ + + + + Microsoft.Practices.ServiceLocation + + + + + The standard exception thrown when a ServiceLocator has an error in resolving an object. + + + + + Initializes a new instance of the class. + + + + + Initializes a new instance of the class with a specified error message. + + + The message that describes the error. + + + + + Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. + + + The error message that explains the reason for the exception. + + + The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified. + + + + + The generic Service Locator interface. This interface is used + to retrieve services (instances identified by type and optional + name) from a container. + + + + + Get an instance of the given . + + Type of object requested. + if there is an error resolving + the service instance. + The requested service instance. + + + + Get an instance of the given named . + + Type of object requested. + Name the object was registered with. + if there is an error resolving + the service instance. + The requested service instance. + + + + Get all instances of the given currently + registered in the container. + + Type of object requested. + if there is are errors resolving + the service instance. + A sequence of instances of the requested . + + + + Get an instance of the given . + + Type of object requested. + if there is are errors resolving + the service instance. + The requested service instance. + + + + Get an instance of the given named . + + Type of object requested. + Name the object was registered with. + if there is are errors resolving + the service instance. + The requested service instance. + + + + Get all instances of the given currently + registered in the container. + + Type of object requested. + if there is are errors resolving + the service instance. + A sequence of instances of the requested . + + + + This class provides the ambient container for this application. If your + framework defines such an ambient container, use ServiceLocator.Current + to get it. + + + + + Set the delegate that is used to retrieve the current container. + + Delegate that, when called, will return + the current ambient container. + + + + The current ambient container. + + + + + This class is a helper that provides a default implementation + for most of the methods of . + + + + + Implementation of . + + The requested service. + if there is an error in resolving the service instance. + The requested object. + + + + Get an instance of the given . + + Type of object requested. + if there is an error resolving + the service instance. + The requested service instance. + + + + Get an instance of the given named . + + Type of object requested. + Name the object was registered with. + if there is an error resolving + the service instance. + The requested service instance. + + + + Get all instances of the given currently + registered in the container. + + Type of object requested. + if there is are errors resolving + the service instance. + A sequence of instances of the requested . + + + + Get an instance of the given . + + Type of object requested. + if there is are errors resolving + the service instance. + The requested service instance. + + + + Get an instance of the given named . + + Type of object requested. + Name the object was registered with. + if there is are errors resolving + the service instance. + The requested service instance. + + + + Get all instances of the given currently + registered in the container. + + Type of object requested. + if there is are errors resolving + the service instance. + A sequence of instances of the requested . + + + + When implemented by inheriting classes, this method will do the actual work of resolving + the requested service instance. + + Type of instance requested. + Name of registered service you want. May be null. + The requested service instance. + + + + When implemented by inheriting classes, this method will do the actual work of + resolving all the requested service instances. + + Type of service requested. + Sequence of service instance objects. + + + + Format the exception message for use in an + that occurs while resolving a single service. + + The actual exception thrown by the implementation. + Type of service requested. + Name requested. + The formatted exception message string. + + + + Format the exception message for use in an + that occurs while resolving multiple service instances. + + The actual exception thrown by the implementation. + Type of service requested. + The formatted exception message string. + + + + This delegate type is used to provide a method that will + return the current container. Used with the + static accessor class. + + An . + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + + Returns the cached ResourceManager instance used by this class. + + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + + Looks up a localized string similar to Activation error occured while trying to get all instances of type {0}. + + + + + Looks up a localized string similar to Activation error occured while trying to get instance of type {0}, key "{1}". + + + + diff --git a/packages/Portable.CommonServiceLocator.1.2.2/lib/sl30/Microsoft.Practices.ServiceLocation.XML b/packages/Portable.CommonServiceLocator.1.2.2/lib/sl30/Microsoft.Practices.ServiceLocation.XML new file mode 100644 index 0000000..fb5136c --- /dev/null +++ b/packages/Portable.CommonServiceLocator.1.2.2/lib/sl30/Microsoft.Practices.ServiceLocation.XML @@ -0,0 +1,280 @@ + + + + Microsoft.Practices.ServiceLocation + + + + + The standard exception thrown when a ServiceLocator has an error in resolving an object. + + + + + Initializes a new instance of the class. + + + + + Initializes a new instance of the class with a specified error message. + + + The message that describes the error. + + + + + Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. + + + The error message that explains the reason for the exception. + + + The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified. + + + + + Initializes a new instance of the class with serialized data. + + + The that holds the serialized object data about the exception being thrown. + + + The that contains contextual information about the source or destination. + + + The parameter is null. + + + The class name is null or is zero (0). + + + + + The generic Service Locator interface. This interface is used + to retrieve services (instances identified by type and optional + name) from a container. + + + + + Get an instance of the given . + + Type of object requested. + if there is an error resolving + the service instance. + The requested service instance. + + + + Get an instance of the given named . + + Type of object requested. + Name the object was registered with. + if there is an error resolving + the service instance. + The requested service instance. + + + + Get all instances of the given currently + registered in the container. + + Type of object requested. + if there is are errors resolving + the service instance. + A sequence of instances of the requested . + + + + Get an instance of the given . + + Type of object requested. + if there is are errors resolving + the service instance. + The requested service instance. + + + + Get an instance of the given named . + + Type of object requested. + Name the object was registered with. + if there is are errors resolving + the service instance. + The requested service instance. + + + + Get all instances of the given currently + registered in the container. + + Type of object requested. + if there is are errors resolving + the service instance. + A sequence of instances of the requested . + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + + Returns the cached ResourceManager instance used by this class. + + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + + Looks up a localized string similar to Activation error occured while trying to get all instances of type {0}. + + + + + Looks up a localized string similar to Activation error occured while trying to get instance of type {0}, key "{1}". + + + + + This class provides the ambient container for this application. If your + framework defines such an ambient container, use ServiceLocator.Current + to get it. + + + + + Set the delegate that is used to retrieve the current container. + + Delegate that, when called, will return + the current ambient container. + + + + The current ambient container. + + + + + This class is a helper that provides a default implementation + for most of the methods of . + + + + + Implementation of . + + The requested service. + if there is an error in resolving the service instance. + The requested object. + + + + Get an instance of the given . + + Type of object requested. + if there is an error resolving + the service instance. + The requested service instance. + + + + Get an instance of the given named . + + Type of object requested. + Name the object was registered with. + if there is an error resolving + the service instance. + The requested service instance. + + + + Get all instances of the given currently + registered in the container. + + Type of object requested. + if there is are errors resolving + the service instance. + A sequence of instances of the requested . + + + + Get an instance of the given . + + Type of object requested. + if there is are errors resolving + the service instance. + The requested service instance. + + + + Get an instance of the given named . + + Type of object requested. + Name the object was registered with. + if there is are errors resolving + the service instance. + The requested service instance. + + + + Get all instances of the given currently + registered in the container. + + Type of object requested. + if there is are errors resolving + the service instance. + A sequence of instances of the requested . + + + + When implemented by inheriting classes, this method will do the actual work of resolving + the requested service instance. + + Type of instance requested. + Name of registered service you want. May be null. + The requested service instance. + + + + When implemented by inheriting classes, this method will do the actual work of + resolving all the requested service instances. + + Type of service requested. + Sequence of service instance objects. + + + + Format the exception message for use in an + that occurs while resolving a single service. + + The actual exception thrown by the implementation. + Type of service requested. + Name requested. + The formatted exception message string. + + + + Format the exception message for use in an + that occurs while resolving multiple service instances. + + The actual exception thrown by the implementation. + Type of service requested. + The formatted exception message string. + + + + This delegate type is used to provide a method that will + return the current container. Used with the + static accessor class. + + An . + + + diff --git a/packages/SimpleInjector.2.6.1/SimpleInjector.2.6.1.nupkg b/packages/SimpleInjector.2.6.1/SimpleInjector.2.6.1.nupkg new file mode 100644 index 0000000..39936a1 Binary files /dev/null and b/packages/SimpleInjector.2.6.1/SimpleInjector.2.6.1.nupkg differ diff --git a/packages/SimpleInjector.2.6.1/lib/net40-client/SimpleInjector.Diagnostics.xml b/packages/SimpleInjector.2.6.1/lib/net40-client/SimpleInjector.Diagnostics.xml new file mode 100644 index 0000000..254c1bd --- /dev/null +++ b/packages/SimpleInjector.2.6.1/lib/net40-client/SimpleInjector.Diagnostics.xml @@ -0,0 +1,193 @@ + + + + SimpleInjector.Diagnostics + + + + + Entry point for doing diagnostic analysis on instances. + + + The following example shows the usage of the Analyzer class: + + + + + + Analyzes the supplied instance. + + The container instance to analyze. + A collection of sub types that describe the diagnostic + warnings and messages. + + + + Diagnostic result for a warning about a concrete type that was not registered explicitly and was not + resolved using unregistered type resolution, but was created by the container using the transient + lifestyle. + For more information, see: https://simpleinjector.org/diaut. + + + + + Base class for types that hold information about a single diagnostic message or warning for a + particular type or part of the configuration. + + + + Gets the diagnostic type of this result. + The . + + + Gets the service type to which this warning is related. + A . + + + Gets the description of the diagnostic result. + A with the description. + + + Gets the hierarchical group to which this diagnostic result belongs. + The . + + + Gets a collection of instances that describe all + container-registered dependencies for the given component. + List of objects. + + + + A hierarchical group of . + + + + + Gets the base that describes the service types of its + . The value often be either (in case this is a + root group) or a partial generic type to allow hierarchical grouping of a large number of related + generic types. + + The . + + + Gets the friendly name of the group. + The name. + + + Gets the description of the group. + The description. + + + Gets the diagnostic type of all grouped instances. + The . + + + Gets the parent or null (Nothing in VB) when this is the + root group. + The . + + + Gets the collection of child s. + A collection of elements. + + + Gets the collection of instances. + /// A collection of elements. + + + + Specifies the list of diagnostic types that are currently supported by the diagnostic + . Note that new diagnostic types might be added in future versions. + For more information, please read the + Diagnosing your configuration using the Diagnostic + Services wiki documentation. + + + + + Diagnostic type that warns about + a concrete type that was not registered explicitly and was not resolved using unregistered type + resolution, but was created by the container using the transient lifestyle. + For more information, see: https://simpleinjector.org/diaut. + + + + + Diagnostic type that warns when a + component depends on a service with a lifestyle that is shorter than that of the component. + For more information, see: https://simpleinjector.org/dialm. + + + + + Diagnostic type that warns when a + component depends on an unregistered concrete type and this concrete type has a lifestyle that is + different than the lifestyle of an explicitly registered type that uses this concrete type as its + implementation. + For more information, see: https://simpleinjector.org/diasc. + + + + + Diagnostic type that warns when a + component depends on (too) many services. + For more information, see: https://simpleinjector.org/diasr. + + + + + Diagnostic result for a warning about a + component that depends on a service with a lifestyle that is shorter than that of the component. + For more information, see: https://simpleinjector.codeplex.com/wikipage?title=PotentialLifestyleMismatches. + + + + Gets the object that describes the relationship between the component and its dependency. + A instance. + + + + Diagnostic result that warns about a + component that depends on an unregistered concrete type and this concrete type has a lifestyle that is + different than the lifestyle of an explicitly registered type that uses this concrete type as its + implementation. + For more information, see: https://simpleinjector.codeplex.com/wikipage?title=ShortCircuitedDependencies. + + + + Gets the instance that describes the current relationship between the checked component + and the short-circuited dependency. + The . + + + + Gets the collection of registrations that have the component's current dependency as + implementation type, but have a lifestyle that is different than the current dependency. + + A collection of instances. + + + + Diagnostic result that warns about a component that depends on (too) many services. + For more information, see: https://simpleinjector.codeplex.com/wikipage?title=PotentialSingleResponsibilityViolations. + + + + Gets the created type. + A . + + + Gets the list of registrations that are dependencies of the . + A collection of instances. + + + diff --git a/packages/SimpleInjector.2.6.1/lib/net40-client/SimpleInjector.xml b/packages/SimpleInjector.2.6.1/lib/net40-client/SimpleInjector.xml new file mode 100644 index 0000000..18de2a3 --- /dev/null +++ b/packages/SimpleInjector.2.6.1/lib/net40-client/SimpleInjector.xml @@ -0,0 +1,4583 @@ + + + + SimpleInjector + + + + + The standard exception thrown when a container has an error in resolving an object. + + + + + Initializes a new instance of the class. + + + + + Initializes a new instance of the class with a specified error + message. + + The message that describes the error. + + + + Initializes a new instance of the class with a specified error + message and a reference to the inner exception that is the cause of this exception. + + + The error message that explains the reason for the exception. + + + The exception that is the cause of the current exception, or a null reference (Nothing in Visual + Basic) if no inner exception is specified. + + + + + Initializes a new instance of the class with serialized data. + + + The that holds the serialized object data about the exception + being thrown. + + + The that contains contextual information about the source or + destination. + + + The parameter is null. + + + The class name is null or hresult is zero (0). + + + + + Extension methods for enable advanced scenarios. + + + + + Determines whether the specified container is locked making any new registrations. The container + is automatically locked when GetInstance is called for the + first time. + + The container. + + true if the specified container is locked; otherwise, false. + + Thrown when is null. + + + Determines whether the specified container is currently verifying its configuration. + The container. + true if the specified container is verifying; otherwise, false. + Thrown when is null. + + + + Builds up an delegate wrapping all delegates that + are registered using RegisterInitializer and + that apply to the given (including delegates that are registered + for interfaces implements and base types that + inherits from). Null will be returned when no delegates are + registered that apply to this type. + + The container. + + This method has a performance caracteristic of O(n). Prevent from calling this in a performance + critical path of the application. + + The type for with an initializer must be built. + An delegate or null. + + + + Retrieves an item from the container stored by the given or null when no + item is stored by that key. + + + Thread-safety: Calls to this method are thread-safe, but users should take proper + percausions when they call both GetItem and . + + The container. + The key of the item to retrieve. + The stored item or null (Nothing in VB). + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + + + Stores an item by the given in the container. + + + Thread-safety: Calls to this method are thread-safe, but users should take proper + percausions when they call both and SetItem. + + The container. + The key of the item to insert or override. + The actual item. May be null. + Thrown when either or + is a null reference (Nothing in VB). + + + + Allows appending new registrations to existing registrations made using one of the + RegisterAll overloads. + + The container. + The service type of the collection. + The registration to append. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + Thrown when the is not a + reference type, is open generic, or ambiguous. + Thrown when the container is locked. + Thrown when the method is called for a registration + that is made with one of the RegisterAll overloads that accepts a dynamic collection + (an IEnumerable or IEnumerable<TService>). + + + + Defines the container's behavior for building an expression tree based on the supplied constructor of + a given type. + Set the ConstructorInjectionBehavior + property of the container's property to change the default behavior + of the container. + + + + + Builds an for the supplied , based on the + container's configuration. + + The parameter. + An that describes the intend of creating that + . This method never returns null. + + + + Defines the container's behavior for finding a suitable constructor for the creation of a type. + Set the ConstructorResolutionBehavior + property of the container's property to change the default behavior + of the container. + + + + + Gets the given 's constructor that can be used by the + container to create that instance. + + Type of the abstraction that is requested. + Type of the implementation to find a suitable constructor for. + + The . This method never returns null. + + Thrown when no suitable constructor could be found. + + + + Defines the container's behavior for verifying the constructor that will be picked by the + . + Set the ConstructorVerificationBehavior + property of the container's property to change the default behavior + of the container. + + + + Verifies the specified . + The parameter. + Thrown when the cannot be + used for auto wiring. + + Thrown when the is a + null reference. + + + + Defines the container's behavior for selecting the lifestyle for a registration in case no lifestyle + is explicitly supplied. + Set the LifestyleSelectionBehavior + property of the container's property to change the default behavior + of the container. By default, when no lifestyle is explicitly supplied, the + Transient lifestyle is used. + + + + Selects the lifestyle based on the supplied type information. + Type of the abstraction that is registered. + Type of the implementation to that is registered. + The suited for the given type. + Thrown when either one of the arguments is a null reference. + + + + Defines the container's behavior for selecting properties to inject during the creation of a type. + Set the PropertySelectionBehavior + property of the container's property to change the default behavior + of the container. By default, no properties will be injected by the container. + + + + + Determines whether a property should be injected by the container upon creation of its type. + + Type of the abstraction that is requested. + The property to check. + True when the property should be injected. + + + + An instance of this type will be supplied to the + delegate that is that is supplied to the + RegisterInitializer + overload that takes this delegate. This type contains contextual information about the creation and it + allows the user to examine the given instance to decide whether the instance should be initialized or + not. + + + + + Gets the that is responsible for the initialization of the created + instance. + + The or null (Nothing in VB) when the instance producer is + unknown. + + + + Gets the that is responsible for the initialization of the created + instance. + + /// The . + + + + Contains data that can be used to initialize a created instance. This data includes the actual + created and the information about the created instance. + + + + Returns the hash code for this instance. + A 32-bit signed integer that is the hash code for this instance. + + + Indicates whether this instance and a specified object are equal. + Another object to compare to. + True if the current object is equal to the other parameter; otherwise, false. + + + + Indicates whether the current object is equal to another object of the same type. + + An object to compare with this object. + True if the current object is equal to the other parameter; otherwise, false. + + + + Indicates whether the values of two specified objects are equal. + + The first object to compare. + The second object to compare. + True if a and b are equal; otherwise, false. + + + + Indicates whether the values of two specified objects are + not equal. + + The first object to compare. + The second object to compare. + True if a and b are not equal; otherwise, false. + + + Gets the with contextual information about the + created instance. + The . + + + Gets the created instance. + The created instance. + + + + This is an internal type. Only depend on this type when you want to be absolutely sure a future + version of the framework will break your code. + + + + Initializes a new instance of the struct. + The scope factory. + The container. + + + Gets the lazily initialized Scope of the current LazyScope instance. + The current Scope or null. + + + + This is an internal type. Only depend on this type when you want to be absolutely sure a future + version of the framework will break your code. + + Service type. + Implementation type. + + + + Initializes a new instance of the + struct. + The registration. + + + Gets the lazily initialized instance for the of the current LazyScopedRegistration. + The scope that is used to retrieve the instance. + The cached instance. + + + + The container. Create an instance of this type for registration of dependencies. + + + + Thread-safety: + Resolving instances can be done safely from multiple threads concurrently, but registration needs to + be done from one single thread. + + + It is therefore safe to call , , + GetService, and + and anything related to resolving instances from multiple thread + concurrently. It is however unsafe to call + RegisterXXX, + , , , + or anything related to registering from multiple threads concurrently. + + + + + + Registers that a new instance of will be returned every time it + is requested (transient). + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + The concrete type that will be registered. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + Thrown when the is a type + that can not be created by the container. + + + + Registers that an instance of will be returned when it + is requested. The instance is cached according to the supplied . + + The concrete type that will be registered. + The lifestyle that specifies how the returned instance will be cached. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + Thrown when the is a type + that can not be created by the container. + + + + Registers that a new instance of will be returned every time a + is requested (transient). + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + Thrown when the given + type is not a type that can be created by the container. + + + + + Registers the specified delegate that allows returning transient instances of + . The delegate is expected to always return a new instance on + each call. + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + The interface or base type that can be used to retrieve instances. + The delegate that allows building or creating new instances. + + Thrown when this container instance is locked and can not be altered, or when the + has already been registered. + + Thrown when is a null reference. + + + + Registers that a new instance of will be returned every time it + is requested (transient). + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + The concrete type that will be registered. + Thrown when is a null + references (Nothing in VB). + Thrown when represents an + open generic type or is a type that can not be created by the container. + + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + + Registers that a new instance of will be returned every time a + is requested. If and + represent the same type, the type is registered by itself. + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + The base type or interface to register. + The actual type that will be returned when requested. + Thrown when or + are null references (Nothing in VB). + Thrown when is + no sub type from (or the same type), or one of them represents an + open generic type. + + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + + Registers the specified delegate that allows returning instances of . + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + The base type or interface to register. + The delegate that will be used for creating new instances. + Thrown when either or + are null references (Nothing in VB). + Thrown when represents an + open generic type. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + + Registers a single concrete instance that will be constructed using constructor injection and will + be returned when this instance is requested by type . + This must be thread-safe when working in a multi-threaded + environment. + + The concrete type that will be registered. + + Thrown when this container instance is locked and can not be altered, or when + has already been registered. + + Thrown when the is a type + that can not be created by the container. + + + + Registers that the same a single instance of type will be + returned every time an type is requested. If + and represent the same + type, the type is registered by itself. must be thread-safe + when working in a multi-threaded environment. + + + The interface or base type that can be used to retrieve the instances. + + The concrete type that will be registered. + + Thrown when this container instance is locked and can not be altered, or when the + has already been registered. + Thrown when the given + type is not a type that can be created by the container. + + + + + Registers a single instance that will be returned when an instance of type + is requested. This must be thread-safe + when working in a multi-threaded environment. + + The interface or base type that can be used to retrieve the instance. + The instance to register. + + Thrown when this container instance is locked and can not be altered, or when the + has already been registered. + + Thrown when is a null reference. + + + + + Registers the specified delegate that allows constructing a single instance of + . This delegate will be called at most once during the lifetime of + the application. The returned instance must be thread-safe when working in a multi-threaded + environment. + + The interface or base type that can be used to retrieve instances. + The delegate that allows building or creating this single + instance. + + Thrown when this container instance is locked and can not be altered, or when a + for has already been registered. + + Thrown when is a + null reference. + + + + Registers that the same instance of type will be returned every + time an instance of type type is requested. If + and represent the same type, the + type is registered by itself. must be thread-safe when working + in a multi-threaded environment. + + The base type or interface to register. + The actual type that will be returned when requested. + Thrown when either or + are null references (Nothing in VB). + Thrown when is + no sub type from , or when one of them represents an open generic + type. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + + Registers the specified delegate that allows constructing a single + instance. The container will call this delegate at most once during the lifetime of the application. + + The base type or interface to register. + The delegate that will be used for creating that single instance. + Thrown when represents an open + generic type. + Thrown when either or + are null references (Nothing in + VB). + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + + Registers a single instance that will be returned when an instance of type + is requested. This must be thread-safe + when working in a multi-threaded environment. + + The base type or interface to register. + The instance to register. + Thrown when either or + are null references (Nothing in VB). + Thrown when is + no sub type from . + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + + Registers that an instance of will be returned when an + instance of type is requested. The instance is cached according to + the supplied . + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + The lifestyle that specifies how the returned instance will be cached. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + Thrown when the given + type is not a type that can be created by the container. + + + + + Registers the specified delegate that will produce instances of + type and will be returned when an instance of type + is requested. The delegate is expected to produce new instances on + each call. The instances are cached according to the supplied . + + The interface or base type that can be used to retrieve instances. + The delegate that allows building or creating new instances. + The lifestyle that specifies how the returned instance will be cached. + + Thrown when this container instance is locked and can not be altered, or when the + has already been registered. + + Thrown when one of the supplied arguments is a null reference (Nothing in VB). + + + + Registers that an instance of type will be returned when an + instance of type is requested. The instance is cached according to + the supplied . + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + The lifestyle that specifies how the returned instance will be cached. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + Thrown when this container instance is locked and can not be altered, or when the + has already been registered. + Thrown when the given + type is not a type that can be created by the container, when either + or are open generic types, or when + is not assignable from the . + + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + + + Registers the specified delegate that will produce instances of + type and will be returned when an instance of type + is requested. The delegate is expected to produce new instances on + each call. The instances are cached according to the supplied . + + The interface or base type that can be used to retrieve instances. + The delegate that allows building or creating new instances. + The lifestyle that specifies how the returned instance will be cached. + + Thrown when this container instance is locked and can not be altered, or when the + has already been registered. + + Thrown when one of the supplied arguments is a null reference (Nothing in VB). + + + + Registers an delegate that runs after the creation of instances that + implement or derive from the given . Please note that only instances + that are created by the container (using constructor injection) can be initialized this way. + + The type for which the initializer will be registered. + The delegate that will be called after the instance has been + constructed and before it is returned. + + Thrown when the is a null reference. + + + Thrown when this container instance is locked and can not be altered. + + + Multiple delegates can be registered per + and multiple initializers can be applied on a created instance, + before it is returned. For instance, when registering a + for type , the delegate will be called for every instance created by + the container, which can be nice for debugging purposes. + + + Note: Initializers are guaranteed to be executed in the order they are registered. + + + The following example shows the usage of the + RegisterInitializer method: + + (); + + // Configuring property injection for types that implement ICommand: + container.RegisterInitializer(command => + { + command.SendAsync = true; + }); + + // Configuring property injection for types that implement CommandBase: + container.RegisterInitializer(command => + { + command.Clock = container.GetInstance(); + }); + + // Act + var command = (ConcreteCommand)container.GetInstance(); + + // Assert + // Because ConcreteCommand implements both ICommand and CommandBase, + // both the initializers will have been executed. + Assert.IsTrue(command.SendAsync); + Assert.IsNotNull(command.Clock); + } + ]]> + + The container does not use the type information of the requested service type, but it uses the + type information of the actual implementation to find all initialized that apply for that + type. This makes it possible to have multiple initializers to be applied on a single returned + instance while keeping performance high. + + + Registered initializers will only be applied to instances that are created by the container self + (using constructor injection). Types that are newed up manually by supplying a + delegate to the container (using the + and + methods) or registered as single instance + (using ) will not trigger initialization. + When initialization of these instances is needed, this must be done manually, as can be seen in + the following example: + commandInitializer = command => + { + initializerCallCount++; + }); + + // Configuring that initializer. + container.RegisterInitializer(commandInitializer); + + container.Register(() => + { + // Create a ConcreteCommand manually: will not be initialized. + var command = new ConcreteCommand("Data Source=.;Initial Catalog=db;"); + + // Run the initializer manually. + commandInitializer(command); + + return command; + }); + + // Act + var command = container.GetInstance(); + + // Assert + // The initializer will only be called once. + Assert.AreEqual(1, initializerCallCount); + } + ]]> + The previous example shows how a manually created instance can still be initialized. Try to + prevent creating types manually, by changing the design of those classes. If possible, create a + single public constructor that only contains dependencies that can be resolved. + + + + + + Registers an delegate that runs after the + creation of instances for which the supplied returns true. Please + note that only instances that are created by the container can be initialized this way. + + The delegate that will be called after the instance has been + constructed and before it is returned. + The predicate that will be used to check whether the given delegate must + be applied to a registration or not. The given predicate will be called once for each registration + in the container. + + Thrown when either the or are + null references. + + + Thrown when this container instance is locked and can not be altered. + + + Note: Initializers are guaranteed to be executed in the order they are registered. + + + Note: The is not guaranteed to be called once per registration; + when a registration's instance is requested for the first time simultaneously over multiple thread, + the predicate might be called multiple times. The caller of this method is responsible of supplying + a predicate that is thread-safe. + + + + + + Registers a dynamic (container uncontrolled) collection of elements of type + . A call to will return the + itself, and updates to the collection will be reflected in the + result. If updates are allowed, make sure the collection can be iterated safely if you're running + a multi-threaded application. + + The interface or base type that can be used to retrieve instances. + The collection to register. + + Thrown when this container instance is locked and can not be altered, or when a + for has already been registered. + + Thrown when is a null + reference. + + + + Registers a collection of singleton elements of type . + + The interface or base type that can be used to retrieve instances. + The collection to register. + + Thrown when this container instance is locked and can not be altered, or when a + for has already been registered. + + Thrown when is a null + reference. + Thrown when one of the elements of + is a null reference. + + + + Registers a collection of , whose instances will be resolved lazily + each time the resolved collection of is enumerated. + The underlying collection is a stream that will return individual instances based on their + specific registered lifestyle, for each call to . + The order in which the types appear in the collection is the exact same order that the items were + registered, i.e the resolved collection is deterministic. + + The base type or interface for elements in the collection. + The collection of objects whose instances + will be requested from the container. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + Thrown when contains a null + (Nothing in VB) element, a generic type definition, or the is + not assignable from one of the given elements. + + + + + Registers a collection of , whose instances will be resolved lazily + each time the resolved collection of is enumerated. + The underlying collection is a stream that will return individual instances based on their + specific registered lifestyle, for each call to . + The order in which the types appear in the collection is the exact same order that the items were + registered, i.e the resolved collection is deterministic. + + The base type or interface for elements in the collection. + The collection of objects whose instances + will be requested from the container. + Thrown when is a null + reference (Nothing in VB). + + Thrown when contains a null + (Nothing in VB) element, a generic type definition, or the is + not assignable from one of the given elements. + + + + + Registers a collection of , whose instances will be resolved lazily + each time the resolved collection of is enumerated. + The underlying collection is a stream that will return individual instances based on their + specific registered lifestyle, for each call to . + The order in which the types appear in the collection is the exact same order that the items were + registered, i.e the resolved collection is deterministic. + + The base type or interface for elements in the collection. + The collection of objects whose instances + will be requested from the container. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + Thrown when contains a null + (Nothing in VB) element, a generic type definition, or the is + not assignable from one of the given elements. + + + + + Registers a collection of , whose instances will be resolved lazily + each time the resolved collection of is enumerated. + The underlying collection is a stream that will return individual instances based on their + specific registered lifestyle, for each call to . + The order in which the types appear in the collection is the exact same order that the items were + registered, i.e the resolved collection is deterministic. + + The base type or interface for elements in the collection. + The collection of objects whose instances + will be requested from the container. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + Thrown when contains a null + (Nothing in VB) element, the is a generic type definition, or when + is + not assignable from one of the given elements. + + + + + Registers a collection of , whose instances will be resolved lazily + each time the resolved collection of is enumerated. + The underlying collection is a stream that will return individual instances based on their + specific registered lifestyle, for each call to . + The order in which the types appear in the collection is the exact same order that the items were + registered, i.e the resolved collection is deterministic. + + The base type or interface for elements in the collection. + The collection of objects whose instances + will be requested from the container. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + Thrown when contains a null + (Nothing in VB) element, the is a generic type definition, or when + is + not assignable from one of the given elements. + + + + + Registers a dynamic (container uncontrolled) collection of elements of type + . A call to will return the + itself, and updates to the collection will be reflected in the + result. If updates are allowed, make sure the collection can be iterated safely if you're running + a multi-threaded application. + + The base type or interface for elements in the collection. + The collection of items to register. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + Thrown when represents an + open generic type. + + + + Verifies the Container. This method will call all registered delegates, + iterate registered collections and throws an exception if there was an error. + + Thrown when the registration of instances was + invalid. + + + + Adds the for the supplied . This + method can be used to apply the same to multiple different service + types. + + The base type or interface to register. + The registration that should be stored for the given + . + + (container); + + container.AddRegistration(typeof(IFoo), registration); + container.AddRegistration(typeof(IBar), registration); + + // Act + IFoo foo = container.GetInstance(); + IBar bar = container.GetInstance(); + + // Assert + bool fooAndBareAreTheSameInstance = object.ReferenceEquals(foo, bar); + Assert.IsTrue(fooAndBareAreTheSameInstance); + } + ]]> + + In the example above a singleton registration is created for type FooBar and this + registration is added to the container for each interface (IFoo and IBar) that it + implements. Since both services use the same singleton registration, requesting those services + will result in the return of the same (singleton) instance. + + + events are applied to the of the + instance and are therefore applied once. + events on the other hand get applied to the Expression of the . + Since each AddRegistration gets its own instance producer (that wraps the + Registration instance), this means that the ExpressionBuilt events will be + applied for each registered service type. + + + The most practical example of this is the use of decorators using one of the + RegisterDecorator overloads + (decorator registration use the + ExpressionBuilt event under the covers). Take a look at the following example: + + (container); + + container.AddRegistration(typeof(IFoo), registration); + container.AddRegistration(typeof(IBar), registration); + + // Registere a decorator for IBar, but not for IFoo + container.RegisterDecorator(typeof(IBar), typeof(BarDecorator)); + + // Act + var foo = container.GetInstance(); + var decorator = container.GetInstance() as BarDecorator; + var bar = decorator.DecoratedBar; + + // Assert + bool fooAndBareAreTheSameInstance = object.ReferenceEquals(foo, bar); + Assert.IsTrue(fooAndBareAreTheSameInstance); + } + ]]> + The example shows that the decorator gets applied to IBar but not to IFoo, but that + the decorated IBar is still the same instance as the resolved IFoo instance. + + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + Thrown when is not a reference + type, is open generic, is ambiguous, when it is not assignable from the + 's ImplementationType + or when the supplied is created for a different + instance. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + Gets an instance of the given . + Type of object requested. + The requested service instance. + Thrown when there are errors resolving the service instance. + + + Gets an instance of the given . + Type of object requested. + The requested service instance. + Thrown when there are errors resolving the service instance. + + + + Gets all instances of the given currently registered in the container. + + Type of object requested. + A sequence of instances of the requested TService. + Thrown when there are errors resolving the service instance. + + + + Gets all instances of the given currently registered in the container. + + Type of object requested. + A sequence of instances of the requested serviceType. + Thrown when there are errors resolving the service instance. + + + Gets the service object of the specified type. + An object that specifies the type of service object to get. + A service object of type serviceType. -or- null if there is no service object of type + . + + + + Gets the for the given . When no + registration exists, the container will try creating a new producer. A producer can be created + when the type is a concrete reference type, there is an + event registered that acts on that type, or when the service type is an . + Otherwise null (Nothing in VB) is returned. + + + + A call to this method locks the container. No new registrations can't be made after a call to this + method. + + + Note: This method is not guaranteed to always return the same + instance for a given . It will however either + always return null or always return a producer that is able to return the expected instance. + + + The that the returned instance producer should produce. + An or null (Nothing in VB). + + + + Gets the for the given . When no + registration exists, the container will try creating a new producer. A producer can be created + when the type is a concrete reference type, there is an + event registered that acts on that type, or when the service type is an . + Otherwise null (Nothing in VB) is returned, or an exception is throw when + is set to true. + + + + A call to this method locks the container. No new registrations can't be made after a call to this + method. + + + Note: This method is not guaranteed to always return the same + instance for a given . It will however either + always return null or always return a producer that is able to return the expected instance. + + + The that the returned instance producer should produce. + The indication whether the method should return null or throw + an exception when the type is not registered. + An or null (Nothing in VB). + + + + Injects all public writable properties of the given that have a type + that can be resolved by this container instance. + NOTE: This method will be removed in a future release. To use property injection, + implement a custom the instead. For more information, + read the + extendibility points wiki. + + The instance whose properties will be injected. + + Thrown when the is null (Nothing in VB). + Throw when injecting properties on the given instance + failed due to security constraints of the sandbox. This can happen when injecting properties + on an internal type in a Silverlight sandbox, or when running in partial trust. + + + Initializes a new instance of the class. + + + Initializes a new instance of the class. + The container options. + Thrown when the is a null + reference. + Thrown when supplied is an instance + that already is supplied to another instance. Every container must get + its own instance. + + + + Returns an array with the current registrations. This list contains all explicitly registered + types, and all implicitly registered instances. Implicit registrations are all concrete + unregistered types that have been requested, all types that have been resolved using + unregistered type resolution (using the event), and + requested unregistered collections. Note that the result of this method may change over time, + because of these implicit registrations. + + + + This method has a performance characteristic of O(n). Prevent from calling this in a performance + critical path of the application. + + + Note: This method is not guaranteed to always return the same + instance for a given registration. It will however either + always return a producer that is able to return the expected instance. Because of this, do not + compare sets of instances returned by different calls to + by reference. The way of comparing lists is by the actual type. The type of each instance is + guaranteed to be unique in the returned list. + + + An array of instances. + + + + Returns an array with the current registrations for root objects. Root objects are registrations + that are in the root of the object graph, meaning that no other registration is depending on it. + + + + This method has a performance characteristic of O(n). Prevent from calling this in a performance + critical path of the application. + + + This list contains the root objects of all explicitly registered types, and all implicitly + registered instances. Implicit registrations are all concrete unregistered types that have been + requested, all types that have been resolved using unregistered type resolution (using the + event), and requested unregistered collections. Note that + the result of this method may change over time, because of these implicit registrations. + + + Note: This method is not guaranteed to always return the same + instance for a given registration. It will however either + always return a producer that is able to return the expected instance. Because of this, do not + compare sets of instances returned by different calls to + by reference. The way of comparing lists is by the actual type. The type of each instance is + guaranteed to be unique in the returned list. + + + An array of instances. + Thrown when this method is called before + has been successfully called. + + + Determines whether the specified System.Object is equal to the current System.Object. + + The System.Object to compare with the current System.Object. + + True if the specified System.Object is equal to the current System.Object; otherwise, false. + + + + Returns the hash code of the current instance. + The hash code of the current instance. + + + + Returns a that represents the . + + + A that represents the . + + + + Gets the of the current instance. + The instance that represents the exact runtime + type of the current instance. + + + Prevents any new registrations to be made to the container. + + + + Occurs when an instance of a type is requested that has not been registered explicitly, allowing + resolution of unregistered types before the container tries to create the type. + + + + The event is called by the container every time an + unregistered type is requested for the first time, allowing a developer to do unregistered type + resolution. By calling the + Register method on the + , a , or + delegate can be registered allowing the container to retrieve + instances of the requested type. This registration is cached and it prevents the + ResolveUnregisteredType event from being called again for the same type. + + + When no registered event handled the registration of an unregistered type, the container will try + to create the type when this type is either concrete or is the + interface. Concrete types will be registered with the Transient + lifestyle and registrations will return an empty collection. When no + even handled the registration and the container could not create it, an exception is thrown. + + + Thread-safety: Please note that the container will not ensure that the hooked delegates + are executed only once. While the calls to for a given type + are finite (and will in most cases happen just once), a container can call the delegate multiple + times and make parallel calls to the delegate. You must make sure that the code can be called + multiple times and is thread-safe. + + + + The following example shows the usage of the event: + + { + void Validate(T instance); + } + + // Implementation of the null object pattern. + public class EmptyValidator : IValidator + { + public void Validate(T instance) + { + // Does nothing. + } + } + + [TestMethod] + public void TestResolveUnregisteredType() + { + // Arrange + var container = new Container(); + + // Register an EmptyValidator to be returned when a IValidator is requested: + container.ResolveUnregisteredType += (sender, e) => + { + if (e.UnregisteredServiceType.IsGenericType && + e.UnregisteredServiceType.GetGenericTypeDefinition() == typeof(IValidator<>)) + { + var validatorType = typeof(EmptyValidator<>).MakeGenericType( + e.UnregisteredServiceType.GetGenericArguments()); + + object emptyValidator = container.GetInstance(validatorType); + + // Register the instance as singleton. + e.Register(() => emptyValidator); + } + }; + + // Act + var orderValidator = container.GetInstance>(); + var customerValidator = container.GetInstance>(); + + // Assert + Assert.IsInstanceOfType(orderValidator, typeof(EmptyValidator)); + Assert.IsInstanceOfType(customerValidator, typeof(EmptyValidator)); + } + ]]> + + The example above registers a delegate that is raised every time an unregistered type is requested + from the container. The delegate checks whether the requested type is a closed generic + implementation of the IValidator<T> interface (such as + IValidator<Order> or IValidator<Customer>). In that case it + will request the container for a concrete EmptyValidator<T> implementation that + implements the given + UnregisteredServiceType, and + registers a delegate that will return this created instance. The e.Register call + registers the method in the container, preventing the from + being called again for the exact same service type, preventing any performance penalties. + + + Please note that given example is just an uhhmm... example. In the case of the example the + EmptyValidator<T> can be better registered using of the built-in + RegisterOpenGeneric + extension methods instead. These extension methods take care of any given generic type constraint + and allow the implementation to be integrated into the container's pipeline, which allows + it to be intercepted using the event and allow any registered + initializers to be applied. + + + + + + Occurs after the creation of the of a registered type is complete (the + lifestyle has been applied), allowing the created to be wrapped, + changed, or replaced. Multiple delegates may handle the same service type. + + + + The ExpressionBuilt event is called by the container every time an registered type is + getting compiled, allowing a developer to change the way the type is created. The delegate that + hooks to the ExpressionBuilt event, can change the + property on the + , which allows changing the way the type is constructed. + + + Thread-safety: Please note that the container will not ensure that the hooked delegates + are executed only once per service type. While the calls to for a + given type are finite (and will in most cases happen just once), a container can call the delegate + multiple times and make parallel calls to the delegate. You must make sure that the code can be + called multiple times and is thread-safe. + + + + The following example shows the usage of the ExpressionBuilt event: + + { + void Validate(T instance); + } + + public interface ILogger + { + void Write(string message); + } + + // Implementation of the decorator pattern. + public class MonitoringValidator : IValidator + { + private readonly IValidator validator; + private readonly ILogger logger; + + public MonitoringValidator(IValidator validator, ILogger logger) + { + this.validator = validator; + this.logger = logger; + } + + public void Validate(T instance) + { + this.logger.Write("Validating " + typeof(T).Name); + this.validator.Validate(instance); + this.logger.Write("Validated " + typeof(T).Name); + } + } + + [TestMethod] + public void TestExpressionBuilt() + { + // Arrange + var container = new Container(); + + container.RegisterSingle(); + container.Register, OrderValidator>(); + container.Register, CustomerValidator>(); + + // Intercept the creation of IValidator instances and wrap them in a MonitoringValidator: + container.ExpressionBuilt += (sender, e) => + { + if (e.RegisteredServiceType.IsGenericType && + e.RegisteredServiceType.GetGenericTypeDefinition() == typeof(IValidator<>)) + { + var decoratorType = typeof(MonitoringValidator<>) + .MakeGenericType(e.RegisteredServiceType.GetGenericArguments()); + + // Wrap the IValidator in a MonitoringValidator. + e.Expression = Expression.New(decoratorType.GetConstructors()[0], new Expression[] + { + e.Expression, + container.GetRegistration(typeof(ILogger)).BuildExpression(), + }); + } + }; + + // Act + var orderValidator = container.GetInstance>(); + var customerValidator = container.GetInstance>(); + + // Assert + Assert.IsInstanceOfType(orderValidator, typeof(MonitoringValidator)); + Assert.IsInstanceOfType(customerValidator, typeof(MonitoringValidator)); + } + ]]> + + The example above registers a delegate that is raised every time the container compiles the + expression for an registered type. The delegate checks whether the requested type is a closed generic + implementation of the IValidator<T> interface (such as + IValidator<Order> or IValidator<Customer>). In that case it + will changes the current with a new one that creates + a new MonitoringValidator<T> that takes the current validator (and an ILogger) + as an dependency. + + + Please note that given example is just an uhhmm... example. In the case of the example the + MonitoringValidator<T> is a decorator and instead of manually writing this code that + many limitations, you can use one of the built-in + RegisterDecorator extension methods instead. + These extension methods take care of any given generic type constraint, allow to register decorators + conditionally and allow the decorator to be integrated into the container's pipeline, which allows + it to be intercepted using the event and allow any registered + initializers to be applied. + + + + + + Occurs directly after the creation of the of a registered type is made, + but before any initializer and lifestyle specific caching + has been applied, allowing the created to be altered. Multiple delegates + may handle the same service type. + + + + The ExpressionBuilding event is called by the container every time an registered type is + getting compiled, allowing a developer to change the way the type is created. The delegate that + hooks to the ExpressionBuilding event, can change the + property on the + , which allows changing the way the type is constructed. + + + The exact type supplied depends on the type of registration. + Registrations that explicitly supply the implementation type (such as + Register<TService, TImplementation>()) + will result in an , while registrations that take a delegate (such as + Register<TService>(Func<TService>)) + will result in an . Singletons that are passed in using their + value (RegisterSingle<TService>(TService)) + will result in an . Note that other ExpressionBuilding + registrations might have changed the + property and might have supplied an of a different type. The order in + which these events are registered might be of importance to you. + + + Thread-safety: Please note that the container will not ensure that the hooked delegates + are executed only once per service type. While the calls to registered ExpressionBuilding + events for a given type are finite (and will in most cases happen just once), a container can + call the delegate multiple times and make parallel calls to the delegate. You must make sure that + the code can be called multiple times and is thread-safe. + + + + The following example shows the usage of the ExpressionBuilding event: + + { + var expression = e.Expression as NewExpression; + + if (expression != null) + { + var propertiesToInject = + from property in expression.Constructor.DeclaringType.GetProperties() + where property.GetCustomAttributes(typeof(MyInjectPropertyAttribute), true).Any() + let registration = container.GetRegistration(property.PropertyType, true) + select Tuple.Create(property, registration); + + if (propertiesToInject.Any()) + { + Func[], object> injectorDelegate = + (instance, dependencies) => + { + foreach (var dependency in dependencies) + { + dependency.Item1.SetValue(instance, dependency.Item2.GetInstance(), null); + } + + return instance; + }; + + e.Expression = Expression.Convert( + Expression.Invoke( + Expression.Constant(injectorDelegate), + e.Expression, + Expression.Constant(propertiesToInject.ToArray())), + expression.Constructor.DeclaringType); + } + } + }; + } + ]]> + + The example above registers a delegate that is raised every time the container compiles the + expression for an registered type. The delegate checks if the type contains properties that are + decorated with the supplied MyInjectPropertyAttribute. If decorated properties are found, + the given expression is replaced with an expression that injects decorated properties. + + + The example differs from the container's built-in method in that + it will fail when one of the decorated properties can not be injected. The built-in + will look at all properties of a given class and will simply skip + over any properties that can not be injected, making the use of the + method often verify fragile and error prone. + + + + + Gets the container options. + The instance for this container. + + + + Gets the intermediate lifestyle that forwards CreateRegistration calls to the lifestyle that is + returned from the registered container.Options.LifestyleSelectionBehavior. + + + + Implements a cache for implementations. + + is thread-safe can be used over multiple threads concurrently. + + + + + Allows registering an delegate that will be called when the scope ends, + but before the scope disposes any instances. + + + During the call to all registered delegates are + processed in the order of registration. Do note that registered actions are not guaranteed + to run. In case an exception is thrown during the call to , the + will stop running any actions that might not have been invoked at that point. + Instances that are registered for disposal using on the other + hand, are guaranteed to be disposed. Note that registered actions won't be invoked during a call + to . + + The delegate to run when the scope ends. + Thrown when one of the arguments is a null reference + (Nothing in VB). + Thrown when the scope has been disposed. + + + + Adds the to the list of items that will get disposed when the + scope ends. + + + Instances that are registered for disposal, will be disposed in opposite order of registration and + they are guaranteed to be disposed when is called (even when + exceptions are thrown). This mimics the behavior of the C# and VB using statements, + where the method is called inside the finally block. + + The instance that should be disposed when the scope ends. + Thrown when one of the arguments is a null reference + (Nothing in VB). + Thrown when the scope has been disposed. + + + Releases all instances that are cached by the object. + + + + Releases all instances that are cached by the object. + + False when only unmanaged resources should be released. + + + Configuration options for the . + + The following example shows the typical usage of the ContainerOptions class. + (); + + // Use of ContainerOptions class here. + container.Options.AllowOverridingRegistrations = true; + + // Replaces the previous registration of ITimeProvider + container.Register(); + ]]> + + + + Initializes a new instance of the class. + + + + Gets or sets a value indicating whether the container allows overriding registrations. The default + is false. + + The value indicating whether the container allows overriding registrations. + + + + Gets or sets the constructor resolution behavior. By default, the container only supports types + that have a single public constructor. + + The constructor resolution behavior. + Thrown when the supplied value is a null reference. + + Thrown when the container already contains registrations. + + + + + Gets or sets the constructor verification behavior. The container's default behavior is to + disallow constructors with value types and strings. + + The constructor resolution behavior. + Thrown when the supplied value is a null reference. + + Thrown when the container already contains registrations. + + + + Gets or sets the constructor injection behavior. + The constructor injection behavior. + Thrown when the supplied value is a null reference. + + Thrown when the container already contains registrations. + + + + + Gets or sets the property selection behavior. The container's default behavior is to do no + property injection. + + The property selection behavior. + Thrown when the supplied value is a null reference. + + Thrown when the container already contains registrations. + + + + + Gets or sets the lifestyle selection behavior. The container's default behavior is to make + registrations using the lifestyle. + The lifestyle selection behavior. + Thrown when the supplied value is a null reference. + + Thrown when the container already contains registrations. + + + + + Gets the container to which this ContainerOptions instance belongs to or null when + this instance hasn't been applied to a yet. + + The current . + + + + Gets or sets a value indicating whether the container will use dynamic assemblies for compilation. + By default, this value is true for the first few containers that are created in an app + domain and false for all other containers. You can set this value explicitly to false + to prevent the use of dynamic assemblies or you can set this value explicitly to true to + force more container instances to use dynamic assemblies. Note that creating an infinite number + of instances (for instance one per web request) with this property set to + true will result in a memory leak; dynamic assemblies take up memory and will only be + unloaded when the AppDomain is unloaded. + + A boolean indicating whether the container should use a dynamic assembly for compilation. + + + + + Allows verifying whether a given type has a direct or indirect dependency on itself. Verifying is done + by preventing recursive calls to a IInstanceProvider. An instance of this type is related to a single + instance of a IInstanceProvider. A RecursiveDependencyValidator instance checks a single + IInstanceProvider and therefore a single service type. + + + + + Extension methods for the RecursiveDependencyValidator class. + + + + + Provides data for and interaction with the + ExpressionBuilding event of + the . An observer can change the + property to change the component that is + currently being built. + + + + Gets the registered service type that is currently requested. + The registered service type that is currently requested. + + + + Gets the type that is known to be returned by the + Expression (most often the implementation + type used in the Register call). This type will be a derivative of + RegisteredServiceType (or + or RegisteredServiceType itself). If the Expression is changed, the new expression + must also return an instance of type KnownImplementationType or a sub type. + This information must be described in the new Expression. + + A . + + + + Gets the lifestyle for the component that is currently being built. + + The . + + + Gets or sets the currently registered . + The current registration. + Thrown when the supplied value is a null reference. + + + + Gets the collection of currently known relationships. This information is used by the Diagnostics + Debug View. Change the contents of this collection to represent the changes made to the + Expression property (if any). This allows + the Diagnostics Debug View to analyze those new relationships as well. + + The collection of instances. + + + + Provides data for and interaction with the + ExpressionBuilt event of + the . An observer can change the + property to change the component that is currently + being built. + + + + Initializes a new instance of the class. + Type of the registered service. + The registered expression. + + + Gets the registered service type that is currently requested. + The registered service type that is currently requested. + + + Gets or sets the currently registered . + The current registration. + Thrown when the supplied value is a null reference. + + + Gets or sets the current lifestyle of the registration. + The original lifestyle of the registration. + + + + Gets the collection of currently known relationships. This information is used by the Diagnostics + Debug View. Change the contents of this collection to represent the changes made to the + Expression property (if any). This allows + the Diagnostics Debug View to analyze those new relationships as well. + + The collection of instances. + + + + A map containing a generic argument (such as T) and the concrete type (such as Int32) that it + represents. + + + + Implements equality. Needed for doing LINQ distinct operations. + The other to compare to. + True or false. + + + Overrides the default hash code. Needed for doing LINQ distinct operations. + An 32 bit integer. + + + + An instance of this type can be injected into constructors of decorator classes that are registered + using RegisterDecorator. This type contains + contextual information about the applied decoration and it allows users to examine the given instance + to make runtime decisions. + + + + + Gets the closed generic service type for which the decorator is about to be applied. The original + service type will be returned, even if other decorators have already been applied to this type. + + The closed generic service type. + + + + Gets the type of the implementation that is created by the container and for which the decorator + is about to be applied. The original implementation type will be returned, even if other decorators + have already been applied to this type. Please not that the implementation type can not always be + determined. In that case the closed generic service type will be returned. + + The implementation type. + + + + Gets the list of the types of decorators that have already been applied to this instance. + + The applied decorators. + + + + Gets the current object that describes the intention to create a new + instance with its currently applied decorators. + + The current expression that is about to be decorated. + + + + Extension methods for applying decorators. + + + + + Ensures that the supplied decorator is returned and cached with + the given , wrapping the original registered + , by injecting that service type into the constructor of the + supplied . Multiple decorators may be applied to the same + . Decorators can be applied to both open, closed, and non-generic + service types. + + + + The RegisterOpenGenericDecorator method works by hooking onto the container's + ExpressionBuilt event. This event fires after the + ResolveUnregisteredType event, which allows + decoration of types that are resolved using unregistered type resolution. The + RegisterOpenGeneric + extension method, for instance, hooks onto the ResolveUnregisteredType. This allows you to + use RegisterOpenGenericDecorator on the same service type as RegisterOpenGeneric. + + + Multiple decorators can be applied to the same service type. The order in which they are registered + is the order they get applied in. This means that the decorator that gets registered first, gets + applied first, which means that the next registered decorator, will wrap the first decorator, which + wraps the original service type. + + + Constructor injection will be used on that type, and although it may have many constructor + arguments, it must have exactly one argument of the type of , or an + argument of type where TResult is . + An exception will be thrown when this is not the case. + + + The registered may have a constructor with an argument of type + where T is . In this case, the + will not inject the decorated itself into the + instance, but it will inject a that allows + creating instances of the decorated type, according to the lifestyle of that type. This enables + more advanced scenarios, such as executing the decorated types on a different thread, or executing + decorated instance within a certain scope (such as a lifetime scope). + + + + Please see the RegisterDecorator method + for more information. + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the given . + The definition of the open generic decorator type that will + be used to wrap the original service type. + The lifestyle that specifies how the returned decorator will be cached. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type, when does not inherit from or + implement , when + does not have a single public constructor, or when does + not contain a constructor that has exactly one argument of type + or where T is + . + + + + Ensures that the supplied decorator is returned when the supplied + returns true and cached with the given + , wrapping the original registered , by + injecting that service type into the constructor of the supplied . + Multiple decorators may be applied to the same . Decorators can be + applied to both open, closed, and non-generic service types. + + + + The RegisterOpenGenericDecorator method works by hooking onto the container's + ExpressionBuilt event. This event fires after the + ResolveUnregisteredType event, which allows + decoration of types that are resolved using unregistered type resolution. The + RegisterOpenGeneric + extension method, for instance, hooks onto the ResolveUnregisteredType. This allows you to + use RegisterOpenGenericDecorator on the same service type as RegisterOpenGeneric. + + + Multiple decorators can be applied to the same service type. The order in which they are registered + is the order they get applied in. This means that the decorator that gets registered first, gets + applied first, which means that the next registered decorator, will wrap the first decorator, which + wraps the original service type. + + + Constructor injection will be used on that type, and although it may have many constructor + arguments, it must have exactly one argument of the type of , or an + argument of type where TResult is . + An exception will be thrown when this is not the case. + + + The registered may have a constructor with an argument of type + where T is . In this case, the + will not inject the decorated itself into the + instance, but it will inject a that allows + creating instances of the decorated type, according to the lifestyle of that type. This enables + more advanced scenarios, such as executing the decorated types on a different thread, or executing + decorated instance within a certain scope (such as a lifetime scope). + + + + Please see the RegisterDecorator method + for more information. + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the given . + The definition of the open generic decorator type that will + be used to wrap the original service type. + The lifestyle that specifies how the returned decorator will be cached. + The predicate that determines whether the + must be applied to a service type. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type, when does not inherit from or + implement , when + does not have a single public constructor, or when does + not contain a constructor that has exactly one argument of type + or where T is + . + + + + Ensures that the decorator type that is returned from is + supplied when the supplied returns true and cached with the given + , wrapping the original registered , by + injecting that service type into the constructor of the decorator type that is returned by the + supplied . + Multiple decorators may be applied to the same . Decorators can be + applied to both open, closed, and non-generic service types. + + + + The types returned from the may be open-generic. The + container will try to fill in the generic parameters based on the resolved service type. + + + The RegisterOpenGenericDecorator method works by hooking onto the container's + ExpressionBuilt event. This event fires after the + ResolveUnregisteredType event, which allows + decoration of types that are resolved using unregistered type resolution. The + RegisterOpenGeneric + extension method, for instance, hooks onto the ResolveUnregisteredType. This allows you to + use RegisterOpenGenericDecorator on the same service type as RegisterOpenGeneric. + + + Multiple decorators can be applied to the same service type. The order in which they are registered + is the order they get applied in. This means that the decorator that gets registered first, gets + applied first, which means that the next registered decorator, will wrap the first decorator, which + wraps the original service type. + + + Constructor injection will be used on that type, and although it may have many constructor + arguments, it must have exactly one argument of the type of , or an + argument of type where TResult is . + An exception will be thrown when this is not the case. + + + The type returned from may have a constructor with an + argument of type where T is . In this + case, the framework will not inject the decorated itself into the + decorator instance, but it will inject a that allows + creating instances of the decorated type, according to the lifestyle of that type. This enables + more advanced scenarios, such as executing the decorated types on a different thread, or executing + decorated instance within a certain scope (such as a lifetime scope). + + + + The following is an example of the registration of a decorator through the factory delegate: + , MoveCustomerCommandHandler>(); + + container.RegisterDecorator( + typeof(ICommandHandler<>), + context => typeof(LoggingCommandHandler<,>).MakeGenericType( + typeof(LoggingCommandHandler<,>).GetGenericArguments().First(), + context.ImplementationType), + Lifestyle.Transient, + context => true); + + var handler = container.GetInstance>(); + + Assert.IsInstanceOfType(handler, + typeof(LoggingCommandHandler)); + + ]]> + The code above allows a generic LoggingCommandHandler<TCommand, TImplementation> to + be applied to command handlers, where the second generic argument will be filled in using the + contextual information. + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the decorator type returned by the supplied . + A factory that allows building Type objects that define the + decorators to inject, based on the given contextual information. The delegate is allowed to return + open-generic types. + The lifestyle that specifies how the returned decorator will be cached. + The predicate that determines whether the decorator must be applied to a + service type. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type. + + + + Ensures that the supplied decorator is returned, wrapping the + original registered , by injecting that service type into the + constructor of the supplied . Multiple decorators may be applied + to the same . Decorators can be applied to both open, closed, and + non-generic service types. By default, a new instance will be + returned on each request (according the Transient lifestyle), + independently of the lifestyle of the wrapped service. + + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + + The RegisterDecorator method works by hooking onto the container's + ExpressionBuilt event. This event fires after the + ResolveUnregisteredType event, which allows + decoration of types that are resolved using unregistered type resolution. The + RegisterOpenGeneric + extension method, for instance, hooks onto the ResolveUnregisteredType. This allows you to + use RegisterDecorator on the same generic service type as RegisterOpenGeneric. + + + Multiple decorators can be applied to the same service type. The order in which they are registered + is the order they get applied in. This means that the decorator that gets registered first, gets + applied first, which means that the next registered decorator, will wrap the first decorator, which + wraps the original service type. + + + Constructor injection will be used on that type, and although it may have many constructor + arguments, it must have exactly one argument of the type of , or an + argument of type where TResult is . + An exception will be thrown when this is not the case. + + + The registered may have a constructor with an argument of type + where T is . In this case, an decorated + instance will not injected into the , but it will inject a + that allows creating instances of the decorated type, according to the + lifestyle of that type. This enables more advanced scenarios, such as executing the decorated + types on a different thread, or executing decorated instance within a certain scope (such as a + lifetime scope). + + + + The following example shows the definition of a generic ICommandHandler<T> interface, + a CustomerMovedCommandHandler implementing that interface, and a + ValidatorCommandHandlerDecorator<T> that acts as a decorator for that interface. + + { + void Handle(TCommand command); + } + + public class CustomerMovedCommand + { + [Required] + public int CustomerId { get; set; } + + [Required] + public Address Address { get; set; } + } + + public class CustomerMovedCommandHandler + : ICommandHandler + { + public void Handle(CustomerMovedCommand command) + { + // some logic + } + } + + // Decorator that validates commands before they get executed. + public class ValidatorCommandHandlerDecorator + : ICommandHandler + { + private readonly ICommandHandler decoratedHandler; + private readonly Container container; + + public ValidatorCommandHandlerDecorator( + ICommandHandler decoratedHandler, + Container container) + { + this.decoratedHandler = decoratedHandler; + this.container = container; + } + + public void Handle(TCommand command) + { + this.Validate(command); + + this.decoratedHandler.Handle(command); + } + + private void Validate(TCommand command) + { + var validationContext = + new ValidationContext(command, this.container, null); + + Validator.ValidateObject(command, validationContext); + } + } + + // Decorator that measures the time it takes to execute a command. + public class MonitoringCommandHandlerDecorator + : ICommandHandler + { + private readonly ICommandHandler decoratedHandler; + private readonly ILogger logger; + + public MonitoringCommandHandlerDecorator( + ICommandHandler decoratedHandler, + ILogger logger) + { + this.decoratedHandler = decoratedHandler; + this.logger = logger; + } + + public void Handle(TCommand command) + { + var watch = Stopwatch.StartNew(); + + this.decoratedHandler.Handle(command); + + this.logger.Log(string.Format("{0} executed in {1} ms.", + command.GetType().Name, watch.ElapsedMilliseconds)); + } + } + + [TestMethod] + public static void TestRegisterOpenGenericDecorator() + { + // Arrange + var container = new Container(); + + container.RegisterSingle(); + + // Search the given assembly and register all concrete types that + // implement ICommandHandler. + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), + typeof(ICommandHandler<>).Assembly); + + // Wrap all ICommandHandler service types with a decorator + // that measures and logs the duration of that handler. + container.RegisterDecorator(typeof(ICommandHandler<>), + typeof(MonitoringCommandHandlerDecorator<>)); + + // Wrap all ICommandHandler types (in this case it will + // wrap the monitoring decorator), but only if the TCommand contains + // any properties. + container.RegisterDecorator(typeof(ICommandHandler<>), + typeof(ValidatorCommandHandlerDecorator<>), context => + { + var commandType = context.ServiceType.GetGenericArguments()[0]; + bool mustDecorate = commandType.GetProperties().Any(); + return mustDecorate; + }); + + // Act + var handler = + container.GetInstance>(); + + // Assert + Assert.IsInstanceOfType(handler, + typeof(ValidatorCommandHandlerDecorator)); + } + ]]> + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the given . + The definition of the open generic decorator type that will + be used to wrap the original service type. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type, when does not inherit from or implement + , when does not + have a single public constructor, or when does not + contain a constructor that has exactly one argument of type + or where T is + . + + + + Ensures that the supplied decorator is returned when the supplied + returns true, wrapping the original registered + , by injecting that service type into the constructor of the + supplied . Multiple decorators may be applied to the same + . Decorators can be applied to both open, closed, and non-generic + service types. By default, a new instance will be returned on + each request (according the Transient lifestyle), + independently of the lifestyle of the wrapped service. + + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + + The RegisterOpenGenericDecorator method works by hooking onto the container's + ExpressionBuilt event. This event fires after the + ResolveUnregisteredType event, which allows + decoration of types that are resolved using unregistered type resolution. The + RegisterOpenGeneric + extension method, for instance, hooks onto the ResolveUnregisteredType. This allows you to + use RegisterOpenGenericDecorator on the same service type as RegisterOpenGeneric. + + + Multiple decorators can be applied to the same service type. The order in which they are registered + is the order they get applied in. This means that the decorator that gets registered first, gets + applied first, which means that the next registered decorator, will wrap the first decorator, which + wraps the original service type. + + + Constructor injection will be used on that type, and although it may have many constructor + arguments, it must have exactly one argument of the type of , or an + argument of type where TResult is . + An exception will be thrown when this is not the case. + + + The registered may have a constructor with an argument of type + where T is . In this case, the + will not inject the decorated itself into the + instance, but it will inject a that allows + creating instances of the decorated type, according to the lifestyle of that type. This enables + more advanced scenarios, such as executing the decorated types on a different thread, or executing + decorated instance within a certain scope (such as a lifetime scope). + + + + Please see the RegisterDecorator method + for more information. + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the given . + The definition of the open generic decorator type that will + be used to wrap the original service type. + The predicate that determines whether the + must be applied to a service type. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type, when does not inherit from or + implement , when + does not have a single public constructor, or when does + not contain a constructor that has exactly one argument of type + or where T is + . + + + + Ensures that a single instance of the supplied decorator is + returned, wrapping the original registered , by injecting that + service type into the constructor of the supplied . Multiple + decorators may be applied to the same . Decorators can be applied + to both open, closed, and non-generic service types. + + + + This method ensures that a single instance of the supplied is + returned, no matter what the lifestyle of the wrapped service type is. Use with care, because the + wrapped service type will also become a singleton. This method is especially useful when use for + injecting factory methods, which will allow the wrapped service type to get + it's own lifestyle back. + + + + Please see the RegisterDecorator method + for more information. + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the given . + The definition of the open generic decorator type that will + be used to wrap the original service type. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type, when does not inherit from or implement + , when does not + have a single public constructor, or when does not + contain a constructor that has exactly one argument of type + or where T is + . + + + + Ensures that the supplied decorator is returned when the supplied + returns true, wrapping the original registered + , by injecting that service type into the constructor of the + supplied . Multiple decorators may be applied to the same + . Decorators can be applied to both open, closed, and non-generic + service types. + + + + This method ensures that a single instance of the supplied is + returned, no matter what the lifestyle of the wrapped service type is. Use with care, because the + wrapped service type will also become a singleton. This method is especially useful when use for + injecting factory methods, which will allow the wrapped service type to get + it's own lifestyle back. + + + + Please see the RegisterDecorator method + for more information. + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the given . + The definition of the open generic decorator type that will + be used to wrap the original service type. + The predicate that determines whether the + must be applied to a service type. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type, when does not inherit from or + implement , when + does not have a single public constructor, or when does + not contain a constructor that has exactly one argument of type + or where T is + . + + + + An instance of this type will be supplied to the + delegate that is that is supplied to the + RegisterDecorator + overload that takes this delegate. This type contains information about the decoration that is about + to be applied and it allows users to examine the given instance to see whether the decorator should + be applied or not. + + + Please see the + RegisterDecorator + method for more information. + + + + + Gets the closed generic service type for which the decorator is about to be applied. The original + service type will be returned, even if other decorators have already been applied to this type. + + The closed generic service type. + + + + Gets the type of the implementation that is created by the container and for which the decorator + is about to be applied. The original implementation type will be returned, even if other decorators + have already been applied to this type. Please not that the implementation type can not always be + determined. In that case the closed generic service type will be returned. + + The implementation type. + + + + Gets the list of the types of decorators that have already been applied to this instance. + + The applied decorators. + + + + Gets the current object that describes the intention to create a new + instance with its currently applied decorators. + + The current expression that is about to be decorated. + + + + Hooks into the building process and adds a decorator if needed. + + + + This interface is not meant for public use. + + + Please do not use. + Do not use. + + + PLease do not use. + Do not use. + + + + A Registration implements lifestyle based caching for a single service and allows building an + that describes the creation of the service. + + + implementations create a new Registration instance for each registered + service type. s returned from the + BuildExpression method can be intercepted by any event + registered with , have + initializers + applied, and the caching particular to its lifestyle have been applied. Interception using the + Container.ExpressionBuilt will not + be applied in the Registration, but will be applied in . + + See the documentation for an example. + + + + + Initializes a new instance of the class. + + The this that created this registration. + The instance for this registration. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + + + Builds a new with the correct caching (according to the specifications of + its ) applied. + + An . + + + + Gets the list of instances. Note that the list is only available + after calling . + + A new array containing the instances. + + + + Initializes an already created instance and applies properties and initializers to that instance. + + + This method is especially useful in integration scenarios where the given platform is in control + of creating certain types. By passing the instance created by the platform to this method, the + container is still able to apply any properties (as defined using a custom + ) and by applying any initializers. + + The instance to initialize. + Thrown when is a null reference + (Nothing in VB). + Thrown when the supplied is not + of type . + + + + Builds a delegate for the creation of the + using the supplied . The returned might + be intercepted by a + Container.ExpressionBuilding event, + and the will have been wrapped with a delegate that executes the + registered initializers + that are applicable to the given (if any). + + The interface or base type that can be used to retrieve instances. + + The delegate supplied by the user that allows building or creating new instances. + A delegate. + + + + Builds a delegate for the creation of . + The returned might be intercepted by a + Container.ExpressionBuilding event, + and the creation of the will have been wrapped with a + delegate that executes the registered + initializers + that are applicable to the given (if any). + + The interface or base type that can be used to retrieve instances. + The concrete type that will be registered. + A delegate. + + + + Builds an that describes the creation of the + using the supplied . The returned might + be intercepted by a + Container.ExpressionBuilding event, + and the will have been wrapped with a delegate that executes the + registered initializers that are + applicable to the given (if any). + + The interface or base type that can be used to retrieve instances. + + The delegate supplied by the user that allows building or creating new instances. + An . + + + + Builds an that describes the creation of + . The returned might be intercepted + by a Container.ExpressionBuilding + event, and the creation of the will have been wrapped with + a delegate that executes the registered + initializers + that are applicable to the given (if any). + + The interface or base type that can be used to retrieve instances. + The concrete type that will be registered. + An . + + + Gets the type that this instance will create. + The type that this instance will create. + + + Gets the this that created this registration. + The this that created this registration. + + + Gets the instance for this registration. + The instance for this registration. + + + + Allows retrieving the concrete types of the generic type arguments of that must be used to create a + closed generic implementation of a given open generic implementation, based on on the concrete + arguments of the given closed base type. + + + + + Helper class for building closed generic type for a given open generic type and a closed generic base. + + + + Result of the GenericTypeBuilder. + + + + A open generic type with the concrete arguments that can be used to create a closed generic type. + + + + + Helper methods for the extensions. + + + + + Represents the method that will called to register one or multiple concrete non-generic + of the given closed generic type + . + + The service type that needs to be registered. + One or more concrete types that implement the given + . + + + { + foreach (Type implementation in implementations) + { + container.RegisterSingle(implementation); + } + + container.RegisterAll(closedServiceType, implementations); + }; + + container.RegisterManyForOpenGeneric( + typeof(ICommandHandler<>), + registerAsCollectionAsSingletons, + typeof(ICommandHandler<>).Assembly); + ]]> + The BatchRegistrationCallback can be supplied to some overloads of the + RegisterManyForOpenGeneric extension methods. + The default behavior of the RegisterManyForOpenGeneric methods is to register a closed generic + type with the corresponding implementation (and will throw when multiple implementations are found for + a single closed generic service type). The given example overrides this default registration by + registering the found list of implementations (one or more) as collection of singletons for the given + closed generic service type. + + + + Defines the accessibility of the types to search. + This type is not available in Silverlight. + + + Load both public as internal types from the given assemblies. + + + Only load publicly exposed types from the given assemblies. + + + + Provides a set of static (Shared in Visual Basic) methods for registration many concrete types at + once that implement the same open generic service types in the . + + + + + Registers all concrete, non-generic, public and internal types in the given set of + that implement the given + with a transient lifetime. + + The container to make the registrations in. + The definition of the open generic type. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Registers all concrete, non-generic, public and internal types that are located in the given + that implement the given + with a transient lifetime. + + The container to make the registrations in. + The definition of the open generic type. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Registers all concrete, non-generic, public and internal types in the given set of + that implement the given + with the supplied . When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will point at the same registration and return the same instance based on the caching + behavior of the supplied . + + The container to make the registrations in. + The definition of the open generic type. + The lifestyle that will be used for the registration of the types. + A list of assemblies that will be searched. + Thrown when , + , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Registers all concrete, non-generic, public and internal types that are located in the given + that implement the given + with the supplied . When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will point at the same registration and return the same instance based on the caching + behavior of the supplied . + + The container to make the registrations in. + The definition of the open generic type. + The lifestyle that will be used for the registration of the types. + A list of assemblies that will be searched. + Thrown when , + , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Allows registration of all concrete, public and internal, non-generic types that are located in the given set of + that implement the given , + by supplying a delegate, that will be called for each + found closed generic implementation of the given . + + The container to make the registrations in. + The definition of the open generic type. + The delegate that will be called for each found closed generic version of + the given open generic to do the actual registration. + A list of assemblies that will be searched. + Thrown when , + , , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type. + + + + Allows registration of all concrete, public and internal, non-generic types that are located in the given set of + that implement the given , + by supplying a delegate, that will be called for each + found closed generic implementation of the given . + + The container to make the registrations in. + The definition of the open generic type. + The delegate that will be called for each found closed generic version of + the given open generic to do the actual registration. + A list of assemblies that will be searched. + Thrown when , + , , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type. + + + + Registers all concrete, non-generic, public and internal types that are located in the given + that implement the given + with a singleton lifetime. + + The container to make the registrations in. + The definition of the open generic type. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Registers all concrete, non-generic, public and internal types that are located in the given + that implement the given + with a singleton lifetime. + + The container to make the registrations in. + The definition of the open generic type. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Registers all supplied by a closed generic definition of the + given with a transient lifetime. + + The container to make the registrations in. + The definition of the open generic type. + The list of types that must be registered according to the given + definition. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + Thrown when there are multiple types in the given + collection that implement the same closed version of the + supplied . + + + + + Registers all supplied by a closed generic definition of the + given with a transient lifetime. + + The container to make the registrations in. + The definition of the open generic type. + The list of types that must be registered according to the given + definition. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + Thrown when there are multiple types in the given + collection that implement the same closed version of the + supplied . + + + + + Allows registration of all supplied by a closed generic + definition of the given , by supplying a + delegate, that will be called for each found closed generic + implementation. + If the list contains open generic types, matching closed generic versions of each open generic + type will be added to the list of implementations that is passed on to the + delegate. + + The container to make the registrations in. + The definition of the open generic type. + The delegate that will be called for each found closed generic version of + the given open generic to do the actual registration. + The list of types that must be registered according to the given + definition. + Thrown when , + , , or + contain a null reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + + + + Registers all supplied by a closed generic definition of the + given with a singleton lifetime. + When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will return the exact same instance. + + The container to make the registrations in. + The definition of the open generic type. + The list of types that must be registered according to the given + definition. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + Thrown when there are multiple types in the given + collection that implement the same closed version of the + supplied . + + + + + Registers all supplied by a closed generic definition of the + given with the supplied . + When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will return the exact same instance. + + The container to make the registrations in. + The definition of the open generic type. + The lifestyle the registrations are made in. + The list of types that must be registered according to the given + definition. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + Thrown when there are multiple types in the given + collection that implement the same closed version of the + supplied . + + + + + Registers all supplied by a closed generic definition of the + given with a singleton lifetime. + When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will return the exact same instance. + + The container to make the registrations in. + The definition of the open generic type. + The list of types that must be registered according to the given + definition. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + Thrown when there are multiple types in the given + collection that implement the same closed version of the + supplied . + + + + + Registers all supplied by a closed generic definition of the + given with the supplied + When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will return the exact same instance. + + The container to make the registrations in. + The definition of the open generic type. + The lifestyle the registrations are made in. + The list of types that must be registered according to the given + definition. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + Thrown when there are multiple types in the given + collection that implement the same closed version of the + supplied . + + + + + Registers all concrete, non-generic types with the given + that are located in the given that implement the given + with a transient lifetime. + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + Thrown when the given set of + contain multiple types that implement the same closed generic + version of the given . + + + + Registers all concrete, non-generic types with the given + that are located in the given that implement the given + with a transient lifetime. + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type or when the argument contains an invalid + value. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Registers all concrete, non-generic types with the given + that are located in the given that implement the given + with the supplied . + When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will point at the same registration and return the same instance based on the caching + behavior of the supplied . + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + The lifestyle that will be used for the registration of the types. + A list of assemblies that will be searched. + Thrown when , + , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + Thrown when the given set of + contain multiple types that implement the same closed generic + version of the given . + + + + Registers all concrete, non-generic types with the given + that are located in the given that implement the given + with the supplied . + When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will point at the same registration and return the same instance based on the caching + behavior of the supplied . + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + The lifestyle that will be used for the registration of the types. + A list of assemblies that will be searched. + Thrown when , + , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Allows registration of all concrete, non-generic types with the given + that are located in the given set of + that implement the given , by supplying a + delegate, that will be called for each found closed generic + implementation of the given . + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + The delegate that will be called for each found closed generic version of + the given open generic to do the actual registration. + A list of assemblies that will be searched. + Thrown when , + , , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + + + + Allows registration of all concrete, non-generic types with the given + that are located in the given set of + that implement the given , by supplying a + delegate, that will be called for each found closed generic + implementation of the given . + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + The delegate that will be called for each found closed generic version of + the given open generic to do the actual registration. + A list of assemblies that will be searched. + Thrown when , + , , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + + + + Registers all concrete, non-generic types with the given + that are located in the given that implement the given + with a singleton lifetime. + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + Thrown when the given set of + contain multiple types that implement the same closed generic + version of the given . + + + + Registers all concrete, non-generic types with the given + that are located in the given that implement the given + with a singleton lifetime. + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Returns all types that are located in the supplied + and implement or inherit from the supplied . + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), AccessibilityOption.PublicTypesOnly, + typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the + registration. + + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + A list of types. + Thrown when + contains an invalid value. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all types that are located in the supplied + and implement or inherit from the supplied . + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), AccessibilityOption.PublicTypesOnly, + typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the registration. + + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + A list of types. + Thrown when + contains an invalid value. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all types that are located in the supplied + and implement or inherit from the supplied . + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), AccessibilityOption.PublicTypesOnly, + typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the + registration. + + The container to use. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + A list of types. + Thrown when + contains an invalid value. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all types that are located in the supplied + and implement or inherit from the supplied . + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), AccessibilityOption.PublicTypesOnly, + typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the registration. + + The container to use. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + A list of types. + Thrown when + contains an invalid value. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all public and internal types that are located in the supplied + and implement or inherit from the supplied . + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the + registration. + + The definition of the open generic type. + A list of assemblies that will be searched. + A list of types. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all public and internal types that are located in the supplied + and implement or inherit from the supplied . + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the registration. + + The definition of the open generic type. + A list of assemblies that will be searched. + A list of types. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all public and internal types that are located in the supplied + and implement or inherit from the supplied . + Types that are considered to be decorators are not returned. + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the + registration. + + The container to use. + The definition of the open generic type. + A list of assemblies that will be searched. + A list of types. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all public and internal types that are located in the supplied + and implement or inherit from the supplied . + Types that are considered to be decorators are not returned. + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the registration. + + The container to use. + The definition of the open generic type. + A list of assemblies that will be searched. + A list of types. + Thrown when , or + contain a null reference (Nothing in VB). + + + + An instance of this type will be supplied to the + delegate that is that is supplied to the + RegisterOpenGeneric + overload that takes this delegate. This type contains information about the open generic service that is about + to be created and it allows the user to examine the given instance to decide whether this implementation should + be created or not. + + + Please see the + RegisterOpenGeneric + method for more information. + + + + Gets the closed generic service type that is to be created. + The closed generic service type. + + + Gets the closed generic implementation type that will be created by the container. + The implementation type. + + + Gets a value indicating whether a previous RegisterOpenGeneric registration has already + been applied for the given . + The indication whether the event has been handled. + + + + Provides a set of static (Shared in Visual Basic) methods for registration of open generic service + types in the . + + + + + Registers that a new instance of will be returned + every time a is requested. + + + Please see the + RegisterOpenGeneric(Container,Type,Type,Lifestyle) + overload for an example. + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances. + The definition of the open generic implementation type + that will be returned when a is requested. + + + + Registers that the same instance of will be returned + every time a is requested. + + + Please see the + RegisterOpenGeneric(Container,Type,Type,Lifestyle) + overload for an example. + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances.. + The definition of the open generic implementation type + that will be returned when a is requested. + + + + Registers that a closed generic instance of the supplied + will be returned when a closed generic version of + the is requested. The instance will be cached + according to the specified . + + + Types registered using the RegisterOpenGeneric are resolved using unregistered type + resolution. This means that an explicit registration made for a closed generic version of the + always gets resolved first and the given + only gets resolved when there is no such registration. + + + The following example shows the definition of a generic IValidator<T> interface + and, a NullValidator<T> implementation and a specific validator for Orders. + The registration ensures a OrderValidator is returned when a + IValidator<Order> is requested. For all requests for a + IValidator<T> other than a IValidator<Order>, an + implementation of NullValidator<T> will be returned. + + { + void Validate(T instance); + } + + public class NullValidator : IValidator + { + public void Validate(T instance) + { + } + } + + public class OrderValidator : IValidator + { + public void Validate(Order instance) + { + if (instance.Total < 0) + { + throw new ValidationException("Total can not be negative."); + } + } + } + + [TestMethod] + public static void TestRegisterOpenGeneric() + { + // Arrange + var container = new Container(); + + container.Register, OrderValidator>(Lifestyle.Transient); + container.RegisterOpenGeneric(typeof(IValidator<>), typeof(NullValidator<>), Lifestyle.Singleton); + + // Act + var orderValidator = container.GetInstance>(); + var customerValidator = container.GetInstance>(); + var productValidator = container.GetInstance>(); + + // Assert + Assert.IsInstanceOfType(orderValidator, typeof(OrderValidator)); + Assert.IsInstanceOfType(customerValidator, typeof(NullValidator)); + Assert.IsInstanceOfType(productValidator, typeof(NullValidator)); + } + ]]> + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances. + The definition of the open generic implementation type + that will be returned when a is requested. + The lifestyle that defines how returned instances are cached. + + + + Registers that the same instance of will be returned + every time a is requested. + + + Please see the + RegisterOpenGeneric(Container,Type,Type,Lifestyle) + overload for an example. + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances.. + The definition of the open generic implementation type + that will be returned when a is requested. + The lifestyle that defines how returned instances are cached. + The predicate that determines whether the + can implement the service type. + + + + Registers that instances of will be returned + when a collection of is requested. New instances of + the registered will be returned whenever the + resolved collection is iterated. + + + Please see the + RegisterAllOpenGeneric(Container,Type,Lifestyle,IEnumerable<Type>) + overload for an example. + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances. + The list of open generic implementation types + that will be returned when a collection of is requested. + + + + + Registers that instances of will be returned + when a collection of is requested. New instances of + the registered will be returned whenever the + resolved collection is iterated. + + + Please see the + RegisterAllOpenGeneric(Container,Type,Lifestyle,IEnumerable<Type>) + overload for an example. + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances. + The list of open generic implementation types + that will be returned when a collection of is requested. + + + + + Registers that instances of will be returned + when a collection of is requested. The instances will be + cached according to the specified . + + + Please see the + RegisterAllOpenGeneric(Container,Type,Lifestyle,IEnumerable<Type>) + overload for an example. + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances. + The lifestyle that defines how returned instances are cached. + The list of open generic implementation types + that will be returned when a collection of is requested. + + + + + Registers that instances of will be returned + when a collection of is requested. The instances will be + cached according to the specified . + + + + Collections registered using the RegisterAllOpenGeneric are resolved using unregistered type + resolution. This means that an explicit registration made for a collection of the closed generic + version of the always gets resolved first and a + collection of only gets resolved when there is no + such registration. + + + + The following example shows the definition of a generic IValidator<T> interface + and, a NullValidator<T> implementation and a specific validator for Orders. + The registration ensures a OrderValidator is returned when a + IValidator<Order> is requested. For all requests for a + IValidator<T> other than a IValidator<Order>, an + implementation of NullValidator<T> will be returned. + + { + void Validate(T instance); + } + + public class DefaultValidator : IValidator + { + public void Validate(T instance) + { + // some default validation + } + } + + [TestMethod] + public static void TestRegisterAllOpenGeneric() + { + // Arrange + var container = new Container(); + + Type[] types = new[] { typeof(OrderValidator), typeof(DefaultValidator<>) }; + + container.RegisterManyForOpenGeneric(typeof(IValidator<>), + (serviceType, implementationTypes) => container.RegisterAll(serviceType, implementationTypes), + types); + + container.RegisterAllOpenGeneric(typeof(IValidator<>), typeof(DefaultValidator<>)); + + // Act + var orderValidators = container.GetAllInstances>(); + var customerValidators = container.GetAllInstances>(); + + // Assert + Assert.IsTrue(orderValidators.SequenceEqual( + new[] { typeof(OrderValidator), typeof(DefaultValidator) })); + + // Without the call to RegisterAllOpenGeneric this customerValidators would be empty. + Assert.IsTrue(customerValidators.SequenceEqual(new[] { typeof(DefaultValidator) })); + } + ]]> + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances. + The lifestyle that defines how returned instances are cached. + The list of open generic implementation types + that will be returned when a collection of is requested. + + + + Resolves a given open generic type. + + + + Allows validating an ArgumentMapping. + + + + + Instances returned from the container can be cached. The contains several + overloads of the Register method that take a Lifestyle instance as argument to define + how returned instances should be cached. The core library contains two lifestyles out of the box. By + supplying Lifestyle.Transient, the registered instance is not + cached; a new instance is returned every time it is requested or injected. By supplying + Lifestyle.Singleton instances can be cached indefinitely; only + a single instance of the registered component will be returned by that container instance. Other + lifestyles are defined in integration and extension packages. The + CreateCustom method allows defining a custom lifestyle and + the CreateHybrid method + allows creating a lifestyle that mixes multiple other lifestyles. + + + This type is abstract and can be overridden to implement a custom lifestyle. + + + + + The lifestyle instance that doesn't cache instances. A new instance of the specified + component is created every time the registered service it is requested or injected. + + + The following example registers the SomeServiceImpl implementation for the + ISomeService service type using the Transient lifestyle: + (Lifestyle.Transient); + ]]> + Note that Transient is the default lifestyle, the previous registration can be reduced to + the following: + (); + ]]> + + + + + The lifestyle that caches components during the lifetime of the instance + and guarantees that only a single instance of that component is created for that instance. Since + general use is to create a single Container instance for the lifetime of the application / + AppDomain, this would mean that only a single instance of that component would exist during the + lifetime of the application. In a multi-threaded applications, implementations registered using + this lifestyle must be thread-safe. + + + The following example registers the RealTimeProvider implementation for the + ITimeProvider service type using the Singleton lifestyle: + (Lifestyle.Singleton); + ]]> + Note that using the + RegisterSingle method has + the same effect: + (); + ]]> + + + + Initializes a new instance of the class. + The user friendly name of this lifestyle. + Thrown when is null (Nothing in VB) + or an empty string. + + + + The hybrid lifestyle allows mixing two lifestyles in a single registration. Based on the supplied + delegate the hybrid lifestyle will redirect the creation of + the instance to the correct lifestyle. The result of the + delegate will not be cached; it is invoked each time an instance is requested or injected. By + nesting hybrid lifestyles, any number of lifestyles can be mixed. + + The delegate that determines which + lifestyle should be used. The will be used if true is + returned; the otherwise. This delegate will be called every + time an instance needs to be resolved or injected. + The lifestyle to use when + returns true. + The lifestyle to use when + returns false. + A new hybrid lifestyle that wraps the supplied lifestyles. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + + The following example shows the creation of a HybridLifestyle that mixes an + WebRequestLifestyle and LifetimeScopeLifestyle: + + HttpContext.Current != null, + new WebRequestLifestyle(), + new LifetimeScopeLifestyle()); + + // The created lifestyle can be reused for many registrations. + container.Register(mixedScopeLifestyle); + container.Register(mixedScopeLifestyle); + ]]> + + Hybrid lifestyles can be nested: + + container.GetCurrentLifetimeScope() != null, + new LifetimeScopeLifestyle(), + Lifestyle.Transient); + + var mixedScopeLifestyle = Lifestyle.CreateHybrid( + () => HttpContext.Current != null, + new WebRequestLifestyle(), + mixedLifetimeTransientLifestyle); + ]]> + + The mixedScopeLifestyle now mixed three lifestyles: Web Request, Lifetime Scope and + Transient. + + + + + + The hybrid lifestyle allows mixing two lifestyles in a single registration. Based on the supplied + delegate the hybrid lifestyle will redirect the creation of + the instance to the correct lifestyle. The result of the + delegate will not be cached; it is invoked each time an instance is requested or injected. By + nesting hybrid lifestyles, any number of lifestyles can be mixed. + + The delegate that determines which + lifestyle should be used. The will be used if true is + returned; the otherwise. This delegate will be called every + time an instance needs to be resolved or injected. + The scoped lifestyle to use when + returns true. + The scoped lifestyle to use when + returns false. + A new scoped hybrid lifestyle that wraps the supplied lifestyles. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + + The following example shows the creation of a HybridLifestyle that mixes an + WebRequestLifestyle and LifetimeScopeLifestyle: + + HttpContext.Current != null, + new WebRequestLifestyle(), + new LifetimeScopeLifestyle()); + + // The created lifestyle can be reused for many registrations. + container.Register(mixedScopeLifestyle); + container.Register(mixedScopeLifestyle); + ]]> + + + + + Creates a custom lifestyle using the supplied delegate. + + + The supplied will be called just once per registered + service. The supplied will be called by the framework + when the type is resolved for the first time, and the framework will supply the factory with a + Func<object> for creating new (transient) instances of that type (that might + have been intercepted and + initializers might have been applied). + It is the job of the to return a Func<object> + that applies the proper caching. The Func<object> that is returned by the + will be stored for that registration (every + registration will store its own Func<object> delegate) and this delegate will be + called every time the service is resolved (by calling + container.GetInstance<TService> or when that service is injected into another + type). + + The name of the lifestyle to create. The name is used to display the lifestyle + in the debugger. + A factory delegate that takes a Func<object> delegate + that will produce a transient instance and returns a delegate that returns cached instances. + A new . + Thrown when one of the arguments is a null reference + (Nothing in VB). + Thrown when is an empty string. + + The following example shows the creation of a lifestyle that caches registered instances for 10 + minutes: + + { + TimeSpan timeout = TimeSpan.FromMinutes(10); + var syncRoot = new object(); + var expirationTime = DateTime.MinValue; + object instance = null; + + // If the application has multiple registrations using this lifestyle, each registration + // will get its own Func delegate (created here) and therefore get its own set + // of variables as defined above. + return () => + { + lock (syncRoot) + { + if (expirationTime < DateTime.UtcNow) + { + instance = instanceCreator(); + expirationTime = DateTime.UtcNow.Add(timeout); + } + + return instance; + } + }; + }); + + var container = new Container(); + + // We can reuse the created lifestyle for multiple registrations. + container.Register(customLifestyle); + container.Register(customLifestyle); + ]]> + + + + + Creates a new instance for the given + that will create new instances of specified with the + caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be created. + The instance for which a + must be created. + A new instance. + Thrown when is a null + reference (Nothing in VB). + + + + Creates a new instance for the given + that will create new instances instance using the supplied + with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + A delegate that will create a new instance of + every time it is called. + The instance for which a + must be created. + A new instance. + Thrown when either or + are null references (Nothing in VB). + + + + Creates a new instance for the given + that will create new instances of specified with the + caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + The instance for which a + must be created. + A new instance. + Thrown when on of the supplied arguments is a null + reference (Nothing in VB). + + + + Creates a new instance defining the creation of the + specified with the caching as specified by this lifestyle. + + The concrete type that will be registered. + The instance for which a + must be created. + A new instance. + Thrown when is a null + reference (Nothing in VB). + + + + Creates a new instance defining the creation of the + specified with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be created. + The instance for which a + must be created. + A new instance. + Thrown when is a null + reference (Nothing in VB). + + + + Creates a new instance defining the creation of the + specified using the supplied + with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + A delegate that will create a new instance of + every time it is called. + The instance for which a + must be created. + A new instance. + Thrown when either or + are null references (Nothing in VB). + + + + Creates a new instance defining the creation of the + specified with the caching as specified by this lifestyle. + This method might fail when run in a partial trust sandbox when + is an internal type. + + The concrete type that will be registered. + The instance for which a + must be created. + A new instance. + Thrown when on of the supplied arguments is a null + reference (Nothing in VB). + + + + Creates a new instance defining the creation of the + specified with the caching as specified by this lifestyle. + This method might fail when run in a partial trust sandbox when + is an internal type. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + The instance for which a + must be created. + A new instance. + Thrown when on of the supplied arguments is a null + reference (Nothing in VB). + + + + Creates a new instance defining the creation of the + specified using the supplied + with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + The delegate that will be responsible for creating new instances. + The instance for which a + must be created. + A new instance. + Thrown when on of the supplied arguments is a null + reference (Nothing in VB). + + + + When overridden in a derived class, + creates a new instance defining the creation of the + specified with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + The instance for which a + must be created. + A new instance. + + If you are implementing your own lifestyle, override this method to implement the code necessary + to create and return a new . Note that you should always create + a new instance. They should never be cached. + + + + + When overridden in a derived class, + creates a new instance defining the creation of the + specified using the supplied + with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + A delegate that will create a new instance of + every time it is called. + The instance for which a + must be created. + A new instance. + + If you are implementing your own lifestyle, override this method to implement the code necessary + to create and return a new . Note that you should always create + a new instance. They should never be cached. + + + + Gets the user friendly name of this lifestyle. + The user friendly name of this lifestyle. + + + + Gets the length of the lifestyle. Implementers must implement this property. The diagnostic + services use this value to compare lifestyles with each other to determine lifestyle + misconfigurations. + + The representing the length of this lifestyle. + + + + A known relationship defines a relationship between two types. The Diagnostics Debug View uses this + information to spot possible misconfigurations. + + + + Initializes a new instance of the class. + The implementation type of the parent type. + The lifestyle of the parent type. + The type that the parent depends on (it is injected into the parent). + + + Serves as a hash function for a particular type. + A hash code for the current . + + + + Determines whether the specified is equal to the current + . + + The object to compare with the current object. + True if the specified is equal to the current + ; otherwise, false. + + + Gets the implementation type of the parent type of the relationship. + The implementation type of the parent type of the relationship. + + + Gets the lifestyle of the parent type of the relationship. + The lifestyle of the parent type of the relationship. + + + Gets the type that the parent depends on (it is injected into the parent). + The type that the parent depends on. + + + + Factory for the creation of a delegate that applies caching to the supplied + . + + A factory for creating new instances. + A factory that returns cached instances. + + + + Forwards CreateRegistration calls to the lifestyle that is returned from the registered + container.Options.LifestyleSelectionBehavior. + + + + + Base class for scoped lifestyles. A scoped lifestyle caches instances for the duration of an implicitly + or explicitly defined scope. Such scope can be an (implicitly defined) web request or an explicitly + defined Lifetime Scope. The lifetime of instances registered with a scoped lifestyle is always equal + or bigger than one-instance-per-object-graph. In other words, a call to GetInstance() will never create + more than one instance of such registered type. + + + + Initializes a new instance of the class. + The user friendly name of this lifestyle. + Thrown when is null (Nothing in VB) + or an empty string. + + + Initializes a new instance of the class. + The user friendly name of this lifestyle. + Signals the lifestyle whether instances should be + disposed or not. + Thrown when is null (Nothing in VB) + or an empty string. + + + + Allows registering an delegate that will be called when the scope ends, + but before the scope disposes any instances. + + + During the call to all registered delegates are + processed in the order of registration. Do note that registered actions are not guaranteed + to run. In case an exception is thrown during the call to , the + will stop running any actions that might not have been invoked at that point. + Instances that are registered for disposal using on the other + hand, are guaranteed to be disposed. Note that registered actions won't be invoked during a call + to . + + The instance. + The delegate to run when the scope ends. + Thrown when one of the arguments is a null reference + (Nothing in VB). + Will be thrown when there is currently no active + scope for the supplied . + + + + Adds the to the list of items that will get disposed when the + scope ends. + + + Note to implementers: Instances registered for disposal will have to be disposed in the opposite + order of registration, since disposable components might still need to call disposable dependencies + in their Dispose() method. + + The instance. + The instance that should be disposed when the scope ends. + Thrown when one of the arguments is a null reference + (Nothing in VB). + Will be thrown when there is currently no active + scope for the supplied . + + + + Returns the current for this lifestyle and the given + , or null when this method is executed outside the context of a scope. + + The container instance that is related to the scope to return. + A instance or null when there is no scope active in this context. + + + + Creates a delegate that upon invocation return the current for this + lifestyle and the given , or null when the delegate is executed outside + the context of such scope. + + The container for which the delegate gets created. + A delegate. This method never returns null. + + + + Returns the current for this lifestyle and the given + , or null when this method is executed outside the context of a scope. + + The container instance that is related to the scope to return. + A instance or null when there is no scope active in this context. + + + + Creates a new instance defining the creation of the + specified using the supplied + with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + A delegate that will create a new instance of + every time it is called. + The instance for which a + must be created. + A new instance. + + + + Creates a new instance defining the creation of the + specified with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + The instance for which a + must be created. + A new instance. + + + + Disposes the list of supplied . The list is iterated in reverse + order (the first element in the list will be disposed last) and the method ensures that the + Dispose method of each element is called, regardless of any exceptions raised from any previously + called Dispose methods. If multiple exceptions are thrown, the last thrown exception will bubble + up the call stack. + + The list of objects to be disposed. + Thrown when the is a null + reference. + + + + Helper methods for the container. + + + + + Produces instances for a given registration. Instances of this type are generally created by the + container when calling one of the Register overloads. Instances can be retrieved by calling + or . + + + The Register method overloads create InstanceProducer instances internally, but + InstanceProducers can be created manually to implement special scenarios. An + InstanceProducer wraps instance. The Registration builds an + that describes the intend to create the instance according to a certain + lifestyle. The InstanceProducer on the other hand transforms this Expression to a + delegate and allows the actual instance to be created. A Registration itself can't create any + instance. The InsanceProducer allows intercepting created instances by hooking onto the + Container.ExpressionBuilt event. The + RegisterDecorator + extension methods for instance work by hooking onto the ExpressionBuilt event and allow + wrapping the returned instance with a decorator. + + + The following example shows the creation of two different InstanceProducer instances that wrap + the same Registration instance. Since the Registration is created using the + Singleton lifestyle, both producers will return + the same instance. The InstanceProducer for the Interface1 however, will wrap that + instance in a (transient) Interface1Decorator. + (container); + + var producer1 = new InstanceProducer(typeof(Interface1), registration); + var producer2 = new InstanceProducer(typeof(Interface2), registration); + + container.RegisterDecorator(typeof(Interface1), typeof(Interface1Decorator)); + + var instance1 = (Interface1)producer1.GetInstance(); + var instance2 = (Interface2)producer2.GetInstance(); + + Assert.IsInstanceOfType(instance1, typeof(Interface1Decorator)); + Assert.IsInstanceOfType(instance2, typeof(ServiceImpl)); + + Assert.AreSame(((Interface1Decorator)instance1).DecoratedInstance, instance2); + ]]> + + + + Initializes a new instance of the class. + The service type for which this instance is created. + The . + + + Produces an instance. + An instance. Will never return null. + When the instance could not be retrieved or is null. + + + + Builds an expression that expresses the intent to get an instance by the current producer. A call + to this method locks the container. No new registrations can't be made after a call to this method. + + An Expression. + + + + Gets the collection of relationships for this instance that the container knows about. + This includes relationships between the registered type and its dependencies and relationships + between applied decorators and their dependencies. Note that types that are not newed up by the + container, property dependencies that are injected using the (legacy) + InjectProperties method, and + properties that are injected inside a custom delegate that is registered using the + RegisterInitializer method are unknown + to the container and are not returned from this method. + Also note that this method will return an empty collection when called before the the + registered type is requested from the container (or before Verify + is called). + + An array of instances. + + + + Builds a string representation of the object graph with the current instance as root of the + graph. + + A string representation of the object graph. + Thrown when this method is called before + or have been called. These calls can be + done directly and explicitly by the user on this instance, indirectly by calling + or on an instance that depends on this + instance, or by calling Verify on the container. + + + + Gets the for this registration. The returned lifestyle can differ from the + lifestyle that is used during the registration. This can happen for instance when the registration + is changed by an ExpressionBuilt registration or + gets decorated. + + The for this registration. + + + Gets the service type for which this producer produces instances. + A instance. + + + Gets the instance for this instance. + The . + + + Internal helper for string resources. + + + + Provides data for and interaction with the + ResolveUnregisteredType event of + the . An observer can check the + to see whether the unregistered type can be handled. The + method can be called to register a delegate + that allows creation of instances of the unregistered for this and future requests. + + + + Initializes a new instance of the UnregisteredTypeEventArgs class. + The unregistered service type. + + + + Registers a delegate that allows creation of instances of the type + expressed by the for this and future requests. The delegate + will be caches and future requests will directly call that delegate. + + The delegate that allows creation of instances of the type + expressed by the . + Thrown when the is a + null reference. + Thrown when multiple observers that have registered to + the ResolveUnregisteredType event + called this method for the same type. + + + + Registers an that describes the creation of instances of the type + expressed by the for this and future requests. The delegate + will be cached and future requests will directly use that expression or the compiled delegate. + + + NOTE: If possible, use the Register(Registration) overload, + since this allows the analysis services to determine any configuration errors on the lifestyle of + the registration. + + The expression that describes the creation of instances of the type + expressed by the . + Thrown when the is a + null reference. + Thrown when multiple observers that have registered to + the ResolveUnregisteredType event + called this method for the same type. + + + + Registers a that describes the creation of instances of the type + expressed by the for this and future requests. The + registration will be cached and future requests will directly call unon that registration, the + expression that it generates or the delegate that gets compiled from that expression. + + The registration that describes the creation of instances according to + the registration's lifestyle of the type expressed by the . + Thrown when the is a + null reference. + Thrown when the is a + not exactly of type where T equals the . + + Thrown when multiple observers that have registered to + the ResolveUnregisteredType event + called this method for the same type. + + + Gets the unregistered service type that is currently requested. + The unregistered service type that is currently requested. + + + + Gets a value indicating whether the event represented by this instance has been handled. + This property will return true when has been called on + this instance. + + The indication whether the event has been handled. + + + diff --git a/packages/SimpleInjector.2.6.1/lib/net45/SimpleInjector.Diagnostics.xml b/packages/SimpleInjector.2.6.1/lib/net45/SimpleInjector.Diagnostics.xml new file mode 100644 index 0000000..254c1bd --- /dev/null +++ b/packages/SimpleInjector.2.6.1/lib/net45/SimpleInjector.Diagnostics.xml @@ -0,0 +1,193 @@ + + + + SimpleInjector.Diagnostics + + + + + Entry point for doing diagnostic analysis on instances. + + + The following example shows the usage of the Analyzer class: + + + + + + Analyzes the supplied instance. + + The container instance to analyze. + A collection of sub types that describe the diagnostic + warnings and messages. + + + + Diagnostic result for a warning about a concrete type that was not registered explicitly and was not + resolved using unregistered type resolution, but was created by the container using the transient + lifestyle. + For more information, see: https://simpleinjector.org/diaut. + + + + + Base class for types that hold information about a single diagnostic message or warning for a + particular type or part of the configuration. + + + + Gets the diagnostic type of this result. + The . + + + Gets the service type to which this warning is related. + A . + + + Gets the description of the diagnostic result. + A with the description. + + + Gets the hierarchical group to which this diagnostic result belongs. + The . + + + Gets a collection of instances that describe all + container-registered dependencies for the given component. + List of objects. + + + + A hierarchical group of . + + + + + Gets the base that describes the service types of its + . The value often be either (in case this is a + root group) or a partial generic type to allow hierarchical grouping of a large number of related + generic types. + + The . + + + Gets the friendly name of the group. + The name. + + + Gets the description of the group. + The description. + + + Gets the diagnostic type of all grouped instances. + The . + + + Gets the parent or null (Nothing in VB) when this is the + root group. + The . + + + Gets the collection of child s. + A collection of elements. + + + Gets the collection of instances. + /// A collection of elements. + + + + Specifies the list of diagnostic types that are currently supported by the diagnostic + . Note that new diagnostic types might be added in future versions. + For more information, please read the + Diagnosing your configuration using the Diagnostic + Services wiki documentation. + + + + + Diagnostic type that warns about + a concrete type that was not registered explicitly and was not resolved using unregistered type + resolution, but was created by the container using the transient lifestyle. + For more information, see: https://simpleinjector.org/diaut. + + + + + Diagnostic type that warns when a + component depends on a service with a lifestyle that is shorter than that of the component. + For more information, see: https://simpleinjector.org/dialm. + + + + + Diagnostic type that warns when a + component depends on an unregistered concrete type and this concrete type has a lifestyle that is + different than the lifestyle of an explicitly registered type that uses this concrete type as its + implementation. + For more information, see: https://simpleinjector.org/diasc. + + + + + Diagnostic type that warns when a + component depends on (too) many services. + For more information, see: https://simpleinjector.org/diasr. + + + + + Diagnostic result for a warning about a + component that depends on a service with a lifestyle that is shorter than that of the component. + For more information, see: https://simpleinjector.codeplex.com/wikipage?title=PotentialLifestyleMismatches. + + + + Gets the object that describes the relationship between the component and its dependency. + A instance. + + + + Diagnostic result that warns about a + component that depends on an unregistered concrete type and this concrete type has a lifestyle that is + different than the lifestyle of an explicitly registered type that uses this concrete type as its + implementation. + For more information, see: https://simpleinjector.codeplex.com/wikipage?title=ShortCircuitedDependencies. + + + + Gets the instance that describes the current relationship between the checked component + and the short-circuited dependency. + The . + + + + Gets the collection of registrations that have the component's current dependency as + implementation type, but have a lifestyle that is different than the current dependency. + + A collection of instances. + + + + Diagnostic result that warns about a component that depends on (too) many services. + For more information, see: https://simpleinjector.codeplex.com/wikipage?title=PotentialSingleResponsibilityViolations. + + + + Gets the created type. + A . + + + Gets the list of registrations that are dependencies of the . + A collection of instances. + + + diff --git a/packages/SimpleInjector.2.6.1/lib/net45/SimpleInjector.xml b/packages/SimpleInjector.2.6.1/lib/net45/SimpleInjector.xml new file mode 100644 index 0000000..18de2a3 --- /dev/null +++ b/packages/SimpleInjector.2.6.1/lib/net45/SimpleInjector.xml @@ -0,0 +1,4583 @@ + + + + SimpleInjector + + + + + The standard exception thrown when a container has an error in resolving an object. + + + + + Initializes a new instance of the class. + + + + + Initializes a new instance of the class with a specified error + message. + + The message that describes the error. + + + + Initializes a new instance of the class with a specified error + message and a reference to the inner exception that is the cause of this exception. + + + The error message that explains the reason for the exception. + + + The exception that is the cause of the current exception, or a null reference (Nothing in Visual + Basic) if no inner exception is specified. + + + + + Initializes a new instance of the class with serialized data. + + + The that holds the serialized object data about the exception + being thrown. + + + The that contains contextual information about the source or + destination. + + + The parameter is null. + + + The class name is null or hresult is zero (0). + + + + + Extension methods for enable advanced scenarios. + + + + + Determines whether the specified container is locked making any new registrations. The container + is automatically locked when GetInstance is called for the + first time. + + The container. + + true if the specified container is locked; otherwise, false. + + Thrown when is null. + + + Determines whether the specified container is currently verifying its configuration. + The container. + true if the specified container is verifying; otherwise, false. + Thrown when is null. + + + + Builds up an delegate wrapping all delegates that + are registered using RegisterInitializer and + that apply to the given (including delegates that are registered + for interfaces implements and base types that + inherits from). Null will be returned when no delegates are + registered that apply to this type. + + The container. + + This method has a performance caracteristic of O(n). Prevent from calling this in a performance + critical path of the application. + + The type for with an initializer must be built. + An delegate or null. + + + + Retrieves an item from the container stored by the given or null when no + item is stored by that key. + + + Thread-safety: Calls to this method are thread-safe, but users should take proper + percausions when they call both GetItem and . + + The container. + The key of the item to retrieve. + The stored item or null (Nothing in VB). + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + + + Stores an item by the given in the container. + + + Thread-safety: Calls to this method are thread-safe, but users should take proper + percausions when they call both and SetItem. + + The container. + The key of the item to insert or override. + The actual item. May be null. + Thrown when either or + is a null reference (Nothing in VB). + + + + Allows appending new registrations to existing registrations made using one of the + RegisterAll overloads. + + The container. + The service type of the collection. + The registration to append. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + Thrown when the is not a + reference type, is open generic, or ambiguous. + Thrown when the container is locked. + Thrown when the method is called for a registration + that is made with one of the RegisterAll overloads that accepts a dynamic collection + (an IEnumerable or IEnumerable<TService>). + + + + Defines the container's behavior for building an expression tree based on the supplied constructor of + a given type. + Set the ConstructorInjectionBehavior + property of the container's property to change the default behavior + of the container. + + + + + Builds an for the supplied , based on the + container's configuration. + + The parameter. + An that describes the intend of creating that + . This method never returns null. + + + + Defines the container's behavior for finding a suitable constructor for the creation of a type. + Set the ConstructorResolutionBehavior + property of the container's property to change the default behavior + of the container. + + + + + Gets the given 's constructor that can be used by the + container to create that instance. + + Type of the abstraction that is requested. + Type of the implementation to find a suitable constructor for. + + The . This method never returns null. + + Thrown when no suitable constructor could be found. + + + + Defines the container's behavior for verifying the constructor that will be picked by the + . + Set the ConstructorVerificationBehavior + property of the container's property to change the default behavior + of the container. + + + + Verifies the specified . + The parameter. + Thrown when the cannot be + used for auto wiring. + + Thrown when the is a + null reference. + + + + Defines the container's behavior for selecting the lifestyle for a registration in case no lifestyle + is explicitly supplied. + Set the LifestyleSelectionBehavior + property of the container's property to change the default behavior + of the container. By default, when no lifestyle is explicitly supplied, the + Transient lifestyle is used. + + + + Selects the lifestyle based on the supplied type information. + Type of the abstraction that is registered. + Type of the implementation to that is registered. + The suited for the given type. + Thrown when either one of the arguments is a null reference. + + + + Defines the container's behavior for selecting properties to inject during the creation of a type. + Set the PropertySelectionBehavior + property of the container's property to change the default behavior + of the container. By default, no properties will be injected by the container. + + + + + Determines whether a property should be injected by the container upon creation of its type. + + Type of the abstraction that is requested. + The property to check. + True when the property should be injected. + + + + An instance of this type will be supplied to the + delegate that is that is supplied to the + RegisterInitializer + overload that takes this delegate. This type contains contextual information about the creation and it + allows the user to examine the given instance to decide whether the instance should be initialized or + not. + + + + + Gets the that is responsible for the initialization of the created + instance. + + The or null (Nothing in VB) when the instance producer is + unknown. + + + + Gets the that is responsible for the initialization of the created + instance. + + /// The . + + + + Contains data that can be used to initialize a created instance. This data includes the actual + created and the information about the created instance. + + + + Returns the hash code for this instance. + A 32-bit signed integer that is the hash code for this instance. + + + Indicates whether this instance and a specified object are equal. + Another object to compare to. + True if the current object is equal to the other parameter; otherwise, false. + + + + Indicates whether the current object is equal to another object of the same type. + + An object to compare with this object. + True if the current object is equal to the other parameter; otherwise, false. + + + + Indicates whether the values of two specified objects are equal. + + The first object to compare. + The second object to compare. + True if a and b are equal; otherwise, false. + + + + Indicates whether the values of two specified objects are + not equal. + + The first object to compare. + The second object to compare. + True if a and b are not equal; otherwise, false. + + + Gets the with contextual information about the + created instance. + The . + + + Gets the created instance. + The created instance. + + + + This is an internal type. Only depend on this type when you want to be absolutely sure a future + version of the framework will break your code. + + + + Initializes a new instance of the struct. + The scope factory. + The container. + + + Gets the lazily initialized Scope of the current LazyScope instance. + The current Scope or null. + + + + This is an internal type. Only depend on this type when you want to be absolutely sure a future + version of the framework will break your code. + + Service type. + Implementation type. + + + + Initializes a new instance of the + struct. + The registration. + + + Gets the lazily initialized instance for the of the current LazyScopedRegistration. + The scope that is used to retrieve the instance. + The cached instance. + + + + The container. Create an instance of this type for registration of dependencies. + + + + Thread-safety: + Resolving instances can be done safely from multiple threads concurrently, but registration needs to + be done from one single thread. + + + It is therefore safe to call , , + GetService, and + and anything related to resolving instances from multiple thread + concurrently. It is however unsafe to call + RegisterXXX, + , , , + or anything related to registering from multiple threads concurrently. + + + + + + Registers that a new instance of will be returned every time it + is requested (transient). + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + The concrete type that will be registered. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + Thrown when the is a type + that can not be created by the container. + + + + Registers that an instance of will be returned when it + is requested. The instance is cached according to the supplied . + + The concrete type that will be registered. + The lifestyle that specifies how the returned instance will be cached. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + Thrown when the is a type + that can not be created by the container. + + + + Registers that a new instance of will be returned every time a + is requested (transient). + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + Thrown when the given + type is not a type that can be created by the container. + + + + + Registers the specified delegate that allows returning transient instances of + . The delegate is expected to always return a new instance on + each call. + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + The interface or base type that can be used to retrieve instances. + The delegate that allows building or creating new instances. + + Thrown when this container instance is locked and can not be altered, or when the + has already been registered. + + Thrown when is a null reference. + + + + Registers that a new instance of will be returned every time it + is requested (transient). + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + The concrete type that will be registered. + Thrown when is a null + references (Nothing in VB). + Thrown when represents an + open generic type or is a type that can not be created by the container. + + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + + Registers that a new instance of will be returned every time a + is requested. If and + represent the same type, the type is registered by itself. + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + The base type or interface to register. + The actual type that will be returned when requested. + Thrown when or + are null references (Nothing in VB). + Thrown when is + no sub type from (or the same type), or one of them represents an + open generic type. + + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + + Registers the specified delegate that allows returning instances of . + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + The base type or interface to register. + The delegate that will be used for creating new instances. + Thrown when either or + are null references (Nothing in VB). + Thrown when represents an + open generic type. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + + Registers a single concrete instance that will be constructed using constructor injection and will + be returned when this instance is requested by type . + This must be thread-safe when working in a multi-threaded + environment. + + The concrete type that will be registered. + + Thrown when this container instance is locked and can not be altered, or when + has already been registered. + + Thrown when the is a type + that can not be created by the container. + + + + Registers that the same a single instance of type will be + returned every time an type is requested. If + and represent the same + type, the type is registered by itself. must be thread-safe + when working in a multi-threaded environment. + + + The interface or base type that can be used to retrieve the instances. + + The concrete type that will be registered. + + Thrown when this container instance is locked and can not be altered, or when the + has already been registered. + Thrown when the given + type is not a type that can be created by the container. + + + + + Registers a single instance that will be returned when an instance of type + is requested. This must be thread-safe + when working in a multi-threaded environment. + + The interface or base type that can be used to retrieve the instance. + The instance to register. + + Thrown when this container instance is locked and can not be altered, or when the + has already been registered. + + Thrown when is a null reference. + + + + + Registers the specified delegate that allows constructing a single instance of + . This delegate will be called at most once during the lifetime of + the application. The returned instance must be thread-safe when working in a multi-threaded + environment. + + The interface or base type that can be used to retrieve instances. + The delegate that allows building or creating this single + instance. + + Thrown when this container instance is locked and can not be altered, or when a + for has already been registered. + + Thrown when is a + null reference. + + + + Registers that the same instance of type will be returned every + time an instance of type type is requested. If + and represent the same type, the + type is registered by itself. must be thread-safe when working + in a multi-threaded environment. + + The base type or interface to register. + The actual type that will be returned when requested. + Thrown when either or + are null references (Nothing in VB). + Thrown when is + no sub type from , or when one of them represents an open generic + type. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + + Registers the specified delegate that allows constructing a single + instance. The container will call this delegate at most once during the lifetime of the application. + + The base type or interface to register. + The delegate that will be used for creating that single instance. + Thrown when represents an open + generic type. + Thrown when either or + are null references (Nothing in + VB). + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + + Registers a single instance that will be returned when an instance of type + is requested. This must be thread-safe + when working in a multi-threaded environment. + + The base type or interface to register. + The instance to register. + Thrown when either or + are null references (Nothing in VB). + Thrown when is + no sub type from . + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + + Registers that an instance of will be returned when an + instance of type is requested. The instance is cached according to + the supplied . + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + The lifestyle that specifies how the returned instance will be cached. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + Thrown when the given + type is not a type that can be created by the container. + + + + + Registers the specified delegate that will produce instances of + type and will be returned when an instance of type + is requested. The delegate is expected to produce new instances on + each call. The instances are cached according to the supplied . + + The interface or base type that can be used to retrieve instances. + The delegate that allows building or creating new instances. + The lifestyle that specifies how the returned instance will be cached. + + Thrown when this container instance is locked and can not be altered, or when the + has already been registered. + + Thrown when one of the supplied arguments is a null reference (Nothing in VB). + + + + Registers that an instance of type will be returned when an + instance of type is requested. The instance is cached according to + the supplied . + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + The lifestyle that specifies how the returned instance will be cached. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + Thrown when this container instance is locked and can not be altered, or when the + has already been registered. + Thrown when the given + type is not a type that can be created by the container, when either + or are open generic types, or when + is not assignable from the . + + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + + + Registers the specified delegate that will produce instances of + type and will be returned when an instance of type + is requested. The delegate is expected to produce new instances on + each call. The instances are cached according to the supplied . + + The interface or base type that can be used to retrieve instances. + The delegate that allows building or creating new instances. + The lifestyle that specifies how the returned instance will be cached. + + Thrown when this container instance is locked and can not be altered, or when the + has already been registered. + + Thrown when one of the supplied arguments is a null reference (Nothing in VB). + + + + Registers an delegate that runs after the creation of instances that + implement or derive from the given . Please note that only instances + that are created by the container (using constructor injection) can be initialized this way. + + The type for which the initializer will be registered. + The delegate that will be called after the instance has been + constructed and before it is returned. + + Thrown when the is a null reference. + + + Thrown when this container instance is locked and can not be altered. + + + Multiple delegates can be registered per + and multiple initializers can be applied on a created instance, + before it is returned. For instance, when registering a + for type , the delegate will be called for every instance created by + the container, which can be nice for debugging purposes. + + + Note: Initializers are guaranteed to be executed in the order they are registered. + + + The following example shows the usage of the + RegisterInitializer method: + + (); + + // Configuring property injection for types that implement ICommand: + container.RegisterInitializer(command => + { + command.SendAsync = true; + }); + + // Configuring property injection for types that implement CommandBase: + container.RegisterInitializer(command => + { + command.Clock = container.GetInstance(); + }); + + // Act + var command = (ConcreteCommand)container.GetInstance(); + + // Assert + // Because ConcreteCommand implements both ICommand and CommandBase, + // both the initializers will have been executed. + Assert.IsTrue(command.SendAsync); + Assert.IsNotNull(command.Clock); + } + ]]> + + The container does not use the type information of the requested service type, but it uses the + type information of the actual implementation to find all initialized that apply for that + type. This makes it possible to have multiple initializers to be applied on a single returned + instance while keeping performance high. + + + Registered initializers will only be applied to instances that are created by the container self + (using constructor injection). Types that are newed up manually by supplying a + delegate to the container (using the + and + methods) or registered as single instance + (using ) will not trigger initialization. + When initialization of these instances is needed, this must be done manually, as can be seen in + the following example: + commandInitializer = command => + { + initializerCallCount++; + }); + + // Configuring that initializer. + container.RegisterInitializer(commandInitializer); + + container.Register(() => + { + // Create a ConcreteCommand manually: will not be initialized. + var command = new ConcreteCommand("Data Source=.;Initial Catalog=db;"); + + // Run the initializer manually. + commandInitializer(command); + + return command; + }); + + // Act + var command = container.GetInstance(); + + // Assert + // The initializer will only be called once. + Assert.AreEqual(1, initializerCallCount); + } + ]]> + The previous example shows how a manually created instance can still be initialized. Try to + prevent creating types manually, by changing the design of those classes. If possible, create a + single public constructor that only contains dependencies that can be resolved. + + + + + + Registers an delegate that runs after the + creation of instances for which the supplied returns true. Please + note that only instances that are created by the container can be initialized this way. + + The delegate that will be called after the instance has been + constructed and before it is returned. + The predicate that will be used to check whether the given delegate must + be applied to a registration or not. The given predicate will be called once for each registration + in the container. + + Thrown when either the or are + null references. + + + Thrown when this container instance is locked and can not be altered. + + + Note: Initializers are guaranteed to be executed in the order they are registered. + + + Note: The is not guaranteed to be called once per registration; + when a registration's instance is requested for the first time simultaneously over multiple thread, + the predicate might be called multiple times. The caller of this method is responsible of supplying + a predicate that is thread-safe. + + + + + + Registers a dynamic (container uncontrolled) collection of elements of type + . A call to will return the + itself, and updates to the collection will be reflected in the + result. If updates are allowed, make sure the collection can be iterated safely if you're running + a multi-threaded application. + + The interface or base type that can be used to retrieve instances. + The collection to register. + + Thrown when this container instance is locked and can not be altered, or when a + for has already been registered. + + Thrown when is a null + reference. + + + + Registers a collection of singleton elements of type . + + The interface or base type that can be used to retrieve instances. + The collection to register. + + Thrown when this container instance is locked and can not be altered, or when a + for has already been registered. + + Thrown when is a null + reference. + Thrown when one of the elements of + is a null reference. + + + + Registers a collection of , whose instances will be resolved lazily + each time the resolved collection of is enumerated. + The underlying collection is a stream that will return individual instances based on their + specific registered lifestyle, for each call to . + The order in which the types appear in the collection is the exact same order that the items were + registered, i.e the resolved collection is deterministic. + + The base type or interface for elements in the collection. + The collection of objects whose instances + will be requested from the container. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + Thrown when contains a null + (Nothing in VB) element, a generic type definition, or the is + not assignable from one of the given elements. + + + + + Registers a collection of , whose instances will be resolved lazily + each time the resolved collection of is enumerated. + The underlying collection is a stream that will return individual instances based on their + specific registered lifestyle, for each call to . + The order in which the types appear in the collection is the exact same order that the items were + registered, i.e the resolved collection is deterministic. + + The base type or interface for elements in the collection. + The collection of objects whose instances + will be requested from the container. + Thrown when is a null + reference (Nothing in VB). + + Thrown when contains a null + (Nothing in VB) element, a generic type definition, or the is + not assignable from one of the given elements. + + + + + Registers a collection of , whose instances will be resolved lazily + each time the resolved collection of is enumerated. + The underlying collection is a stream that will return individual instances based on their + specific registered lifestyle, for each call to . + The order in which the types appear in the collection is the exact same order that the items were + registered, i.e the resolved collection is deterministic. + + The base type or interface for elements in the collection. + The collection of objects whose instances + will be requested from the container. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + Thrown when contains a null + (Nothing in VB) element, a generic type definition, or the is + not assignable from one of the given elements. + + + + + Registers a collection of , whose instances will be resolved lazily + each time the resolved collection of is enumerated. + The underlying collection is a stream that will return individual instances based on their + specific registered lifestyle, for each call to . + The order in which the types appear in the collection is the exact same order that the items were + registered, i.e the resolved collection is deterministic. + + The base type or interface for elements in the collection. + The collection of objects whose instances + will be requested from the container. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + Thrown when contains a null + (Nothing in VB) element, the is a generic type definition, or when + is + not assignable from one of the given elements. + + + + + Registers a collection of , whose instances will be resolved lazily + each time the resolved collection of is enumerated. + The underlying collection is a stream that will return individual instances based on their + specific registered lifestyle, for each call to . + The order in which the types appear in the collection is the exact same order that the items were + registered, i.e the resolved collection is deterministic. + + The base type or interface for elements in the collection. + The collection of objects whose instances + will be requested from the container. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + Thrown when contains a null + (Nothing in VB) element, the is a generic type definition, or when + is + not assignable from one of the given elements. + + + + + Registers a dynamic (container uncontrolled) collection of elements of type + . A call to will return the + itself, and updates to the collection will be reflected in the + result. If updates are allowed, make sure the collection can be iterated safely if you're running + a multi-threaded application. + + The base type or interface for elements in the collection. + The collection of items to register. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + Thrown when represents an + open generic type. + + + + Verifies the Container. This method will call all registered delegates, + iterate registered collections and throws an exception if there was an error. + + Thrown when the registration of instances was + invalid. + + + + Adds the for the supplied . This + method can be used to apply the same to multiple different service + types. + + The base type or interface to register. + The registration that should be stored for the given + . + + (container); + + container.AddRegistration(typeof(IFoo), registration); + container.AddRegistration(typeof(IBar), registration); + + // Act + IFoo foo = container.GetInstance(); + IBar bar = container.GetInstance(); + + // Assert + bool fooAndBareAreTheSameInstance = object.ReferenceEquals(foo, bar); + Assert.IsTrue(fooAndBareAreTheSameInstance); + } + ]]> + + In the example above a singleton registration is created for type FooBar and this + registration is added to the container for each interface (IFoo and IBar) that it + implements. Since both services use the same singleton registration, requesting those services + will result in the return of the same (singleton) instance. + + + events are applied to the of the + instance and are therefore applied once. + events on the other hand get applied to the Expression of the . + Since each AddRegistration gets its own instance producer (that wraps the + Registration instance), this means that the ExpressionBuilt events will be + applied for each registered service type. + + + The most practical example of this is the use of decorators using one of the + RegisterDecorator overloads + (decorator registration use the + ExpressionBuilt event under the covers). Take a look at the following example: + + (container); + + container.AddRegistration(typeof(IFoo), registration); + container.AddRegistration(typeof(IBar), registration); + + // Registere a decorator for IBar, but not for IFoo + container.RegisterDecorator(typeof(IBar), typeof(BarDecorator)); + + // Act + var foo = container.GetInstance(); + var decorator = container.GetInstance() as BarDecorator; + var bar = decorator.DecoratedBar; + + // Assert + bool fooAndBareAreTheSameInstance = object.ReferenceEquals(foo, bar); + Assert.IsTrue(fooAndBareAreTheSameInstance); + } + ]]> + The example shows that the decorator gets applied to IBar but not to IFoo, but that + the decorated IBar is still the same instance as the resolved IFoo instance. + + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + Thrown when is not a reference + type, is open generic, is ambiguous, when it is not assignable from the + 's ImplementationType + or when the supplied is created for a different + instance. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + Gets an instance of the given . + Type of object requested. + The requested service instance. + Thrown when there are errors resolving the service instance. + + + Gets an instance of the given . + Type of object requested. + The requested service instance. + Thrown when there are errors resolving the service instance. + + + + Gets all instances of the given currently registered in the container. + + Type of object requested. + A sequence of instances of the requested TService. + Thrown when there are errors resolving the service instance. + + + + Gets all instances of the given currently registered in the container. + + Type of object requested. + A sequence of instances of the requested serviceType. + Thrown when there are errors resolving the service instance. + + + Gets the service object of the specified type. + An object that specifies the type of service object to get. + A service object of type serviceType. -or- null if there is no service object of type + . + + + + Gets the for the given . When no + registration exists, the container will try creating a new producer. A producer can be created + when the type is a concrete reference type, there is an + event registered that acts on that type, or when the service type is an . + Otherwise null (Nothing in VB) is returned. + + + + A call to this method locks the container. No new registrations can't be made after a call to this + method. + + + Note: This method is not guaranteed to always return the same + instance for a given . It will however either + always return null or always return a producer that is able to return the expected instance. + + + The that the returned instance producer should produce. + An or null (Nothing in VB). + + + + Gets the for the given . When no + registration exists, the container will try creating a new producer. A producer can be created + when the type is a concrete reference type, there is an + event registered that acts on that type, or when the service type is an . + Otherwise null (Nothing in VB) is returned, or an exception is throw when + is set to true. + + + + A call to this method locks the container. No new registrations can't be made after a call to this + method. + + + Note: This method is not guaranteed to always return the same + instance for a given . It will however either + always return null or always return a producer that is able to return the expected instance. + + + The that the returned instance producer should produce. + The indication whether the method should return null or throw + an exception when the type is not registered. + An or null (Nothing in VB). + + + + Injects all public writable properties of the given that have a type + that can be resolved by this container instance. + NOTE: This method will be removed in a future release. To use property injection, + implement a custom the instead. For more information, + read the + extendibility points wiki. + + The instance whose properties will be injected. + + Thrown when the is null (Nothing in VB). + Throw when injecting properties on the given instance + failed due to security constraints of the sandbox. This can happen when injecting properties + on an internal type in a Silverlight sandbox, or when running in partial trust. + + + Initializes a new instance of the class. + + + Initializes a new instance of the class. + The container options. + Thrown when the is a null + reference. + Thrown when supplied is an instance + that already is supplied to another instance. Every container must get + its own instance. + + + + Returns an array with the current registrations. This list contains all explicitly registered + types, and all implicitly registered instances. Implicit registrations are all concrete + unregistered types that have been requested, all types that have been resolved using + unregistered type resolution (using the event), and + requested unregistered collections. Note that the result of this method may change over time, + because of these implicit registrations. + + + + This method has a performance characteristic of O(n). Prevent from calling this in a performance + critical path of the application. + + + Note: This method is not guaranteed to always return the same + instance for a given registration. It will however either + always return a producer that is able to return the expected instance. Because of this, do not + compare sets of instances returned by different calls to + by reference. The way of comparing lists is by the actual type. The type of each instance is + guaranteed to be unique in the returned list. + + + An array of instances. + + + + Returns an array with the current registrations for root objects. Root objects are registrations + that are in the root of the object graph, meaning that no other registration is depending on it. + + + + This method has a performance characteristic of O(n). Prevent from calling this in a performance + critical path of the application. + + + This list contains the root objects of all explicitly registered types, and all implicitly + registered instances. Implicit registrations are all concrete unregistered types that have been + requested, all types that have been resolved using unregistered type resolution (using the + event), and requested unregistered collections. Note that + the result of this method may change over time, because of these implicit registrations. + + + Note: This method is not guaranteed to always return the same + instance for a given registration. It will however either + always return a producer that is able to return the expected instance. Because of this, do not + compare sets of instances returned by different calls to + by reference. The way of comparing lists is by the actual type. The type of each instance is + guaranteed to be unique in the returned list. + + + An array of instances. + Thrown when this method is called before + has been successfully called. + + + Determines whether the specified System.Object is equal to the current System.Object. + + The System.Object to compare with the current System.Object. + + True if the specified System.Object is equal to the current System.Object; otherwise, false. + + + + Returns the hash code of the current instance. + The hash code of the current instance. + + + + Returns a that represents the . + + + A that represents the . + + + + Gets the of the current instance. + The instance that represents the exact runtime + type of the current instance. + + + Prevents any new registrations to be made to the container. + + + + Occurs when an instance of a type is requested that has not been registered explicitly, allowing + resolution of unregistered types before the container tries to create the type. + + + + The event is called by the container every time an + unregistered type is requested for the first time, allowing a developer to do unregistered type + resolution. By calling the + Register method on the + , a , or + delegate can be registered allowing the container to retrieve + instances of the requested type. This registration is cached and it prevents the + ResolveUnregisteredType event from being called again for the same type. + + + When no registered event handled the registration of an unregistered type, the container will try + to create the type when this type is either concrete or is the + interface. Concrete types will be registered with the Transient + lifestyle and registrations will return an empty collection. When no + even handled the registration and the container could not create it, an exception is thrown. + + + Thread-safety: Please note that the container will not ensure that the hooked delegates + are executed only once. While the calls to for a given type + are finite (and will in most cases happen just once), a container can call the delegate multiple + times and make parallel calls to the delegate. You must make sure that the code can be called + multiple times and is thread-safe. + + + + The following example shows the usage of the event: + + { + void Validate(T instance); + } + + // Implementation of the null object pattern. + public class EmptyValidator : IValidator + { + public void Validate(T instance) + { + // Does nothing. + } + } + + [TestMethod] + public void TestResolveUnregisteredType() + { + // Arrange + var container = new Container(); + + // Register an EmptyValidator to be returned when a IValidator is requested: + container.ResolveUnregisteredType += (sender, e) => + { + if (e.UnregisteredServiceType.IsGenericType && + e.UnregisteredServiceType.GetGenericTypeDefinition() == typeof(IValidator<>)) + { + var validatorType = typeof(EmptyValidator<>).MakeGenericType( + e.UnregisteredServiceType.GetGenericArguments()); + + object emptyValidator = container.GetInstance(validatorType); + + // Register the instance as singleton. + e.Register(() => emptyValidator); + } + }; + + // Act + var orderValidator = container.GetInstance>(); + var customerValidator = container.GetInstance>(); + + // Assert + Assert.IsInstanceOfType(orderValidator, typeof(EmptyValidator)); + Assert.IsInstanceOfType(customerValidator, typeof(EmptyValidator)); + } + ]]> + + The example above registers a delegate that is raised every time an unregistered type is requested + from the container. The delegate checks whether the requested type is a closed generic + implementation of the IValidator<T> interface (such as + IValidator<Order> or IValidator<Customer>). In that case it + will request the container for a concrete EmptyValidator<T> implementation that + implements the given + UnregisteredServiceType, and + registers a delegate that will return this created instance. The e.Register call + registers the method in the container, preventing the from + being called again for the exact same service type, preventing any performance penalties. + + + Please note that given example is just an uhhmm... example. In the case of the example the + EmptyValidator<T> can be better registered using of the built-in + RegisterOpenGeneric + extension methods instead. These extension methods take care of any given generic type constraint + and allow the implementation to be integrated into the container's pipeline, which allows + it to be intercepted using the event and allow any registered + initializers to be applied. + + + + + + Occurs after the creation of the of a registered type is complete (the + lifestyle has been applied), allowing the created to be wrapped, + changed, or replaced. Multiple delegates may handle the same service type. + + + + The ExpressionBuilt event is called by the container every time an registered type is + getting compiled, allowing a developer to change the way the type is created. The delegate that + hooks to the ExpressionBuilt event, can change the + property on the + , which allows changing the way the type is constructed. + + + Thread-safety: Please note that the container will not ensure that the hooked delegates + are executed only once per service type. While the calls to for a + given type are finite (and will in most cases happen just once), a container can call the delegate + multiple times and make parallel calls to the delegate. You must make sure that the code can be + called multiple times and is thread-safe. + + + + The following example shows the usage of the ExpressionBuilt event: + + { + void Validate(T instance); + } + + public interface ILogger + { + void Write(string message); + } + + // Implementation of the decorator pattern. + public class MonitoringValidator : IValidator + { + private readonly IValidator validator; + private readonly ILogger logger; + + public MonitoringValidator(IValidator validator, ILogger logger) + { + this.validator = validator; + this.logger = logger; + } + + public void Validate(T instance) + { + this.logger.Write("Validating " + typeof(T).Name); + this.validator.Validate(instance); + this.logger.Write("Validated " + typeof(T).Name); + } + } + + [TestMethod] + public void TestExpressionBuilt() + { + // Arrange + var container = new Container(); + + container.RegisterSingle(); + container.Register, OrderValidator>(); + container.Register, CustomerValidator>(); + + // Intercept the creation of IValidator instances and wrap them in a MonitoringValidator: + container.ExpressionBuilt += (sender, e) => + { + if (e.RegisteredServiceType.IsGenericType && + e.RegisteredServiceType.GetGenericTypeDefinition() == typeof(IValidator<>)) + { + var decoratorType = typeof(MonitoringValidator<>) + .MakeGenericType(e.RegisteredServiceType.GetGenericArguments()); + + // Wrap the IValidator in a MonitoringValidator. + e.Expression = Expression.New(decoratorType.GetConstructors()[0], new Expression[] + { + e.Expression, + container.GetRegistration(typeof(ILogger)).BuildExpression(), + }); + } + }; + + // Act + var orderValidator = container.GetInstance>(); + var customerValidator = container.GetInstance>(); + + // Assert + Assert.IsInstanceOfType(orderValidator, typeof(MonitoringValidator)); + Assert.IsInstanceOfType(customerValidator, typeof(MonitoringValidator)); + } + ]]> + + The example above registers a delegate that is raised every time the container compiles the + expression for an registered type. The delegate checks whether the requested type is a closed generic + implementation of the IValidator<T> interface (such as + IValidator<Order> or IValidator<Customer>). In that case it + will changes the current with a new one that creates + a new MonitoringValidator<T> that takes the current validator (and an ILogger) + as an dependency. + + + Please note that given example is just an uhhmm... example. In the case of the example the + MonitoringValidator<T> is a decorator and instead of manually writing this code that + many limitations, you can use one of the built-in + RegisterDecorator extension methods instead. + These extension methods take care of any given generic type constraint, allow to register decorators + conditionally and allow the decorator to be integrated into the container's pipeline, which allows + it to be intercepted using the event and allow any registered + initializers to be applied. + + + + + + Occurs directly after the creation of the of a registered type is made, + but before any initializer and lifestyle specific caching + has been applied, allowing the created to be altered. Multiple delegates + may handle the same service type. + + + + The ExpressionBuilding event is called by the container every time an registered type is + getting compiled, allowing a developer to change the way the type is created. The delegate that + hooks to the ExpressionBuilding event, can change the + property on the + , which allows changing the way the type is constructed. + + + The exact type supplied depends on the type of registration. + Registrations that explicitly supply the implementation type (such as + Register<TService, TImplementation>()) + will result in an , while registrations that take a delegate (such as + Register<TService>(Func<TService>)) + will result in an . Singletons that are passed in using their + value (RegisterSingle<TService>(TService)) + will result in an . Note that other ExpressionBuilding + registrations might have changed the + property and might have supplied an of a different type. The order in + which these events are registered might be of importance to you. + + + Thread-safety: Please note that the container will not ensure that the hooked delegates + are executed only once per service type. While the calls to registered ExpressionBuilding + events for a given type are finite (and will in most cases happen just once), a container can + call the delegate multiple times and make parallel calls to the delegate. You must make sure that + the code can be called multiple times and is thread-safe. + + + + The following example shows the usage of the ExpressionBuilding event: + + { + var expression = e.Expression as NewExpression; + + if (expression != null) + { + var propertiesToInject = + from property in expression.Constructor.DeclaringType.GetProperties() + where property.GetCustomAttributes(typeof(MyInjectPropertyAttribute), true).Any() + let registration = container.GetRegistration(property.PropertyType, true) + select Tuple.Create(property, registration); + + if (propertiesToInject.Any()) + { + Func[], object> injectorDelegate = + (instance, dependencies) => + { + foreach (var dependency in dependencies) + { + dependency.Item1.SetValue(instance, dependency.Item2.GetInstance(), null); + } + + return instance; + }; + + e.Expression = Expression.Convert( + Expression.Invoke( + Expression.Constant(injectorDelegate), + e.Expression, + Expression.Constant(propertiesToInject.ToArray())), + expression.Constructor.DeclaringType); + } + } + }; + } + ]]> + + The example above registers a delegate that is raised every time the container compiles the + expression for an registered type. The delegate checks if the type contains properties that are + decorated with the supplied MyInjectPropertyAttribute. If decorated properties are found, + the given expression is replaced with an expression that injects decorated properties. + + + The example differs from the container's built-in method in that + it will fail when one of the decorated properties can not be injected. The built-in + will look at all properties of a given class and will simply skip + over any properties that can not be injected, making the use of the + method often verify fragile and error prone. + + + + + Gets the container options. + The instance for this container. + + + + Gets the intermediate lifestyle that forwards CreateRegistration calls to the lifestyle that is + returned from the registered container.Options.LifestyleSelectionBehavior. + + + + Implements a cache for implementations. + + is thread-safe can be used over multiple threads concurrently. + + + + + Allows registering an delegate that will be called when the scope ends, + but before the scope disposes any instances. + + + During the call to all registered delegates are + processed in the order of registration. Do note that registered actions are not guaranteed + to run. In case an exception is thrown during the call to , the + will stop running any actions that might not have been invoked at that point. + Instances that are registered for disposal using on the other + hand, are guaranteed to be disposed. Note that registered actions won't be invoked during a call + to . + + The delegate to run when the scope ends. + Thrown when one of the arguments is a null reference + (Nothing in VB). + Thrown when the scope has been disposed. + + + + Adds the to the list of items that will get disposed when the + scope ends. + + + Instances that are registered for disposal, will be disposed in opposite order of registration and + they are guaranteed to be disposed when is called (even when + exceptions are thrown). This mimics the behavior of the C# and VB using statements, + where the method is called inside the finally block. + + The instance that should be disposed when the scope ends. + Thrown when one of the arguments is a null reference + (Nothing in VB). + Thrown when the scope has been disposed. + + + Releases all instances that are cached by the object. + + + + Releases all instances that are cached by the object. + + False when only unmanaged resources should be released. + + + Configuration options for the . + + The following example shows the typical usage of the ContainerOptions class. + (); + + // Use of ContainerOptions class here. + container.Options.AllowOverridingRegistrations = true; + + // Replaces the previous registration of ITimeProvider + container.Register(); + ]]> + + + + Initializes a new instance of the class. + + + + Gets or sets a value indicating whether the container allows overriding registrations. The default + is false. + + The value indicating whether the container allows overriding registrations. + + + + Gets or sets the constructor resolution behavior. By default, the container only supports types + that have a single public constructor. + + The constructor resolution behavior. + Thrown when the supplied value is a null reference. + + Thrown when the container already contains registrations. + + + + + Gets or sets the constructor verification behavior. The container's default behavior is to + disallow constructors with value types and strings. + + The constructor resolution behavior. + Thrown when the supplied value is a null reference. + + Thrown when the container already contains registrations. + + + + Gets or sets the constructor injection behavior. + The constructor injection behavior. + Thrown when the supplied value is a null reference. + + Thrown when the container already contains registrations. + + + + + Gets or sets the property selection behavior. The container's default behavior is to do no + property injection. + + The property selection behavior. + Thrown when the supplied value is a null reference. + + Thrown when the container already contains registrations. + + + + + Gets or sets the lifestyle selection behavior. The container's default behavior is to make + registrations using the lifestyle. + The lifestyle selection behavior. + Thrown when the supplied value is a null reference. + + Thrown when the container already contains registrations. + + + + + Gets the container to which this ContainerOptions instance belongs to or null when + this instance hasn't been applied to a yet. + + The current . + + + + Gets or sets a value indicating whether the container will use dynamic assemblies for compilation. + By default, this value is true for the first few containers that are created in an app + domain and false for all other containers. You can set this value explicitly to false + to prevent the use of dynamic assemblies or you can set this value explicitly to true to + force more container instances to use dynamic assemblies. Note that creating an infinite number + of instances (for instance one per web request) with this property set to + true will result in a memory leak; dynamic assemblies take up memory and will only be + unloaded when the AppDomain is unloaded. + + A boolean indicating whether the container should use a dynamic assembly for compilation. + + + + + Allows verifying whether a given type has a direct or indirect dependency on itself. Verifying is done + by preventing recursive calls to a IInstanceProvider. An instance of this type is related to a single + instance of a IInstanceProvider. A RecursiveDependencyValidator instance checks a single + IInstanceProvider and therefore a single service type. + + + + + Extension methods for the RecursiveDependencyValidator class. + + + + + Provides data for and interaction with the + ExpressionBuilding event of + the . An observer can change the + property to change the component that is + currently being built. + + + + Gets the registered service type that is currently requested. + The registered service type that is currently requested. + + + + Gets the type that is known to be returned by the + Expression (most often the implementation + type used in the Register call). This type will be a derivative of + RegisteredServiceType (or + or RegisteredServiceType itself). If the Expression is changed, the new expression + must also return an instance of type KnownImplementationType or a sub type. + This information must be described in the new Expression. + + A . + + + + Gets the lifestyle for the component that is currently being built. + + The . + + + Gets or sets the currently registered . + The current registration. + Thrown when the supplied value is a null reference. + + + + Gets the collection of currently known relationships. This information is used by the Diagnostics + Debug View. Change the contents of this collection to represent the changes made to the + Expression property (if any). This allows + the Diagnostics Debug View to analyze those new relationships as well. + + The collection of instances. + + + + Provides data for and interaction with the + ExpressionBuilt event of + the . An observer can change the + property to change the component that is currently + being built. + + + + Initializes a new instance of the class. + Type of the registered service. + The registered expression. + + + Gets the registered service type that is currently requested. + The registered service type that is currently requested. + + + Gets or sets the currently registered . + The current registration. + Thrown when the supplied value is a null reference. + + + Gets or sets the current lifestyle of the registration. + The original lifestyle of the registration. + + + + Gets the collection of currently known relationships. This information is used by the Diagnostics + Debug View. Change the contents of this collection to represent the changes made to the + Expression property (if any). This allows + the Diagnostics Debug View to analyze those new relationships as well. + + The collection of instances. + + + + A map containing a generic argument (such as T) and the concrete type (such as Int32) that it + represents. + + + + Implements equality. Needed for doing LINQ distinct operations. + The other to compare to. + True or false. + + + Overrides the default hash code. Needed for doing LINQ distinct operations. + An 32 bit integer. + + + + An instance of this type can be injected into constructors of decorator classes that are registered + using RegisterDecorator. This type contains + contextual information about the applied decoration and it allows users to examine the given instance + to make runtime decisions. + + + + + Gets the closed generic service type for which the decorator is about to be applied. The original + service type will be returned, even if other decorators have already been applied to this type. + + The closed generic service type. + + + + Gets the type of the implementation that is created by the container and for which the decorator + is about to be applied. The original implementation type will be returned, even if other decorators + have already been applied to this type. Please not that the implementation type can not always be + determined. In that case the closed generic service type will be returned. + + The implementation type. + + + + Gets the list of the types of decorators that have already been applied to this instance. + + The applied decorators. + + + + Gets the current object that describes the intention to create a new + instance with its currently applied decorators. + + The current expression that is about to be decorated. + + + + Extension methods for applying decorators. + + + + + Ensures that the supplied decorator is returned and cached with + the given , wrapping the original registered + , by injecting that service type into the constructor of the + supplied . Multiple decorators may be applied to the same + . Decorators can be applied to both open, closed, and non-generic + service types. + + + + The RegisterOpenGenericDecorator method works by hooking onto the container's + ExpressionBuilt event. This event fires after the + ResolveUnregisteredType event, which allows + decoration of types that are resolved using unregistered type resolution. The + RegisterOpenGeneric + extension method, for instance, hooks onto the ResolveUnregisteredType. This allows you to + use RegisterOpenGenericDecorator on the same service type as RegisterOpenGeneric. + + + Multiple decorators can be applied to the same service type. The order in which they are registered + is the order they get applied in. This means that the decorator that gets registered first, gets + applied first, which means that the next registered decorator, will wrap the first decorator, which + wraps the original service type. + + + Constructor injection will be used on that type, and although it may have many constructor + arguments, it must have exactly one argument of the type of , or an + argument of type where TResult is . + An exception will be thrown when this is not the case. + + + The registered may have a constructor with an argument of type + where T is . In this case, the + will not inject the decorated itself into the + instance, but it will inject a that allows + creating instances of the decorated type, according to the lifestyle of that type. This enables + more advanced scenarios, such as executing the decorated types on a different thread, or executing + decorated instance within a certain scope (such as a lifetime scope). + + + + Please see the RegisterDecorator method + for more information. + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the given . + The definition of the open generic decorator type that will + be used to wrap the original service type. + The lifestyle that specifies how the returned decorator will be cached. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type, when does not inherit from or + implement , when + does not have a single public constructor, or when does + not contain a constructor that has exactly one argument of type + or where T is + . + + + + Ensures that the supplied decorator is returned when the supplied + returns true and cached with the given + , wrapping the original registered , by + injecting that service type into the constructor of the supplied . + Multiple decorators may be applied to the same . Decorators can be + applied to both open, closed, and non-generic service types. + + + + The RegisterOpenGenericDecorator method works by hooking onto the container's + ExpressionBuilt event. This event fires after the + ResolveUnregisteredType event, which allows + decoration of types that are resolved using unregistered type resolution. The + RegisterOpenGeneric + extension method, for instance, hooks onto the ResolveUnregisteredType. This allows you to + use RegisterOpenGenericDecorator on the same service type as RegisterOpenGeneric. + + + Multiple decorators can be applied to the same service type. The order in which they are registered + is the order they get applied in. This means that the decorator that gets registered first, gets + applied first, which means that the next registered decorator, will wrap the first decorator, which + wraps the original service type. + + + Constructor injection will be used on that type, and although it may have many constructor + arguments, it must have exactly one argument of the type of , or an + argument of type where TResult is . + An exception will be thrown when this is not the case. + + + The registered may have a constructor with an argument of type + where T is . In this case, the + will not inject the decorated itself into the + instance, but it will inject a that allows + creating instances of the decorated type, according to the lifestyle of that type. This enables + more advanced scenarios, such as executing the decorated types on a different thread, or executing + decorated instance within a certain scope (such as a lifetime scope). + + + + Please see the RegisterDecorator method + for more information. + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the given . + The definition of the open generic decorator type that will + be used to wrap the original service type. + The lifestyle that specifies how the returned decorator will be cached. + The predicate that determines whether the + must be applied to a service type. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type, when does not inherit from or + implement , when + does not have a single public constructor, or when does + not contain a constructor that has exactly one argument of type + or where T is + . + + + + Ensures that the decorator type that is returned from is + supplied when the supplied returns true and cached with the given + , wrapping the original registered , by + injecting that service type into the constructor of the decorator type that is returned by the + supplied . + Multiple decorators may be applied to the same . Decorators can be + applied to both open, closed, and non-generic service types. + + + + The types returned from the may be open-generic. The + container will try to fill in the generic parameters based on the resolved service type. + + + The RegisterOpenGenericDecorator method works by hooking onto the container's + ExpressionBuilt event. This event fires after the + ResolveUnregisteredType event, which allows + decoration of types that are resolved using unregistered type resolution. The + RegisterOpenGeneric + extension method, for instance, hooks onto the ResolveUnregisteredType. This allows you to + use RegisterOpenGenericDecorator on the same service type as RegisterOpenGeneric. + + + Multiple decorators can be applied to the same service type. The order in which they are registered + is the order they get applied in. This means that the decorator that gets registered first, gets + applied first, which means that the next registered decorator, will wrap the first decorator, which + wraps the original service type. + + + Constructor injection will be used on that type, and although it may have many constructor + arguments, it must have exactly one argument of the type of , or an + argument of type where TResult is . + An exception will be thrown when this is not the case. + + + The type returned from may have a constructor with an + argument of type where T is . In this + case, the framework will not inject the decorated itself into the + decorator instance, but it will inject a that allows + creating instances of the decorated type, according to the lifestyle of that type. This enables + more advanced scenarios, such as executing the decorated types on a different thread, or executing + decorated instance within a certain scope (such as a lifetime scope). + + + + The following is an example of the registration of a decorator through the factory delegate: + , MoveCustomerCommandHandler>(); + + container.RegisterDecorator( + typeof(ICommandHandler<>), + context => typeof(LoggingCommandHandler<,>).MakeGenericType( + typeof(LoggingCommandHandler<,>).GetGenericArguments().First(), + context.ImplementationType), + Lifestyle.Transient, + context => true); + + var handler = container.GetInstance>(); + + Assert.IsInstanceOfType(handler, + typeof(LoggingCommandHandler)); + + ]]> + The code above allows a generic LoggingCommandHandler<TCommand, TImplementation> to + be applied to command handlers, where the second generic argument will be filled in using the + contextual information. + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the decorator type returned by the supplied . + A factory that allows building Type objects that define the + decorators to inject, based on the given contextual information. The delegate is allowed to return + open-generic types. + The lifestyle that specifies how the returned decorator will be cached. + The predicate that determines whether the decorator must be applied to a + service type. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type. + + + + Ensures that the supplied decorator is returned, wrapping the + original registered , by injecting that service type into the + constructor of the supplied . Multiple decorators may be applied + to the same . Decorators can be applied to both open, closed, and + non-generic service types. By default, a new instance will be + returned on each request (according the Transient lifestyle), + independently of the lifestyle of the wrapped service. + + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + + The RegisterDecorator method works by hooking onto the container's + ExpressionBuilt event. This event fires after the + ResolveUnregisteredType event, which allows + decoration of types that are resolved using unregistered type resolution. The + RegisterOpenGeneric + extension method, for instance, hooks onto the ResolveUnregisteredType. This allows you to + use RegisterDecorator on the same generic service type as RegisterOpenGeneric. + + + Multiple decorators can be applied to the same service type. The order in which they are registered + is the order they get applied in. This means that the decorator that gets registered first, gets + applied first, which means that the next registered decorator, will wrap the first decorator, which + wraps the original service type. + + + Constructor injection will be used on that type, and although it may have many constructor + arguments, it must have exactly one argument of the type of , or an + argument of type where TResult is . + An exception will be thrown when this is not the case. + + + The registered may have a constructor with an argument of type + where T is . In this case, an decorated + instance will not injected into the , but it will inject a + that allows creating instances of the decorated type, according to the + lifestyle of that type. This enables more advanced scenarios, such as executing the decorated + types on a different thread, or executing decorated instance within a certain scope (such as a + lifetime scope). + + + + The following example shows the definition of a generic ICommandHandler<T> interface, + a CustomerMovedCommandHandler implementing that interface, and a + ValidatorCommandHandlerDecorator<T> that acts as a decorator for that interface. + + { + void Handle(TCommand command); + } + + public class CustomerMovedCommand + { + [Required] + public int CustomerId { get; set; } + + [Required] + public Address Address { get; set; } + } + + public class CustomerMovedCommandHandler + : ICommandHandler + { + public void Handle(CustomerMovedCommand command) + { + // some logic + } + } + + // Decorator that validates commands before they get executed. + public class ValidatorCommandHandlerDecorator + : ICommandHandler + { + private readonly ICommandHandler decoratedHandler; + private readonly Container container; + + public ValidatorCommandHandlerDecorator( + ICommandHandler decoratedHandler, + Container container) + { + this.decoratedHandler = decoratedHandler; + this.container = container; + } + + public void Handle(TCommand command) + { + this.Validate(command); + + this.decoratedHandler.Handle(command); + } + + private void Validate(TCommand command) + { + var validationContext = + new ValidationContext(command, this.container, null); + + Validator.ValidateObject(command, validationContext); + } + } + + // Decorator that measures the time it takes to execute a command. + public class MonitoringCommandHandlerDecorator + : ICommandHandler + { + private readonly ICommandHandler decoratedHandler; + private readonly ILogger logger; + + public MonitoringCommandHandlerDecorator( + ICommandHandler decoratedHandler, + ILogger logger) + { + this.decoratedHandler = decoratedHandler; + this.logger = logger; + } + + public void Handle(TCommand command) + { + var watch = Stopwatch.StartNew(); + + this.decoratedHandler.Handle(command); + + this.logger.Log(string.Format("{0} executed in {1} ms.", + command.GetType().Name, watch.ElapsedMilliseconds)); + } + } + + [TestMethod] + public static void TestRegisterOpenGenericDecorator() + { + // Arrange + var container = new Container(); + + container.RegisterSingle(); + + // Search the given assembly and register all concrete types that + // implement ICommandHandler. + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), + typeof(ICommandHandler<>).Assembly); + + // Wrap all ICommandHandler service types with a decorator + // that measures and logs the duration of that handler. + container.RegisterDecorator(typeof(ICommandHandler<>), + typeof(MonitoringCommandHandlerDecorator<>)); + + // Wrap all ICommandHandler types (in this case it will + // wrap the monitoring decorator), but only if the TCommand contains + // any properties. + container.RegisterDecorator(typeof(ICommandHandler<>), + typeof(ValidatorCommandHandlerDecorator<>), context => + { + var commandType = context.ServiceType.GetGenericArguments()[0]; + bool mustDecorate = commandType.GetProperties().Any(); + return mustDecorate; + }); + + // Act + var handler = + container.GetInstance>(); + + // Assert + Assert.IsInstanceOfType(handler, + typeof(ValidatorCommandHandlerDecorator)); + } + ]]> + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the given . + The definition of the open generic decorator type that will + be used to wrap the original service type. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type, when does not inherit from or implement + , when does not + have a single public constructor, or when does not + contain a constructor that has exactly one argument of type + or where T is + . + + + + Ensures that the supplied decorator is returned when the supplied + returns true, wrapping the original registered + , by injecting that service type into the constructor of the + supplied . Multiple decorators may be applied to the same + . Decorators can be applied to both open, closed, and non-generic + service types. By default, a new instance will be returned on + each request (according the Transient lifestyle), + independently of the lifestyle of the wrapped service. + + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + + The RegisterOpenGenericDecorator method works by hooking onto the container's + ExpressionBuilt event. This event fires after the + ResolveUnregisteredType event, which allows + decoration of types that are resolved using unregistered type resolution. The + RegisterOpenGeneric + extension method, for instance, hooks onto the ResolveUnregisteredType. This allows you to + use RegisterOpenGenericDecorator on the same service type as RegisterOpenGeneric. + + + Multiple decorators can be applied to the same service type. The order in which they are registered + is the order they get applied in. This means that the decorator that gets registered first, gets + applied first, which means that the next registered decorator, will wrap the first decorator, which + wraps the original service type. + + + Constructor injection will be used on that type, and although it may have many constructor + arguments, it must have exactly one argument of the type of , or an + argument of type where TResult is . + An exception will be thrown when this is not the case. + + + The registered may have a constructor with an argument of type + where T is . In this case, the + will not inject the decorated itself into the + instance, but it will inject a that allows + creating instances of the decorated type, according to the lifestyle of that type. This enables + more advanced scenarios, such as executing the decorated types on a different thread, or executing + decorated instance within a certain scope (such as a lifetime scope). + + + + Please see the RegisterDecorator method + for more information. + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the given . + The definition of the open generic decorator type that will + be used to wrap the original service type. + The predicate that determines whether the + must be applied to a service type. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type, when does not inherit from or + implement , when + does not have a single public constructor, or when does + not contain a constructor that has exactly one argument of type + or where T is + . + + + + Ensures that a single instance of the supplied decorator is + returned, wrapping the original registered , by injecting that + service type into the constructor of the supplied . Multiple + decorators may be applied to the same . Decorators can be applied + to both open, closed, and non-generic service types. + + + + This method ensures that a single instance of the supplied is + returned, no matter what the lifestyle of the wrapped service type is. Use with care, because the + wrapped service type will also become a singleton. This method is especially useful when use for + injecting factory methods, which will allow the wrapped service type to get + it's own lifestyle back. + + + + Please see the RegisterDecorator method + for more information. + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the given . + The definition of the open generic decorator type that will + be used to wrap the original service type. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type, when does not inherit from or implement + , when does not + have a single public constructor, or when does not + contain a constructor that has exactly one argument of type + or where T is + . + + + + Ensures that the supplied decorator is returned when the supplied + returns true, wrapping the original registered + , by injecting that service type into the constructor of the + supplied . Multiple decorators may be applied to the same + . Decorators can be applied to both open, closed, and non-generic + service types. + + + + This method ensures that a single instance of the supplied is + returned, no matter what the lifestyle of the wrapped service type is. Use with care, because the + wrapped service type will also become a singleton. This method is especially useful when use for + injecting factory methods, which will allow the wrapped service type to get + it's own lifestyle back. + + + + Please see the RegisterDecorator method + for more information. + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the given . + The definition of the open generic decorator type that will + be used to wrap the original service type. + The predicate that determines whether the + must be applied to a service type. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type, when does not inherit from or + implement , when + does not have a single public constructor, or when does + not contain a constructor that has exactly one argument of type + or where T is + . + + + + An instance of this type will be supplied to the + delegate that is that is supplied to the + RegisterDecorator + overload that takes this delegate. This type contains information about the decoration that is about + to be applied and it allows users to examine the given instance to see whether the decorator should + be applied or not. + + + Please see the + RegisterDecorator + method for more information. + + + + + Gets the closed generic service type for which the decorator is about to be applied. The original + service type will be returned, even if other decorators have already been applied to this type. + + The closed generic service type. + + + + Gets the type of the implementation that is created by the container and for which the decorator + is about to be applied. The original implementation type will be returned, even if other decorators + have already been applied to this type. Please not that the implementation type can not always be + determined. In that case the closed generic service type will be returned. + + The implementation type. + + + + Gets the list of the types of decorators that have already been applied to this instance. + + The applied decorators. + + + + Gets the current object that describes the intention to create a new + instance with its currently applied decorators. + + The current expression that is about to be decorated. + + + + Hooks into the building process and adds a decorator if needed. + + + + This interface is not meant for public use. + + + Please do not use. + Do not use. + + + PLease do not use. + Do not use. + + + + A Registration implements lifestyle based caching for a single service and allows building an + that describes the creation of the service. + + + implementations create a new Registration instance for each registered + service type. s returned from the + BuildExpression method can be intercepted by any event + registered with , have + initializers + applied, and the caching particular to its lifestyle have been applied. Interception using the + Container.ExpressionBuilt will not + be applied in the Registration, but will be applied in . + + See the documentation for an example. + + + + + Initializes a new instance of the class. + + The this that created this registration. + The instance for this registration. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + + + Builds a new with the correct caching (according to the specifications of + its ) applied. + + An . + + + + Gets the list of instances. Note that the list is only available + after calling . + + A new array containing the instances. + + + + Initializes an already created instance and applies properties and initializers to that instance. + + + This method is especially useful in integration scenarios where the given platform is in control + of creating certain types. By passing the instance created by the platform to this method, the + container is still able to apply any properties (as defined using a custom + ) and by applying any initializers. + + The instance to initialize. + Thrown when is a null reference + (Nothing in VB). + Thrown when the supplied is not + of type . + + + + Builds a delegate for the creation of the + using the supplied . The returned might + be intercepted by a + Container.ExpressionBuilding event, + and the will have been wrapped with a delegate that executes the + registered initializers + that are applicable to the given (if any). + + The interface or base type that can be used to retrieve instances. + + The delegate supplied by the user that allows building or creating new instances. + A delegate. + + + + Builds a delegate for the creation of . + The returned might be intercepted by a + Container.ExpressionBuilding event, + and the creation of the will have been wrapped with a + delegate that executes the registered + initializers + that are applicable to the given (if any). + + The interface or base type that can be used to retrieve instances. + The concrete type that will be registered. + A delegate. + + + + Builds an that describes the creation of the + using the supplied . The returned might + be intercepted by a + Container.ExpressionBuilding event, + and the will have been wrapped with a delegate that executes the + registered initializers that are + applicable to the given (if any). + + The interface or base type that can be used to retrieve instances. + + The delegate supplied by the user that allows building or creating new instances. + An . + + + + Builds an that describes the creation of + . The returned might be intercepted + by a Container.ExpressionBuilding + event, and the creation of the will have been wrapped with + a delegate that executes the registered + initializers + that are applicable to the given (if any). + + The interface or base type that can be used to retrieve instances. + The concrete type that will be registered. + An . + + + Gets the type that this instance will create. + The type that this instance will create. + + + Gets the this that created this registration. + The this that created this registration. + + + Gets the instance for this registration. + The instance for this registration. + + + + Allows retrieving the concrete types of the generic type arguments of that must be used to create a + closed generic implementation of a given open generic implementation, based on on the concrete + arguments of the given closed base type. + + + + + Helper class for building closed generic type for a given open generic type and a closed generic base. + + + + Result of the GenericTypeBuilder. + + + + A open generic type with the concrete arguments that can be used to create a closed generic type. + + + + + Helper methods for the extensions. + + + + + Represents the method that will called to register one or multiple concrete non-generic + of the given closed generic type + . + + The service type that needs to be registered. + One or more concrete types that implement the given + . + + + { + foreach (Type implementation in implementations) + { + container.RegisterSingle(implementation); + } + + container.RegisterAll(closedServiceType, implementations); + }; + + container.RegisterManyForOpenGeneric( + typeof(ICommandHandler<>), + registerAsCollectionAsSingletons, + typeof(ICommandHandler<>).Assembly); + ]]> + The BatchRegistrationCallback can be supplied to some overloads of the + RegisterManyForOpenGeneric extension methods. + The default behavior of the RegisterManyForOpenGeneric methods is to register a closed generic + type with the corresponding implementation (and will throw when multiple implementations are found for + a single closed generic service type). The given example overrides this default registration by + registering the found list of implementations (one or more) as collection of singletons for the given + closed generic service type. + + + + Defines the accessibility of the types to search. + This type is not available in Silverlight. + + + Load both public as internal types from the given assemblies. + + + Only load publicly exposed types from the given assemblies. + + + + Provides a set of static (Shared in Visual Basic) methods for registration many concrete types at + once that implement the same open generic service types in the . + + + + + Registers all concrete, non-generic, public and internal types in the given set of + that implement the given + with a transient lifetime. + + The container to make the registrations in. + The definition of the open generic type. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Registers all concrete, non-generic, public and internal types that are located in the given + that implement the given + with a transient lifetime. + + The container to make the registrations in. + The definition of the open generic type. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Registers all concrete, non-generic, public and internal types in the given set of + that implement the given + with the supplied . When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will point at the same registration and return the same instance based on the caching + behavior of the supplied . + + The container to make the registrations in. + The definition of the open generic type. + The lifestyle that will be used for the registration of the types. + A list of assemblies that will be searched. + Thrown when , + , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Registers all concrete, non-generic, public and internal types that are located in the given + that implement the given + with the supplied . When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will point at the same registration and return the same instance based on the caching + behavior of the supplied . + + The container to make the registrations in. + The definition of the open generic type. + The lifestyle that will be used for the registration of the types. + A list of assemblies that will be searched. + Thrown when , + , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Allows registration of all concrete, public and internal, non-generic types that are located in the given set of + that implement the given , + by supplying a delegate, that will be called for each + found closed generic implementation of the given . + + The container to make the registrations in. + The definition of the open generic type. + The delegate that will be called for each found closed generic version of + the given open generic to do the actual registration. + A list of assemblies that will be searched. + Thrown when , + , , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type. + + + + Allows registration of all concrete, public and internal, non-generic types that are located in the given set of + that implement the given , + by supplying a delegate, that will be called for each + found closed generic implementation of the given . + + The container to make the registrations in. + The definition of the open generic type. + The delegate that will be called for each found closed generic version of + the given open generic to do the actual registration. + A list of assemblies that will be searched. + Thrown when , + , , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type. + + + + Registers all concrete, non-generic, public and internal types that are located in the given + that implement the given + with a singleton lifetime. + + The container to make the registrations in. + The definition of the open generic type. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Registers all concrete, non-generic, public and internal types that are located in the given + that implement the given + with a singleton lifetime. + + The container to make the registrations in. + The definition of the open generic type. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Registers all supplied by a closed generic definition of the + given with a transient lifetime. + + The container to make the registrations in. + The definition of the open generic type. + The list of types that must be registered according to the given + definition. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + Thrown when there are multiple types in the given + collection that implement the same closed version of the + supplied . + + + + + Registers all supplied by a closed generic definition of the + given with a transient lifetime. + + The container to make the registrations in. + The definition of the open generic type. + The list of types that must be registered according to the given + definition. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + Thrown when there are multiple types in the given + collection that implement the same closed version of the + supplied . + + + + + Allows registration of all supplied by a closed generic + definition of the given , by supplying a + delegate, that will be called for each found closed generic + implementation. + If the list contains open generic types, matching closed generic versions of each open generic + type will be added to the list of implementations that is passed on to the + delegate. + + The container to make the registrations in. + The definition of the open generic type. + The delegate that will be called for each found closed generic version of + the given open generic to do the actual registration. + The list of types that must be registered according to the given + definition. + Thrown when , + , , or + contain a null reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + + + + Registers all supplied by a closed generic definition of the + given with a singleton lifetime. + When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will return the exact same instance. + + The container to make the registrations in. + The definition of the open generic type. + The list of types that must be registered according to the given + definition. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + Thrown when there are multiple types in the given + collection that implement the same closed version of the + supplied . + + + + + Registers all supplied by a closed generic definition of the + given with the supplied . + When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will return the exact same instance. + + The container to make the registrations in. + The definition of the open generic type. + The lifestyle the registrations are made in. + The list of types that must be registered according to the given + definition. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + Thrown when there are multiple types in the given + collection that implement the same closed version of the + supplied . + + + + + Registers all supplied by a closed generic definition of the + given with a singleton lifetime. + When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will return the exact same instance. + + The container to make the registrations in. + The definition of the open generic type. + The list of types that must be registered according to the given + definition. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + Thrown when there are multiple types in the given + collection that implement the same closed version of the + supplied . + + + + + Registers all supplied by a closed generic definition of the + given with the supplied + When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will return the exact same instance. + + The container to make the registrations in. + The definition of the open generic type. + The lifestyle the registrations are made in. + The list of types that must be registered according to the given + definition. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + Thrown when there are multiple types in the given + collection that implement the same closed version of the + supplied . + + + + + Registers all concrete, non-generic types with the given + that are located in the given that implement the given + with a transient lifetime. + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + Thrown when the given set of + contain multiple types that implement the same closed generic + version of the given . + + + + Registers all concrete, non-generic types with the given + that are located in the given that implement the given + with a transient lifetime. + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type or when the argument contains an invalid + value. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Registers all concrete, non-generic types with the given + that are located in the given that implement the given + with the supplied . + When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will point at the same registration and return the same instance based on the caching + behavior of the supplied . + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + The lifestyle that will be used for the registration of the types. + A list of assemblies that will be searched. + Thrown when , + , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + Thrown when the given set of + contain multiple types that implement the same closed generic + version of the given . + + + + Registers all concrete, non-generic types with the given + that are located in the given that implement the given + with the supplied . + When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will point at the same registration and return the same instance based on the caching + behavior of the supplied . + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + The lifestyle that will be used for the registration of the types. + A list of assemblies that will be searched. + Thrown when , + , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Allows registration of all concrete, non-generic types with the given + that are located in the given set of + that implement the given , by supplying a + delegate, that will be called for each found closed generic + implementation of the given . + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + The delegate that will be called for each found closed generic version of + the given open generic to do the actual registration. + A list of assemblies that will be searched. + Thrown when , + , , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + + + + Allows registration of all concrete, non-generic types with the given + that are located in the given set of + that implement the given , by supplying a + delegate, that will be called for each found closed generic + implementation of the given . + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + The delegate that will be called for each found closed generic version of + the given open generic to do the actual registration. + A list of assemblies that will be searched. + Thrown when , + , , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + + + + Registers all concrete, non-generic types with the given + that are located in the given that implement the given + with a singleton lifetime. + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + Thrown when the given set of + contain multiple types that implement the same closed generic + version of the given . + + + + Registers all concrete, non-generic types with the given + that are located in the given that implement the given + with a singleton lifetime. + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Returns all types that are located in the supplied + and implement or inherit from the supplied . + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), AccessibilityOption.PublicTypesOnly, + typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the + registration. + + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + A list of types. + Thrown when + contains an invalid value. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all types that are located in the supplied + and implement or inherit from the supplied . + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), AccessibilityOption.PublicTypesOnly, + typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the registration. + + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + A list of types. + Thrown when + contains an invalid value. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all types that are located in the supplied + and implement or inherit from the supplied . + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), AccessibilityOption.PublicTypesOnly, + typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the + registration. + + The container to use. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + A list of types. + Thrown when + contains an invalid value. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all types that are located in the supplied + and implement or inherit from the supplied . + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), AccessibilityOption.PublicTypesOnly, + typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the registration. + + The container to use. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + A list of types. + Thrown when + contains an invalid value. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all public and internal types that are located in the supplied + and implement or inherit from the supplied . + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the + registration. + + The definition of the open generic type. + A list of assemblies that will be searched. + A list of types. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all public and internal types that are located in the supplied + and implement or inherit from the supplied . + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the registration. + + The definition of the open generic type. + A list of assemblies that will be searched. + A list of types. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all public and internal types that are located in the supplied + and implement or inherit from the supplied . + Types that are considered to be decorators are not returned. + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the + registration. + + The container to use. + The definition of the open generic type. + A list of assemblies that will be searched. + A list of types. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all public and internal types that are located in the supplied + and implement or inherit from the supplied . + Types that are considered to be decorators are not returned. + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the registration. + + The container to use. + The definition of the open generic type. + A list of assemblies that will be searched. + A list of types. + Thrown when , or + contain a null reference (Nothing in VB). + + + + An instance of this type will be supplied to the + delegate that is that is supplied to the + RegisterOpenGeneric + overload that takes this delegate. This type contains information about the open generic service that is about + to be created and it allows the user to examine the given instance to decide whether this implementation should + be created or not. + + + Please see the + RegisterOpenGeneric + method for more information. + + + + Gets the closed generic service type that is to be created. + The closed generic service type. + + + Gets the closed generic implementation type that will be created by the container. + The implementation type. + + + Gets a value indicating whether a previous RegisterOpenGeneric registration has already + been applied for the given . + The indication whether the event has been handled. + + + + Provides a set of static (Shared in Visual Basic) methods for registration of open generic service + types in the . + + + + + Registers that a new instance of will be returned + every time a is requested. + + + Please see the + RegisterOpenGeneric(Container,Type,Type,Lifestyle) + overload for an example. + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances. + The definition of the open generic implementation type + that will be returned when a is requested. + + + + Registers that the same instance of will be returned + every time a is requested. + + + Please see the + RegisterOpenGeneric(Container,Type,Type,Lifestyle) + overload for an example. + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances.. + The definition of the open generic implementation type + that will be returned when a is requested. + + + + Registers that a closed generic instance of the supplied + will be returned when a closed generic version of + the is requested. The instance will be cached + according to the specified . + + + Types registered using the RegisterOpenGeneric are resolved using unregistered type + resolution. This means that an explicit registration made for a closed generic version of the + always gets resolved first and the given + only gets resolved when there is no such registration. + + + The following example shows the definition of a generic IValidator<T> interface + and, a NullValidator<T> implementation and a specific validator for Orders. + The registration ensures a OrderValidator is returned when a + IValidator<Order> is requested. For all requests for a + IValidator<T> other than a IValidator<Order>, an + implementation of NullValidator<T> will be returned. + + { + void Validate(T instance); + } + + public class NullValidator : IValidator + { + public void Validate(T instance) + { + } + } + + public class OrderValidator : IValidator + { + public void Validate(Order instance) + { + if (instance.Total < 0) + { + throw new ValidationException("Total can not be negative."); + } + } + } + + [TestMethod] + public static void TestRegisterOpenGeneric() + { + // Arrange + var container = new Container(); + + container.Register, OrderValidator>(Lifestyle.Transient); + container.RegisterOpenGeneric(typeof(IValidator<>), typeof(NullValidator<>), Lifestyle.Singleton); + + // Act + var orderValidator = container.GetInstance>(); + var customerValidator = container.GetInstance>(); + var productValidator = container.GetInstance>(); + + // Assert + Assert.IsInstanceOfType(orderValidator, typeof(OrderValidator)); + Assert.IsInstanceOfType(customerValidator, typeof(NullValidator)); + Assert.IsInstanceOfType(productValidator, typeof(NullValidator)); + } + ]]> + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances. + The definition of the open generic implementation type + that will be returned when a is requested. + The lifestyle that defines how returned instances are cached. + + + + Registers that the same instance of will be returned + every time a is requested. + + + Please see the + RegisterOpenGeneric(Container,Type,Type,Lifestyle) + overload for an example. + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances.. + The definition of the open generic implementation type + that will be returned when a is requested. + The lifestyle that defines how returned instances are cached. + The predicate that determines whether the + can implement the service type. + + + + Registers that instances of will be returned + when a collection of is requested. New instances of + the registered will be returned whenever the + resolved collection is iterated. + + + Please see the + RegisterAllOpenGeneric(Container,Type,Lifestyle,IEnumerable<Type>) + overload for an example. + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances. + The list of open generic implementation types + that will be returned when a collection of is requested. + + + + + Registers that instances of will be returned + when a collection of is requested. New instances of + the registered will be returned whenever the + resolved collection is iterated. + + + Please see the + RegisterAllOpenGeneric(Container,Type,Lifestyle,IEnumerable<Type>) + overload for an example. + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances. + The list of open generic implementation types + that will be returned when a collection of is requested. + + + + + Registers that instances of will be returned + when a collection of is requested. The instances will be + cached according to the specified . + + + Please see the + RegisterAllOpenGeneric(Container,Type,Lifestyle,IEnumerable<Type>) + overload for an example. + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances. + The lifestyle that defines how returned instances are cached. + The list of open generic implementation types + that will be returned when a collection of is requested. + + + + + Registers that instances of will be returned + when a collection of is requested. The instances will be + cached according to the specified . + + + + Collections registered using the RegisterAllOpenGeneric are resolved using unregistered type + resolution. This means that an explicit registration made for a collection of the closed generic + version of the always gets resolved first and a + collection of only gets resolved when there is no + such registration. + + + + The following example shows the definition of a generic IValidator<T> interface + and, a NullValidator<T> implementation and a specific validator for Orders. + The registration ensures a OrderValidator is returned when a + IValidator<Order> is requested. For all requests for a + IValidator<T> other than a IValidator<Order>, an + implementation of NullValidator<T> will be returned. + + { + void Validate(T instance); + } + + public class DefaultValidator : IValidator + { + public void Validate(T instance) + { + // some default validation + } + } + + [TestMethod] + public static void TestRegisterAllOpenGeneric() + { + // Arrange + var container = new Container(); + + Type[] types = new[] { typeof(OrderValidator), typeof(DefaultValidator<>) }; + + container.RegisterManyForOpenGeneric(typeof(IValidator<>), + (serviceType, implementationTypes) => container.RegisterAll(serviceType, implementationTypes), + types); + + container.RegisterAllOpenGeneric(typeof(IValidator<>), typeof(DefaultValidator<>)); + + // Act + var orderValidators = container.GetAllInstances>(); + var customerValidators = container.GetAllInstances>(); + + // Assert + Assert.IsTrue(orderValidators.SequenceEqual( + new[] { typeof(OrderValidator), typeof(DefaultValidator) })); + + // Without the call to RegisterAllOpenGeneric this customerValidators would be empty. + Assert.IsTrue(customerValidators.SequenceEqual(new[] { typeof(DefaultValidator) })); + } + ]]> + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances. + The lifestyle that defines how returned instances are cached. + The list of open generic implementation types + that will be returned when a collection of is requested. + + + + Resolves a given open generic type. + + + + Allows validating an ArgumentMapping. + + + + + Instances returned from the container can be cached. The contains several + overloads of the Register method that take a Lifestyle instance as argument to define + how returned instances should be cached. The core library contains two lifestyles out of the box. By + supplying Lifestyle.Transient, the registered instance is not + cached; a new instance is returned every time it is requested or injected. By supplying + Lifestyle.Singleton instances can be cached indefinitely; only + a single instance of the registered component will be returned by that container instance. Other + lifestyles are defined in integration and extension packages. The + CreateCustom method allows defining a custom lifestyle and + the CreateHybrid method + allows creating a lifestyle that mixes multiple other lifestyles. + + + This type is abstract and can be overridden to implement a custom lifestyle. + + + + + The lifestyle instance that doesn't cache instances. A new instance of the specified + component is created every time the registered service it is requested or injected. + + + The following example registers the SomeServiceImpl implementation for the + ISomeService service type using the Transient lifestyle: + (Lifestyle.Transient); + ]]> + Note that Transient is the default lifestyle, the previous registration can be reduced to + the following: + (); + ]]> + + + + + The lifestyle that caches components during the lifetime of the instance + and guarantees that only a single instance of that component is created for that instance. Since + general use is to create a single Container instance for the lifetime of the application / + AppDomain, this would mean that only a single instance of that component would exist during the + lifetime of the application. In a multi-threaded applications, implementations registered using + this lifestyle must be thread-safe. + + + The following example registers the RealTimeProvider implementation for the + ITimeProvider service type using the Singleton lifestyle: + (Lifestyle.Singleton); + ]]> + Note that using the + RegisterSingle method has + the same effect: + (); + ]]> + + + + Initializes a new instance of the class. + The user friendly name of this lifestyle. + Thrown when is null (Nothing in VB) + or an empty string. + + + + The hybrid lifestyle allows mixing two lifestyles in a single registration. Based on the supplied + delegate the hybrid lifestyle will redirect the creation of + the instance to the correct lifestyle. The result of the + delegate will not be cached; it is invoked each time an instance is requested or injected. By + nesting hybrid lifestyles, any number of lifestyles can be mixed. + + The delegate that determines which + lifestyle should be used. The will be used if true is + returned; the otherwise. This delegate will be called every + time an instance needs to be resolved or injected. + The lifestyle to use when + returns true. + The lifestyle to use when + returns false. + A new hybrid lifestyle that wraps the supplied lifestyles. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + + The following example shows the creation of a HybridLifestyle that mixes an + WebRequestLifestyle and LifetimeScopeLifestyle: + + HttpContext.Current != null, + new WebRequestLifestyle(), + new LifetimeScopeLifestyle()); + + // The created lifestyle can be reused for many registrations. + container.Register(mixedScopeLifestyle); + container.Register(mixedScopeLifestyle); + ]]> + + Hybrid lifestyles can be nested: + + container.GetCurrentLifetimeScope() != null, + new LifetimeScopeLifestyle(), + Lifestyle.Transient); + + var mixedScopeLifestyle = Lifestyle.CreateHybrid( + () => HttpContext.Current != null, + new WebRequestLifestyle(), + mixedLifetimeTransientLifestyle); + ]]> + + The mixedScopeLifestyle now mixed three lifestyles: Web Request, Lifetime Scope and + Transient. + + + + + + The hybrid lifestyle allows mixing two lifestyles in a single registration. Based on the supplied + delegate the hybrid lifestyle will redirect the creation of + the instance to the correct lifestyle. The result of the + delegate will not be cached; it is invoked each time an instance is requested or injected. By + nesting hybrid lifestyles, any number of lifestyles can be mixed. + + The delegate that determines which + lifestyle should be used. The will be used if true is + returned; the otherwise. This delegate will be called every + time an instance needs to be resolved or injected. + The scoped lifestyle to use when + returns true. + The scoped lifestyle to use when + returns false. + A new scoped hybrid lifestyle that wraps the supplied lifestyles. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + + The following example shows the creation of a HybridLifestyle that mixes an + WebRequestLifestyle and LifetimeScopeLifestyle: + + HttpContext.Current != null, + new WebRequestLifestyle(), + new LifetimeScopeLifestyle()); + + // The created lifestyle can be reused for many registrations. + container.Register(mixedScopeLifestyle); + container.Register(mixedScopeLifestyle); + ]]> + + + + + Creates a custom lifestyle using the supplied delegate. + + + The supplied will be called just once per registered + service. The supplied will be called by the framework + when the type is resolved for the first time, and the framework will supply the factory with a + Func<object> for creating new (transient) instances of that type (that might + have been intercepted and + initializers might have been applied). + It is the job of the to return a Func<object> + that applies the proper caching. The Func<object> that is returned by the + will be stored for that registration (every + registration will store its own Func<object> delegate) and this delegate will be + called every time the service is resolved (by calling + container.GetInstance<TService> or when that service is injected into another + type). + + The name of the lifestyle to create. The name is used to display the lifestyle + in the debugger. + A factory delegate that takes a Func<object> delegate + that will produce a transient instance and returns a delegate that returns cached instances. + A new . + Thrown when one of the arguments is a null reference + (Nothing in VB). + Thrown when is an empty string. + + The following example shows the creation of a lifestyle that caches registered instances for 10 + minutes: + + { + TimeSpan timeout = TimeSpan.FromMinutes(10); + var syncRoot = new object(); + var expirationTime = DateTime.MinValue; + object instance = null; + + // If the application has multiple registrations using this lifestyle, each registration + // will get its own Func delegate (created here) and therefore get its own set + // of variables as defined above. + return () => + { + lock (syncRoot) + { + if (expirationTime < DateTime.UtcNow) + { + instance = instanceCreator(); + expirationTime = DateTime.UtcNow.Add(timeout); + } + + return instance; + } + }; + }); + + var container = new Container(); + + // We can reuse the created lifestyle for multiple registrations. + container.Register(customLifestyle); + container.Register(customLifestyle); + ]]> + + + + + Creates a new instance for the given + that will create new instances of specified with the + caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be created. + The instance for which a + must be created. + A new instance. + Thrown when is a null + reference (Nothing in VB). + + + + Creates a new instance for the given + that will create new instances instance using the supplied + with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + A delegate that will create a new instance of + every time it is called. + The instance for which a + must be created. + A new instance. + Thrown when either or + are null references (Nothing in VB). + + + + Creates a new instance for the given + that will create new instances of specified with the + caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + The instance for which a + must be created. + A new instance. + Thrown when on of the supplied arguments is a null + reference (Nothing in VB). + + + + Creates a new instance defining the creation of the + specified with the caching as specified by this lifestyle. + + The concrete type that will be registered. + The instance for which a + must be created. + A new instance. + Thrown when is a null + reference (Nothing in VB). + + + + Creates a new instance defining the creation of the + specified with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be created. + The instance for which a + must be created. + A new instance. + Thrown when is a null + reference (Nothing in VB). + + + + Creates a new instance defining the creation of the + specified using the supplied + with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + A delegate that will create a new instance of + every time it is called. + The instance for which a + must be created. + A new instance. + Thrown when either or + are null references (Nothing in VB). + + + + Creates a new instance defining the creation of the + specified with the caching as specified by this lifestyle. + This method might fail when run in a partial trust sandbox when + is an internal type. + + The concrete type that will be registered. + The instance for which a + must be created. + A new instance. + Thrown when on of the supplied arguments is a null + reference (Nothing in VB). + + + + Creates a new instance defining the creation of the + specified with the caching as specified by this lifestyle. + This method might fail when run in a partial trust sandbox when + is an internal type. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + The instance for which a + must be created. + A new instance. + Thrown when on of the supplied arguments is a null + reference (Nothing in VB). + + + + Creates a new instance defining the creation of the + specified using the supplied + with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + The delegate that will be responsible for creating new instances. + The instance for which a + must be created. + A new instance. + Thrown when on of the supplied arguments is a null + reference (Nothing in VB). + + + + When overridden in a derived class, + creates a new instance defining the creation of the + specified with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + The instance for which a + must be created. + A new instance. + + If you are implementing your own lifestyle, override this method to implement the code necessary + to create and return a new . Note that you should always create + a new instance. They should never be cached. + + + + + When overridden in a derived class, + creates a new instance defining the creation of the + specified using the supplied + with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + A delegate that will create a new instance of + every time it is called. + The instance for which a + must be created. + A new instance. + + If you are implementing your own lifestyle, override this method to implement the code necessary + to create and return a new . Note that you should always create + a new instance. They should never be cached. + + + + Gets the user friendly name of this lifestyle. + The user friendly name of this lifestyle. + + + + Gets the length of the lifestyle. Implementers must implement this property. The diagnostic + services use this value to compare lifestyles with each other to determine lifestyle + misconfigurations. + + The representing the length of this lifestyle. + + + + A known relationship defines a relationship between two types. The Diagnostics Debug View uses this + information to spot possible misconfigurations. + + + + Initializes a new instance of the class. + The implementation type of the parent type. + The lifestyle of the parent type. + The type that the parent depends on (it is injected into the parent). + + + Serves as a hash function for a particular type. + A hash code for the current . + + + + Determines whether the specified is equal to the current + . + + The object to compare with the current object. + True if the specified is equal to the current + ; otherwise, false. + + + Gets the implementation type of the parent type of the relationship. + The implementation type of the parent type of the relationship. + + + Gets the lifestyle of the parent type of the relationship. + The lifestyle of the parent type of the relationship. + + + Gets the type that the parent depends on (it is injected into the parent). + The type that the parent depends on. + + + + Factory for the creation of a delegate that applies caching to the supplied + . + + A factory for creating new instances. + A factory that returns cached instances. + + + + Forwards CreateRegistration calls to the lifestyle that is returned from the registered + container.Options.LifestyleSelectionBehavior. + + + + + Base class for scoped lifestyles. A scoped lifestyle caches instances for the duration of an implicitly + or explicitly defined scope. Such scope can be an (implicitly defined) web request or an explicitly + defined Lifetime Scope. The lifetime of instances registered with a scoped lifestyle is always equal + or bigger than one-instance-per-object-graph. In other words, a call to GetInstance() will never create + more than one instance of such registered type. + + + + Initializes a new instance of the class. + The user friendly name of this lifestyle. + Thrown when is null (Nothing in VB) + or an empty string. + + + Initializes a new instance of the class. + The user friendly name of this lifestyle. + Signals the lifestyle whether instances should be + disposed or not. + Thrown when is null (Nothing in VB) + or an empty string. + + + + Allows registering an delegate that will be called when the scope ends, + but before the scope disposes any instances. + + + During the call to all registered delegates are + processed in the order of registration. Do note that registered actions are not guaranteed + to run. In case an exception is thrown during the call to , the + will stop running any actions that might not have been invoked at that point. + Instances that are registered for disposal using on the other + hand, are guaranteed to be disposed. Note that registered actions won't be invoked during a call + to . + + The instance. + The delegate to run when the scope ends. + Thrown when one of the arguments is a null reference + (Nothing in VB). + Will be thrown when there is currently no active + scope for the supplied . + + + + Adds the to the list of items that will get disposed when the + scope ends. + + + Note to implementers: Instances registered for disposal will have to be disposed in the opposite + order of registration, since disposable components might still need to call disposable dependencies + in their Dispose() method. + + The instance. + The instance that should be disposed when the scope ends. + Thrown when one of the arguments is a null reference + (Nothing in VB). + Will be thrown when there is currently no active + scope for the supplied . + + + + Returns the current for this lifestyle and the given + , or null when this method is executed outside the context of a scope. + + The container instance that is related to the scope to return. + A instance or null when there is no scope active in this context. + + + + Creates a delegate that upon invocation return the current for this + lifestyle and the given , or null when the delegate is executed outside + the context of such scope. + + The container for which the delegate gets created. + A delegate. This method never returns null. + + + + Returns the current for this lifestyle and the given + , or null when this method is executed outside the context of a scope. + + The container instance that is related to the scope to return. + A instance or null when there is no scope active in this context. + + + + Creates a new instance defining the creation of the + specified using the supplied + with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + A delegate that will create a new instance of + every time it is called. + The instance for which a + must be created. + A new instance. + + + + Creates a new instance defining the creation of the + specified with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + The instance for which a + must be created. + A new instance. + + + + Disposes the list of supplied . The list is iterated in reverse + order (the first element in the list will be disposed last) and the method ensures that the + Dispose method of each element is called, regardless of any exceptions raised from any previously + called Dispose methods. If multiple exceptions are thrown, the last thrown exception will bubble + up the call stack. + + The list of objects to be disposed. + Thrown when the is a null + reference. + + + + Helper methods for the container. + + + + + Produces instances for a given registration. Instances of this type are generally created by the + container when calling one of the Register overloads. Instances can be retrieved by calling + or . + + + The Register method overloads create InstanceProducer instances internally, but + InstanceProducers can be created manually to implement special scenarios. An + InstanceProducer wraps instance. The Registration builds an + that describes the intend to create the instance according to a certain + lifestyle. The InstanceProducer on the other hand transforms this Expression to a + delegate and allows the actual instance to be created. A Registration itself can't create any + instance. The InsanceProducer allows intercepting created instances by hooking onto the + Container.ExpressionBuilt event. The + RegisterDecorator + extension methods for instance work by hooking onto the ExpressionBuilt event and allow + wrapping the returned instance with a decorator. + + + The following example shows the creation of two different InstanceProducer instances that wrap + the same Registration instance. Since the Registration is created using the + Singleton lifestyle, both producers will return + the same instance. The InstanceProducer for the Interface1 however, will wrap that + instance in a (transient) Interface1Decorator. + (container); + + var producer1 = new InstanceProducer(typeof(Interface1), registration); + var producer2 = new InstanceProducer(typeof(Interface2), registration); + + container.RegisterDecorator(typeof(Interface1), typeof(Interface1Decorator)); + + var instance1 = (Interface1)producer1.GetInstance(); + var instance2 = (Interface2)producer2.GetInstance(); + + Assert.IsInstanceOfType(instance1, typeof(Interface1Decorator)); + Assert.IsInstanceOfType(instance2, typeof(ServiceImpl)); + + Assert.AreSame(((Interface1Decorator)instance1).DecoratedInstance, instance2); + ]]> + + + + Initializes a new instance of the class. + The service type for which this instance is created. + The . + + + Produces an instance. + An instance. Will never return null. + When the instance could not be retrieved or is null. + + + + Builds an expression that expresses the intent to get an instance by the current producer. A call + to this method locks the container. No new registrations can't be made after a call to this method. + + An Expression. + + + + Gets the collection of relationships for this instance that the container knows about. + This includes relationships between the registered type and its dependencies and relationships + between applied decorators and their dependencies. Note that types that are not newed up by the + container, property dependencies that are injected using the (legacy) + InjectProperties method, and + properties that are injected inside a custom delegate that is registered using the + RegisterInitializer method are unknown + to the container and are not returned from this method. + Also note that this method will return an empty collection when called before the the + registered type is requested from the container (or before Verify + is called). + + An array of instances. + + + + Builds a string representation of the object graph with the current instance as root of the + graph. + + A string representation of the object graph. + Thrown when this method is called before + or have been called. These calls can be + done directly and explicitly by the user on this instance, indirectly by calling + or on an instance that depends on this + instance, or by calling Verify on the container. + + + + Gets the for this registration. The returned lifestyle can differ from the + lifestyle that is used during the registration. This can happen for instance when the registration + is changed by an ExpressionBuilt registration or + gets decorated. + + The for this registration. + + + Gets the service type for which this producer produces instances. + A instance. + + + Gets the instance for this instance. + The . + + + Internal helper for string resources. + + + + Provides data for and interaction with the + ResolveUnregisteredType event of + the . An observer can check the + to see whether the unregistered type can be handled. The + method can be called to register a delegate + that allows creation of instances of the unregistered for this and future requests. + + + + Initializes a new instance of the UnregisteredTypeEventArgs class. + The unregistered service type. + + + + Registers a delegate that allows creation of instances of the type + expressed by the for this and future requests. The delegate + will be caches and future requests will directly call that delegate. + + The delegate that allows creation of instances of the type + expressed by the . + Thrown when the is a + null reference. + Thrown when multiple observers that have registered to + the ResolveUnregisteredType event + called this method for the same type. + + + + Registers an that describes the creation of instances of the type + expressed by the for this and future requests. The delegate + will be cached and future requests will directly use that expression or the compiled delegate. + + + NOTE: If possible, use the Register(Registration) overload, + since this allows the analysis services to determine any configuration errors on the lifestyle of + the registration. + + The expression that describes the creation of instances of the type + expressed by the . + Thrown when the is a + null reference. + Thrown when multiple observers that have registered to + the ResolveUnregisteredType event + called this method for the same type. + + + + Registers a that describes the creation of instances of the type + expressed by the for this and future requests. The + registration will be cached and future requests will directly call unon that registration, the + expression that it generates or the delegate that gets compiled from that expression. + + The registration that describes the creation of instances according to + the registration's lifestyle of the type expressed by the . + Thrown when the is a + null reference. + Thrown when the is a + not exactly of type where T equals the . + + Thrown when multiple observers that have registered to + the ResolveUnregisteredType event + called this method for the same type. + + + Gets the unregistered service type that is currently requested. + The unregistered service type that is currently requested. + + + + Gets a value indicating whether the event represented by this instance has been handled. + This property will return true when has been called on + this instance. + + The indication whether the event has been handled. + + + diff --git a/packages/SimpleInjector.2.6.1/lib/portable-net4+sl4+wp8+win8+wpa81/SimpleInjector.Diagnostics.xml b/packages/SimpleInjector.2.6.1/lib/portable-net4+sl4+wp8+win8+wpa81/SimpleInjector.Diagnostics.xml new file mode 100644 index 0000000..254c1bd --- /dev/null +++ b/packages/SimpleInjector.2.6.1/lib/portable-net4+sl4+wp8+win8+wpa81/SimpleInjector.Diagnostics.xml @@ -0,0 +1,193 @@ + + + + SimpleInjector.Diagnostics + + + + + Entry point for doing diagnostic analysis on instances. + + + The following example shows the usage of the Analyzer class: + + + + + + Analyzes the supplied instance. + + The container instance to analyze. + A collection of sub types that describe the diagnostic + warnings and messages. + + + + Diagnostic result for a warning about a concrete type that was not registered explicitly and was not + resolved using unregistered type resolution, but was created by the container using the transient + lifestyle. + For more information, see: https://simpleinjector.org/diaut. + + + + + Base class for types that hold information about a single diagnostic message or warning for a + particular type or part of the configuration. + + + + Gets the diagnostic type of this result. + The . + + + Gets the service type to which this warning is related. + A . + + + Gets the description of the diagnostic result. + A with the description. + + + Gets the hierarchical group to which this diagnostic result belongs. + The . + + + Gets a collection of instances that describe all + container-registered dependencies for the given component. + List of objects. + + + + A hierarchical group of . + + + + + Gets the base that describes the service types of its + . The value often be either (in case this is a + root group) or a partial generic type to allow hierarchical grouping of a large number of related + generic types. + + The . + + + Gets the friendly name of the group. + The name. + + + Gets the description of the group. + The description. + + + Gets the diagnostic type of all grouped instances. + The . + + + Gets the parent or null (Nothing in VB) when this is the + root group. + The . + + + Gets the collection of child s. + A collection of elements. + + + Gets the collection of instances. + /// A collection of elements. + + + + Specifies the list of diagnostic types that are currently supported by the diagnostic + . Note that new diagnostic types might be added in future versions. + For more information, please read the + Diagnosing your configuration using the Diagnostic + Services wiki documentation. + + + + + Diagnostic type that warns about + a concrete type that was not registered explicitly and was not resolved using unregistered type + resolution, but was created by the container using the transient lifestyle. + For more information, see: https://simpleinjector.org/diaut. + + + + + Diagnostic type that warns when a + component depends on a service with a lifestyle that is shorter than that of the component. + For more information, see: https://simpleinjector.org/dialm. + + + + + Diagnostic type that warns when a + component depends on an unregistered concrete type and this concrete type has a lifestyle that is + different than the lifestyle of an explicitly registered type that uses this concrete type as its + implementation. + For more information, see: https://simpleinjector.org/diasc. + + + + + Diagnostic type that warns when a + component depends on (too) many services. + For more information, see: https://simpleinjector.org/diasr. + + + + + Diagnostic result for a warning about a + component that depends on a service with a lifestyle that is shorter than that of the component. + For more information, see: https://simpleinjector.codeplex.com/wikipage?title=PotentialLifestyleMismatches. + + + + Gets the object that describes the relationship between the component and its dependency. + A instance. + + + + Diagnostic result that warns about a + component that depends on an unregistered concrete type and this concrete type has a lifestyle that is + different than the lifestyle of an explicitly registered type that uses this concrete type as its + implementation. + For more information, see: https://simpleinjector.codeplex.com/wikipage?title=ShortCircuitedDependencies. + + + + Gets the instance that describes the current relationship between the checked component + and the short-circuited dependency. + The . + + + + Gets the collection of registrations that have the component's current dependency as + implementation type, but have a lifestyle that is different than the current dependency. + + A collection of instances. + + + + Diagnostic result that warns about a component that depends on (too) many services. + For more information, see: https://simpleinjector.codeplex.com/wikipage?title=PotentialSingleResponsibilityViolations. + + + + Gets the created type. + A . + + + Gets the list of registrations that are dependencies of the . + A collection of instances. + + + diff --git a/packages/SimpleInjector.2.6.1/lib/portable-net4+sl4+wp8+win8+wpa81/SimpleInjector.xml b/packages/SimpleInjector.2.6.1/lib/portable-net4+sl4+wp8+win8+wpa81/SimpleInjector.xml new file mode 100644 index 0000000..41d5f1f --- /dev/null +++ b/packages/SimpleInjector.2.6.1/lib/portable-net4+sl4+wp8+win8+wpa81/SimpleInjector.xml @@ -0,0 +1,4573 @@ + + + + SimpleInjector + + + + + The standard exception thrown when a container has an error in resolving an object. + + + + + Initializes a new instance of the class. + + + + + Initializes a new instance of the class with a specified error + message. + + The message that describes the error. + + + + Initializes a new instance of the class with a specified error + message and a reference to the inner exception that is the cause of this exception. + + + The error message that explains the reason for the exception. + + + The exception that is the cause of the current exception, or a null reference (Nothing in Visual + Basic) if no inner exception is specified. + + + + + Extension methods for enable advanced scenarios. + + + + + Determines whether the specified container is locked making any new registrations. The container + is automatically locked when GetInstance is called for the + first time. + + The container. + + true if the specified container is locked; otherwise, false. + + Thrown when is null. + + + Determines whether the specified container is currently verifying its configuration. + The container. + true if the specified container is verifying; otherwise, false. + Thrown when is null. + + + + Builds up an delegate wrapping all delegates that + are registered using RegisterInitializer and + that apply to the given (including delegates that are registered + for interfaces implements and base types that + inherits from). Null will be returned when no delegates are + registered that apply to this type. + + The container. + + This method has a performance caracteristic of O(n). Prevent from calling this in a performance + critical path of the application. + + The type for with an initializer must be built. + An delegate or null. + + + + Retrieves an item from the container stored by the given or null when no + item is stored by that key. + + + Thread-safety: Calls to this method are thread-safe, but users should take proper + percausions when they call both GetItem and . + + The container. + The key of the item to retrieve. + The stored item or null (Nothing in VB). + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + + + Stores an item by the given in the container. + + + Thread-safety: Calls to this method are thread-safe, but users should take proper + percausions when they call both and SetItem. + + The container. + The key of the item to insert or override. + The actual item. May be null. + Thrown when either or + is a null reference (Nothing in VB). + + + + Allows appending new registrations to existing registrations made using one of the + RegisterAll overloads. + + The container. + The service type of the collection. + The registration to append. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + Thrown when the is not a + reference type, is open generic, or ambiguous. + Thrown when the container is locked. + Thrown when the method is called for a registration + that is made with one of the RegisterAll overloads that accepts a dynamic collection + (an IEnumerable or IEnumerable<TService>). + + + This interface is not meant for public use. + + + Please do not use. + Do not use. + + + PLease do not use. + Do not use. + + + + Defines the container's behavior for building an expression tree based on the supplied constructor of + a given type. + Set the ConstructorInjectionBehavior + property of the container's property to change the default behavior + of the container. + + + + + Builds an for the supplied , based on the + container's configuration. + + The parameter. + An that describes the intend of creating that + . This method never returns null. + + + + Defines the container's behavior for finding a suitable constructor for the creation of a type. + Set the ConstructorResolutionBehavior + property of the container's property to change the default behavior + of the container. + + + + + Gets the given 's constructor that can be used by the + container to create that instance. + + Type of the abstraction that is requested. + Type of the implementation to find a suitable constructor for. + + The . This method never returns null. + + Thrown when no suitable constructor could be found. + + + + Defines the container's behavior for verifying the constructor that will be picked by the + . + Set the ConstructorVerificationBehavior + property of the container's property to change the default behavior + of the container. + + + + Verifies the specified . + The parameter. + Thrown when the cannot be + used for auto wiring. + + Thrown when the is a + null reference. + + + + Defines the container's behavior for selecting properties to inject during the creation of a type. + Set the PropertySelectionBehavior + property of the container's property to change the default behavior + of the container. By default, no properties will be injected by the container. + + + + + Determines whether a property should be injected by the container upon creation of its type. + + Type of the abstraction that is requested. + The property to check. + True when the property should be injected. + + + + Defines the container's behavior for selecting the lifestyle for a registration in case no lifestyle + is explicitly supplied. + Set the LifestyleSelectionBehavior + property of the container's property to change the default behavior + of the container. By default, when no lifestyle is explicitly supplied, the + Transient lifestyle is used. + + + + Selects the lifestyle based on the supplied type information. + Type of the abstraction that is registered. + Type of the implementation to that is registered. + The suited for the given type. + Thrown when either one of the arguments is a null reference. + + + + An instance of this type will be supplied to the + delegate that is that is supplied to the + RegisterInitializer + overload that takes this delegate. This type contains contextual information about the creation and it + allows the user to examine the given instance to decide whether the instance should be initialized or + not. + + + + + Gets the that is responsible for the initialization of the created + instance. + + The or null (Nothing in VB) when the instance producer is + unknown. + + + + Gets the that is responsible for the initialization of the created + instance. + + /// The . + + + + Contains data that can be used to initialize a created instance. This data includes the actual + created and the information about the created instance. + + + + Returns the hash code for this instance. + A 32-bit signed integer that is the hash code for this instance. + + + Indicates whether this instance and a specified object are equal. + Another object to compare to. + True if the current object is equal to the other parameter; otherwise, false. + + + + Indicates whether the current object is equal to another object of the same type. + + An object to compare with this object. + True if the current object is equal to the other parameter; otherwise, false. + + + + Indicates whether the values of two specified objects are equal. + + The first object to compare. + The second object to compare. + True if a and b are equal; otherwise, false. + + + + Indicates whether the values of two specified objects are + not equal. + + The first object to compare. + The second object to compare. + True if a and b are not equal; otherwise, false. + + + Gets the with contextual information about the + created instance. + The . + + + Gets the created instance. + The created instance. + + + + This is an internal type. Only depend on this type when you want to be absolutely sure a future + version of the framework will break your code. + + + + Initializes a new instance of the struct. + The scope factory. + The container. + + + Gets the lazily initialized Scope of the current LazyScope instance. + The current Scope or null. + + + + This is an internal type. Only depend on this type when you want to be absolutely sure a future + version of the framework will break your code. + + Service type. + Implementation type. + + + + Initializes a new instance of the + struct. + The registration. + + + Gets the lazily initialized instance for the of the current LazyScopedRegistration. + The scope that is used to retrieve the instance. + The cached instance. + + + + A known relationship defines a relationship between two types. The Diagnostics Debug View uses this + information to spot possible misconfigurations. + + + + Initializes a new instance of the class. + The implementation type of the parent type. + The lifestyle of the parent type. + The type that the parent depends on (it is injected into the parent). + + + Serves as a hash function for a particular type. + A hash code for the current . + + + + Determines whether the specified is equal to the current + . + + The object to compare with the current object. + True if the specified is equal to the current + ; otherwise, false. + + + Gets the implementation type of the parent type of the relationship. + The implementation type of the parent type of the relationship. + + + Gets the lifestyle of the parent type of the relationship. + The lifestyle of the parent type of the relationship. + + + Gets the type that the parent depends on (it is injected into the parent). + The type that the parent depends on. + + + + The container. Create an instance of this type for registration of dependencies. + + + + Thread-safety: + Resolving instances can be done safely from multiple threads concurrently, but registration needs to + be done from one single thread. + + + It is therefore safe to call , , + GetService, and + and anything related to resolving instances from multiple thread + concurrently. It is however unsafe to call + RegisterXXX, + , , , + or anything related to registering from multiple threads concurrently. + + + + + Initializes a new instance of the class. + + + Initializes a new instance of the class. + The container options. + Thrown when the is a null + reference. + Thrown when supplied is an instance + that already is supplied to another instance. Every container must get + its own instance. + + + + Returns an array with the current registrations. This list contains all explicitly registered + types, and all implicitly registered instances. Implicit registrations are all concrete + unregistered types that have been requested, all types that have been resolved using + unregistered type resolution (using the event), and + requested unregistered collections. Note that the result of this method may change over time, + because of these implicit registrations. + + + + This method has a performance characteristic of O(n). Prevent from calling this in a performance + critical path of the application. + + + Note: This method is not guaranteed to always return the same + instance for a given registration. It will however either + always return a producer that is able to return the expected instance. Because of this, do not + compare sets of instances returned by different calls to + by reference. The way of comparing lists is by the actual type. The type of each instance is + guaranteed to be unique in the returned list. + + + An array of instances. + + + + Returns an array with the current registrations for root objects. Root objects are registrations + that are in the root of the object graph, meaning that no other registration is depending on it. + + + + This method has a performance characteristic of O(n). Prevent from calling this in a performance + critical path of the application. + + + This list contains the root objects of all explicitly registered types, and all implicitly + registered instances. Implicit registrations are all concrete unregistered types that have been + requested, all types that have been resolved using unregistered type resolution (using the + event), and requested unregistered collections. Note that + the result of this method may change over time, because of these implicit registrations. + + + Note: This method is not guaranteed to always return the same + instance for a given registration. It will however either + always return a producer that is able to return the expected instance. Because of this, do not + compare sets of instances returned by different calls to + by reference. The way of comparing lists is by the actual type. The type of each instance is + guaranteed to be unique in the returned list. + + + An array of instances. + Thrown when this method is called before + has been successfully called. + + + Determines whether the specified System.Object is equal to the current System.Object. + + The System.Object to compare with the current System.Object. + + True if the specified System.Object is equal to the current System.Object; otherwise, false. + + + + Returns the hash code of the current instance. + The hash code of the current instance. + + + + Returns a that represents the . + + + A that represents the . + + + + Gets the of the current instance. + The instance that represents the exact runtime + type of the current instance. + + + Prevents any new registrations to be made to the container. + + + + Registers that a new instance of will be returned every time it + is requested (transient). + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + The concrete type that will be registered. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + Thrown when the is a type + that can not be created by the container. + + + + Registers that an instance of will be returned when it + is requested. The instance is cached according to the supplied . + + The concrete type that will be registered. + The lifestyle that specifies how the returned instance will be cached. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + Thrown when the is a type + that can not be created by the container. + + + + Registers that a new instance of will be returned every time a + is requested (transient). + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + Thrown when the given + type is not a type that can be created by the container. + + + + + Registers the specified delegate that allows returning transient instances of + . The delegate is expected to always return a new instance on + each call. + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + The interface or base type that can be used to retrieve instances. + The delegate that allows building or creating new instances. + + Thrown when this container instance is locked and can not be altered, or when the + has already been registered. + + Thrown when is a null reference. + + + + Registers that a new instance of will be returned every time it + is requested (transient). + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + The concrete type that will be registered. + Thrown when is a null + references (Nothing in VB). + Thrown when represents an + open generic type or is a type that can not be created by the container. + + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + + Registers that a new instance of will be returned every time a + is requested. If and + represent the same type, the type is registered by itself. + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + The base type or interface to register. + The actual type that will be returned when requested. + Thrown when or + are null references (Nothing in VB). + Thrown when is + no sub type from (or the same type), or one of them represents an + open generic type. + + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + + Registers the specified delegate that allows returning instances of . + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + The base type or interface to register. + The delegate that will be used for creating new instances. + Thrown when either or + are null references (Nothing in VB). + Thrown when represents an + open generic type. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + + Registers a single concrete instance that will be constructed using constructor injection and will + be returned when this instance is requested by type . + This must be thread-safe when working in a multi-threaded + environment. + + The concrete type that will be registered. + + Thrown when this container instance is locked and can not be altered, or when + has already been registered. + + Thrown when the is a type + that can not be created by the container. + + + + Registers that the same a single instance of type will be + returned every time an type is requested. If + and represent the same + type, the type is registered by itself. must be thread-safe + when working in a multi-threaded environment. + + + The interface or base type that can be used to retrieve the instances. + + The concrete type that will be registered. + + Thrown when this container instance is locked and can not be altered, or when the + has already been registered. + Thrown when the given + type is not a type that can be created by the container. + + + + + Registers a single instance that will be returned when an instance of type + is requested. This must be thread-safe + when working in a multi-threaded environment. + + The interface or base type that can be used to retrieve the instance. + The instance to register. + + Thrown when this container instance is locked and can not be altered, or when the + has already been registered. + + Thrown when is a null reference. + + + + + Registers the specified delegate that allows constructing a single instance of + . This delegate will be called at most once during the lifetime of + the application. The returned instance must be thread-safe when working in a multi-threaded + environment. + + The interface or base type that can be used to retrieve instances. + The delegate that allows building or creating this single + instance. + + Thrown when this container instance is locked and can not be altered, or when a + for has already been registered. + + Thrown when is a + null reference. + + + + Registers that the same instance of type will be returned every + time an instance of type type is requested. If + and represent the same type, the + type is registered by itself. must be thread-safe when working + in a multi-threaded environment. + + The base type or interface to register. + The actual type that will be returned when requested. + Thrown when either or + are null references (Nothing in VB). + Thrown when is + no sub type from , or when one of them represents an open generic + type. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + + Registers the specified delegate that allows constructing a single + instance. The container will call this delegate at most once during the lifetime of the application. + + The base type or interface to register. + The delegate that will be used for creating that single instance. + Thrown when represents an open + generic type. + Thrown when either or + are null references (Nothing in + VB). + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + + Registers a single instance that will be returned when an instance of type + is requested. This must be thread-safe + when working in a multi-threaded environment. + + The base type or interface to register. + The instance to register. + Thrown when either or + are null references (Nothing in VB). + Thrown when is + no sub type from . + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + + Registers that an instance of will be returned when an + instance of type is requested. The instance is cached according to + the supplied . + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + The lifestyle that specifies how the returned instance will be cached. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + Thrown when the given + type is not a type that can be created by the container. + + + + + Registers the specified delegate that will produce instances of + type and will be returned when an instance of type + is requested. The delegate is expected to produce new instances on + each call. The instances are cached according to the supplied . + + The interface or base type that can be used to retrieve instances. + The delegate that allows building or creating new instances. + The lifestyle that specifies how the returned instance will be cached. + + Thrown when this container instance is locked and can not be altered, or when the + has already been registered. + + Thrown when one of the supplied arguments is a null reference (Nothing in VB). + + + + Registers that an instance of type will be returned when an + instance of type is requested. The instance is cached according to + the supplied . + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + The lifestyle that specifies how the returned instance will be cached. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + Thrown when this container instance is locked and can not be altered, or when the + has already been registered. + Thrown when the given + type is not a type that can be created by the container, when either + or are open generic types, or when + is not assignable from the . + + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + + + Registers the specified delegate that will produce instances of + type and will be returned when an instance of type + is requested. The delegate is expected to produce new instances on + each call. The instances are cached according to the supplied . + + The interface or base type that can be used to retrieve instances. + The delegate that allows building or creating new instances. + The lifestyle that specifies how the returned instance will be cached. + + Thrown when this container instance is locked and can not be altered, or when the + has already been registered. + + Thrown when one of the supplied arguments is a null reference (Nothing in VB). + + + + Registers an delegate that runs after the creation of instances that + implement or derive from the given . Please note that only instances + that are created by the container (using constructor injection) can be initialized this way. + + The type for which the initializer will be registered. + The delegate that will be called after the instance has been + constructed and before it is returned. + + Thrown when the is a null reference. + + + Thrown when this container instance is locked and can not be altered. + + + Multiple delegates can be registered per + and multiple initializers can be applied on a created instance, + before it is returned. For instance, when registering a + for type , the delegate will be called for every instance created by + the container, which can be nice for debugging purposes. + + + Note: Initializers are guaranteed to be executed in the order they are registered. + + + The following example shows the usage of the + RegisterInitializer method: + + (); + + // Configuring property injection for types that implement ICommand: + container.RegisterInitializer(command => + { + command.SendAsync = true; + }); + + // Configuring property injection for types that implement CommandBase: + container.RegisterInitializer(command => + { + command.Clock = container.GetInstance(); + }); + + // Act + var command = (ConcreteCommand)container.GetInstance(); + + // Assert + // Because ConcreteCommand implements both ICommand and CommandBase, + // both the initializers will have been executed. + Assert.IsTrue(command.SendAsync); + Assert.IsNotNull(command.Clock); + } + ]]> + + The container does not use the type information of the requested service type, but it uses the + type information of the actual implementation to find all initialized that apply for that + type. This makes it possible to have multiple initializers to be applied on a single returned + instance while keeping performance high. + + + Registered initializers will only be applied to instances that are created by the container self + (using constructor injection). Types that are newed up manually by supplying a + delegate to the container (using the + and + methods) or registered as single instance + (using ) will not trigger initialization. + When initialization of these instances is needed, this must be done manually, as can be seen in + the following example: + commandInitializer = command => + { + initializerCallCount++; + }); + + // Configuring that initializer. + container.RegisterInitializer(commandInitializer); + + container.Register(() => + { + // Create a ConcreteCommand manually: will not be initialized. + var command = new ConcreteCommand("Data Source=.;Initial Catalog=db;"); + + // Run the initializer manually. + commandInitializer(command); + + return command; + }); + + // Act + var command = container.GetInstance(); + + // Assert + // The initializer will only be called once. + Assert.AreEqual(1, initializerCallCount); + } + ]]> + The previous example shows how a manually created instance can still be initialized. Try to + prevent creating types manually, by changing the design of those classes. If possible, create a + single public constructor that only contains dependencies that can be resolved. + + + + + + Registers an delegate that runs after the + creation of instances for which the supplied returns true. Please + note that only instances that are created by the container can be initialized this way. + + The delegate that will be called after the instance has been + constructed and before it is returned. + The predicate that will be used to check whether the given delegate must + be applied to a registration or not. The given predicate will be called once for each registration + in the container. + + Thrown when either the or are + null references. + + + Thrown when this container instance is locked and can not be altered. + + + Note: Initializers are guaranteed to be executed in the order they are registered. + + + Note: The is not guaranteed to be called once per registration; + when a registration's instance is requested for the first time simultaneously over multiple thread, + the predicate might be called multiple times. The caller of this method is responsible of supplying + a predicate that is thread-safe. + + + + + + Registers a dynamic (container uncontrolled) collection of elements of type + . A call to will return the + itself, and updates to the collection will be reflected in the + result. If updates are allowed, make sure the collection can be iterated safely if you're running + a multi-threaded application. + + The interface or base type that can be used to retrieve instances. + The collection to register. + + Thrown when this container instance is locked and can not be altered, or when a + for has already been registered. + + Thrown when is a null + reference. + + + + Registers a collection of singleton elements of type . + + The interface or base type that can be used to retrieve instances. + The collection to register. + + Thrown when this container instance is locked and can not be altered, or when a + for has already been registered. + + Thrown when is a null + reference. + Thrown when one of the elements of + is a null reference. + + + + Registers a collection of , whose instances will be resolved lazily + each time the resolved collection of is enumerated. + The underlying collection is a stream that will return individual instances based on their + specific registered lifestyle, for each call to . + The order in which the types appear in the collection is the exact same order that the items were + registered, i.e the resolved collection is deterministic. + + The base type or interface for elements in the collection. + The collection of objects whose instances + will be requested from the container. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + Thrown when contains a null + (Nothing in VB) element, a generic type definition, or the is + not assignable from one of the given elements. + + + + + Registers a collection of , whose instances will be resolved lazily + each time the resolved collection of is enumerated. + The underlying collection is a stream that will return individual instances based on their + specific registered lifestyle, for each call to . + The order in which the types appear in the collection is the exact same order that the items were + registered, i.e the resolved collection is deterministic. + + The base type or interface for elements in the collection. + The collection of objects whose instances + will be requested from the container. + Thrown when is a null + reference (Nothing in VB). + + Thrown when contains a null + (Nothing in VB) element, a generic type definition, or the is + not assignable from one of the given elements. + + + + + Registers a collection of , whose instances will be resolved lazily + each time the resolved collection of is enumerated. + The underlying collection is a stream that will return individual instances based on their + specific registered lifestyle, for each call to . + The order in which the types appear in the collection is the exact same order that the items were + registered, i.e the resolved collection is deterministic. + + The base type or interface for elements in the collection. + The collection of objects whose instances + will be requested from the container. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + Thrown when contains a null + (Nothing in VB) element, a generic type definition, or the is + not assignable from one of the given elements. + + + + + Registers a collection of , whose instances will be resolved lazily + each time the resolved collection of is enumerated. + The underlying collection is a stream that will return individual instances based on their + specific registered lifestyle, for each call to . + The order in which the types appear in the collection is the exact same order that the items were + registered, i.e the resolved collection is deterministic. + + The base type or interface for elements in the collection. + The collection of objects whose instances + will be requested from the container. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + Thrown when contains a null + (Nothing in VB) element, the is a generic type definition, or when + is + not assignable from one of the given elements. + + + + + Registers a collection of , whose instances will be resolved lazily + each time the resolved collection of is enumerated. + The underlying collection is a stream that will return individual instances based on their + specific registered lifestyle, for each call to . + The order in which the types appear in the collection is the exact same order that the items were + registered, i.e the resolved collection is deterministic. + + The base type or interface for elements in the collection. + The collection of objects whose instances + will be requested from the container. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + Thrown when contains a null + (Nothing in VB) element, the is a generic type definition, or when + is + not assignable from one of the given elements. + + + + + Registers a dynamic (container uncontrolled) collection of elements of type + . A call to will return the + itself, and updates to the collection will be reflected in the + result. If updates are allowed, make sure the collection can be iterated safely if you're running + a multi-threaded application. + + The base type or interface for elements in the collection. + The collection of items to register. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + Thrown when represents an + open generic type. + + + + Verifies the Container. This method will call all registered delegates, + iterate registered collections and throws an exception if there was an error. + + Thrown when the registration of instances was + invalid. + + + + Adds the for the supplied . This + method can be used to apply the same to multiple different service + types. + + The base type or interface to register. + The registration that should be stored for the given + . + + (container); + + container.AddRegistration(typeof(IFoo), registration); + container.AddRegistration(typeof(IBar), registration); + + // Act + IFoo foo = container.GetInstance(); + IBar bar = container.GetInstance(); + + // Assert + bool fooAndBareAreTheSameInstance = object.ReferenceEquals(foo, bar); + Assert.IsTrue(fooAndBareAreTheSameInstance); + } + ]]> + + In the example above a singleton registration is created for type FooBar and this + registration is added to the container for each interface (IFoo and IBar) that it + implements. Since both services use the same singleton registration, requesting those services + will result in the return of the same (singleton) instance. + + + events are applied to the of the + instance and are therefore applied once. + events on the other hand get applied to the Expression of the . + Since each AddRegistration gets its own instance producer (that wraps the + Registration instance), this means that the ExpressionBuilt events will be + applied for each registered service type. + + + The most practical example of this is the use of decorators using one of the + RegisterDecorator overloads + (decorator registration use the + ExpressionBuilt event under the covers). Take a look at the following example: + + (container); + + container.AddRegistration(typeof(IFoo), registration); + container.AddRegistration(typeof(IBar), registration); + + // Registere a decorator for IBar, but not for IFoo + container.RegisterDecorator(typeof(IBar), typeof(BarDecorator)); + + // Act + var foo = container.GetInstance(); + var decorator = container.GetInstance() as BarDecorator; + var bar = decorator.DecoratedBar; + + // Assert + bool fooAndBareAreTheSameInstance = object.ReferenceEquals(foo, bar); + Assert.IsTrue(fooAndBareAreTheSameInstance); + } + ]]> + The example shows that the decorator gets applied to IBar but not to IFoo, but that + the decorated IBar is still the same instance as the resolved IFoo instance. + + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + Thrown when is not a reference + type, is open generic, is ambiguous, when it is not assignable from the + 's ImplementationType + or when the supplied is created for a different + instance. + + Thrown when this container instance is locked and can not be altered, or when an + the has already been registered. + + + + Gets an instance of the given . + Type of object requested. + The requested service instance. + Thrown when there are errors resolving the service instance. + + + Gets an instance of the given . + Type of object requested. + The requested service instance. + Thrown when there are errors resolving the service instance. + + + + Gets all instances of the given currently registered in the container. + + Type of object requested. + A sequence of instances of the requested TService. + Thrown when there are errors resolving the service instance. + + + + Gets all instances of the given currently registered in the container. + + Type of object requested. + A sequence of instances of the requested serviceType. + Thrown when there are errors resolving the service instance. + + + Gets the service object of the specified type. + An object that specifies the type of service object to get. + A service object of type serviceType. -or- null if there is no service object of type + . + + + + Gets the for the given . When no + registration exists, the container will try creating a new producer. A producer can be created + when the type is a concrete reference type, there is an + event registered that acts on that type, or when the service type is an . + Otherwise null (Nothing in VB) is returned. + + + + A call to this method locks the container. No new registrations can't be made after a call to this + method. + + + Note: This method is not guaranteed to always return the same + instance for a given . It will however either + always return null or always return a producer that is able to return the expected instance. + + + The that the returned instance producer should produce. + An or null (Nothing in VB). + + + + Gets the for the given . When no + registration exists, the container will try creating a new producer. A producer can be created + when the type is a concrete reference type, there is an + event registered that acts on that type, or when the service type is an . + Otherwise null (Nothing in VB) is returned, or an exception is throw when + is set to true. + + + + A call to this method locks the container. No new registrations can't be made after a call to this + method. + + + Note: This method is not guaranteed to always return the same + instance for a given . It will however either + always return null or always return a producer that is able to return the expected instance. + + + The that the returned instance producer should produce. + The indication whether the method should return null or throw + an exception when the type is not registered. + An or null (Nothing in VB). + + + + Injects all public writable properties of the given that have a type + that can be resolved by this container instance. + NOTE: This method will be removed in a future release. To use property injection, + implement a custom the instead. For more information, + read the + extendibility points wiki. + + The instance whose properties will be injected. + + Thrown when the is null (Nothing in VB). + Throw when injecting properties on the given instance + failed due to security constraints of the sandbox. This can happen when injecting properties + on an internal type in a Silverlight sandbox, or when running in partial trust. + + + Gets the container options. + The instance for this container. + + + + Gets the intermediate lifestyle that forwards CreateRegistration calls to the lifestyle that is + returned from the registered container.Options.LifestyleSelectionBehavior. + + + + + Occurs when an instance of a type is requested that has not been registered explicitly, allowing + resolution of unregistered types before the container tries to create the type. + + + + The event is called by the container every time an + unregistered type is requested for the first time, allowing a developer to do unregistered type + resolution. By calling the + Register method on the + , a , or + delegate can be registered allowing the container to retrieve + instances of the requested type. This registration is cached and it prevents the + ResolveUnregisteredType event from being called again for the same type. + + + When no registered event handled the registration of an unregistered type, the container will try + to create the type when this type is either concrete or is the + interface. Concrete types will be registered with the Transient + lifestyle and registrations will return an empty collection. When no + even handled the registration and the container could not create it, an exception is thrown. + + + Thread-safety: Please note that the container will not ensure that the hooked delegates + are executed only once. While the calls to for a given type + are finite (and will in most cases happen just once), a container can call the delegate multiple + times and make parallel calls to the delegate. You must make sure that the code can be called + multiple times and is thread-safe. + + + + The following example shows the usage of the event: + + { + void Validate(T instance); + } + + // Implementation of the null object pattern. + public class EmptyValidator : IValidator + { + public void Validate(T instance) + { + // Does nothing. + } + } + + [TestMethod] + public void TestResolveUnregisteredType() + { + // Arrange + var container = new Container(); + + // Register an EmptyValidator to be returned when a IValidator is requested: + container.ResolveUnregisteredType += (sender, e) => + { + if (e.UnregisteredServiceType.IsGenericType && + e.UnregisteredServiceType.GetGenericTypeDefinition() == typeof(IValidator<>)) + { + var validatorType = typeof(EmptyValidator<>).MakeGenericType( + e.UnregisteredServiceType.GetGenericArguments()); + + object emptyValidator = container.GetInstance(validatorType); + + // Register the instance as singleton. + e.Register(() => emptyValidator); + } + }; + + // Act + var orderValidator = container.GetInstance>(); + var customerValidator = container.GetInstance>(); + + // Assert + Assert.IsInstanceOfType(orderValidator, typeof(EmptyValidator)); + Assert.IsInstanceOfType(customerValidator, typeof(EmptyValidator)); + } + ]]> + + The example above registers a delegate that is raised every time an unregistered type is requested + from the container. The delegate checks whether the requested type is a closed generic + implementation of the IValidator<T> interface (such as + IValidator<Order> or IValidator<Customer>). In that case it + will request the container for a concrete EmptyValidator<T> implementation that + implements the given + UnregisteredServiceType, and + registers a delegate that will return this created instance. The e.Register call + registers the method in the container, preventing the from + being called again for the exact same service type, preventing any performance penalties. + + + Please note that given example is just an uhhmm... example. In the case of the example the + EmptyValidator<T> can be better registered using of the built-in + RegisterOpenGeneric + extension methods instead. These extension methods take care of any given generic type constraint + and allow the implementation to be integrated into the container's pipeline, which allows + it to be intercepted using the event and allow any registered + initializers to be applied. + + + + + + Occurs after the creation of the of a registered type is complete (the + lifestyle has been applied), allowing the created to be wrapped, + changed, or replaced. Multiple delegates may handle the same service type. + + + + The ExpressionBuilt event is called by the container every time an registered type is + getting compiled, allowing a developer to change the way the type is created. The delegate that + hooks to the ExpressionBuilt event, can change the + property on the + , which allows changing the way the type is constructed. + + + Thread-safety: Please note that the container will not ensure that the hooked delegates + are executed only once per service type. While the calls to for a + given type are finite (and will in most cases happen just once), a container can call the delegate + multiple times and make parallel calls to the delegate. You must make sure that the code can be + called multiple times and is thread-safe. + + + + The following example shows the usage of the ExpressionBuilt event: + + { + void Validate(T instance); + } + + public interface ILogger + { + void Write(string message); + } + + // Implementation of the decorator pattern. + public class MonitoringValidator : IValidator + { + private readonly IValidator validator; + private readonly ILogger logger; + + public MonitoringValidator(IValidator validator, ILogger logger) + { + this.validator = validator; + this.logger = logger; + } + + public void Validate(T instance) + { + this.logger.Write("Validating " + typeof(T).Name); + this.validator.Validate(instance); + this.logger.Write("Validated " + typeof(T).Name); + } + } + + [TestMethod] + public void TestExpressionBuilt() + { + // Arrange + var container = new Container(); + + container.RegisterSingle(); + container.Register, OrderValidator>(); + container.Register, CustomerValidator>(); + + // Intercept the creation of IValidator instances and wrap them in a MonitoringValidator: + container.ExpressionBuilt += (sender, e) => + { + if (e.RegisteredServiceType.IsGenericType && + e.RegisteredServiceType.GetGenericTypeDefinition() == typeof(IValidator<>)) + { + var decoratorType = typeof(MonitoringValidator<>) + .MakeGenericType(e.RegisteredServiceType.GetGenericArguments()); + + // Wrap the IValidator in a MonitoringValidator. + e.Expression = Expression.New(decoratorType.GetConstructors()[0], new Expression[] + { + e.Expression, + container.GetRegistration(typeof(ILogger)).BuildExpression(), + }); + } + }; + + // Act + var orderValidator = container.GetInstance>(); + var customerValidator = container.GetInstance>(); + + // Assert + Assert.IsInstanceOfType(orderValidator, typeof(MonitoringValidator)); + Assert.IsInstanceOfType(customerValidator, typeof(MonitoringValidator)); + } + ]]> + + The example above registers a delegate that is raised every time the container compiles the + expression for an registered type. The delegate checks whether the requested type is a closed generic + implementation of the IValidator<T> interface (such as + IValidator<Order> or IValidator<Customer>). In that case it + will changes the current with a new one that creates + a new MonitoringValidator<T> that takes the current validator (and an ILogger) + as an dependency. + + + Please note that given example is just an uhhmm... example. In the case of the example the + MonitoringValidator<T> is a decorator and instead of manually writing this code that + many limitations, you can use one of the built-in + RegisterDecorator extension methods instead. + These extension methods take care of any given generic type constraint, allow to register decorators + conditionally and allow the decorator to be integrated into the container's pipeline, which allows + it to be intercepted using the event and allow any registered + initializers to be applied. + + + + + + Occurs directly after the creation of the of a registered type is made, + but before any initializer and lifestyle specific caching + has been applied, allowing the created to be altered. Multiple delegates + may handle the same service type. + + + + The ExpressionBuilding event is called by the container every time an registered type is + getting compiled, allowing a developer to change the way the type is created. The delegate that + hooks to the ExpressionBuilding event, can change the + property on the + , which allows changing the way the type is constructed. + + + The exact type supplied depends on the type of registration. + Registrations that explicitly supply the implementation type (such as + Register<TService, TImplementation>()) + will result in an , while registrations that take a delegate (such as + Register<TService>(Func<TService>)) + will result in an . Singletons that are passed in using their + value (RegisterSingle<TService>(TService)) + will result in an . Note that other ExpressionBuilding + registrations might have changed the + property and might have supplied an of a different type. The order in + which these events are registered might be of importance to you. + + + Thread-safety: Please note that the container will not ensure that the hooked delegates + are executed only once per service type. While the calls to registered ExpressionBuilding + events for a given type are finite (and will in most cases happen just once), a container can + call the delegate multiple times and make parallel calls to the delegate. You must make sure that + the code can be called multiple times and is thread-safe. + + + + The following example shows the usage of the ExpressionBuilding event: + + { + var expression = e.Expression as NewExpression; + + if (expression != null) + { + var propertiesToInject = + from property in expression.Constructor.DeclaringType.GetProperties() + where property.GetCustomAttributes(typeof(MyInjectPropertyAttribute), true).Any() + let registration = container.GetRegistration(property.PropertyType, true) + select Tuple.Create(property, registration); + + if (propertiesToInject.Any()) + { + Func[], object> injectorDelegate = + (instance, dependencies) => + { + foreach (var dependency in dependencies) + { + dependency.Item1.SetValue(instance, dependency.Item2.GetInstance(), null); + } + + return instance; + }; + + e.Expression = Expression.Convert( + Expression.Invoke( + Expression.Constant(injectorDelegate), + e.Expression, + Expression.Constant(propertiesToInject.ToArray())), + expression.Constructor.DeclaringType); + } + } + }; + } + ]]> + + The example above registers a delegate that is raised every time the container compiles the + expression for an registered type. The delegate checks if the type contains properties that are + decorated with the supplied MyInjectPropertyAttribute. If decorated properties are found, + the given expression is replaced with an expression that injects decorated properties. + + + The example differs from the container's built-in method in that + it will fail when one of the decorated properties can not be injected. The built-in + will look at all properties of a given class and will simply skip + over any properties that can not be injected, making the use of the + method often verify fragile and error prone. + + + + + Implements a cache for implementations. + + is thread-safe can be used over multiple threads concurrently. + + + + + Allows registering an delegate that will be called when the scope ends, + but before the scope disposes any instances. + + + During the call to all registered delegates are + processed in the order of registration. Do note that registered actions are not guaranteed + to run. In case an exception is thrown during the call to , the + will stop running any actions that might not have been invoked at that point. + Instances that are registered for disposal using on the other + hand, are guaranteed to be disposed. Note that registered actions won't be invoked during a call + to . + + The delegate to run when the scope ends. + Thrown when one of the arguments is a null reference + (Nothing in VB). + Thrown when the scope has been disposed. + + + + Adds the to the list of items that will get disposed when the + scope ends. + + + Instances that are registered for disposal, will be disposed in opposite order of registration and + they are guaranteed to be disposed when is called (even when + exceptions are thrown). This mimics the behavior of the C# and VB using statements, + where the method is called inside the finally block. + + The instance that should be disposed when the scope ends. + Thrown when one of the arguments is a null reference + (Nothing in VB). + Thrown when the scope has been disposed. + + + Releases all instances that are cached by the object. + + + + Releases all instances that are cached by the object. + + False when only unmanaged resources should be released. + + + Configuration options for the . + + The following example shows the typical usage of the ContainerOptions class. + (); + + // Use of ContainerOptions class here. + container.Options.AllowOverridingRegistrations = true; + + // Replaces the previous registration of ITimeProvider + container.Register(); + ]]> + + + + Initializes a new instance of the class. + + + + Gets or sets a value indicating whether the container allows overriding registrations. The default + is false. + + The value indicating whether the container allows overriding registrations. + + + + Gets or sets the constructor resolution behavior. By default, the container only supports types + that have a single public constructor. + + The constructor resolution behavior. + Thrown when the supplied value is a null reference. + + Thrown when the container already contains registrations. + + + + + Gets or sets the constructor verification behavior. The container's default behavior is to + disallow constructors with value types and strings. + + The constructor resolution behavior. + Thrown when the supplied value is a null reference. + + Thrown when the container already contains registrations. + + + + Gets or sets the constructor injection behavior. + The constructor injection behavior. + Thrown when the supplied value is a null reference. + + Thrown when the container already contains registrations. + + + + + Gets or sets the property selection behavior. The container's default behavior is to do no + property injection. + + The property selection behavior. + Thrown when the supplied value is a null reference. + + Thrown when the container already contains registrations. + + + + + Gets or sets the lifestyle selection behavior. The container's default behavior is to make + registrations using the lifestyle. + The lifestyle selection behavior. + Thrown when the supplied value is a null reference. + + Thrown when the container already contains registrations. + + + + + Gets the container to which this ContainerOptions instance belongs to or null when + this instance hasn't been applied to a yet. + + The current . + + + + Gets or sets a value indicating whether the container will use dynamic assemblies for compilation. + By default, this value is true for the first few containers that are created in an app + domain and false for all other containers. You can set this value explicitly to false + to prevent the use of dynamic assemblies or you can set this value explicitly to true to + force more container instances to use dynamic assemblies. Note that creating an infinite number + of instances (for instance one per web request) with this property set to + true will result in a memory leak; dynamic assemblies take up memory and will only be + unloaded when the AppDomain is unloaded. + + A boolean indicating whether the container should use a dynamic assembly for compilation. + + + + + Allows verifying whether a given type has a direct or indirect dependency on itself. Verifying is done + by preventing recursive calls to a IInstanceProvider. An instance of this type is related to a single + instance of a IInstanceProvider. A RecursiveDependencyValidator instance checks a single + IInstanceProvider and therefore a single service type. + + + + + Extension methods for the RecursiveDependencyValidator class. + + + + + Provides data for and interaction with the + ExpressionBuilding event of + the . An observer can change the + property to change the component that is + currently being built. + + + + Gets the registered service type that is currently requested. + The registered service type that is currently requested. + + + + Gets the type that is known to be returned by the + Expression (most often the implementation + type used in the Register call). This type will be a derivative of + RegisteredServiceType (or + or RegisteredServiceType itself). If the Expression is changed, the new expression + must also return an instance of type KnownImplementationType or a sub type. + This information must be described in the new Expression. + + A . + + + + Gets the lifestyle for the component that is currently being built. + + The . + + + Gets or sets the currently registered . + The current registration. + Thrown when the supplied value is a null reference. + + + + Gets the collection of currently known relationships. This information is used by the Diagnostics + Debug View. Change the contents of this collection to represent the changes made to the + Expression property (if any). This allows + the Diagnostics Debug View to analyze those new relationships as well. + + The collection of instances. + + + + Provides data for and interaction with the + ExpressionBuilt event of + the . An observer can change the + property to change the component that is currently + being built. + + + + Initializes a new instance of the class. + Type of the registered service. + The registered expression. + + + Gets the registered service type that is currently requested. + The registered service type that is currently requested. + + + Gets or sets the currently registered . + The current registration. + Thrown when the supplied value is a null reference. + + + Gets or sets the current lifestyle of the registration. + The original lifestyle of the registration. + + + + Gets the collection of currently known relationships. This information is used by the Diagnostics + Debug View. Change the contents of this collection to represent the changes made to the + Expression property (if any). This allows + the Diagnostics Debug View to analyze those new relationships as well. + + The collection of instances. + + + + A map containing a generic argument (such as T) and the concrete type (such as Int32) that it + represents. + + + + Implements equality. Needed for doing LINQ distinct operations. + The other to compare to. + True or false. + + + Overrides the default hash code. Needed for doing LINQ distinct operations. + An 32 bit integer. + + + + An instance of this type can be injected into constructors of decorator classes that are registered + using RegisterDecorator. This type contains + contextual information about the applied decoration and it allows users to examine the given instance + to make runtime decisions. + + + + + Gets the closed generic service type for which the decorator is about to be applied. The original + service type will be returned, even if other decorators have already been applied to this type. + + The closed generic service type. + + + + Gets the type of the implementation that is created by the container and for which the decorator + is about to be applied. The original implementation type will be returned, even if other decorators + have already been applied to this type. Please not that the implementation type can not always be + determined. In that case the closed generic service type will be returned. + + The implementation type. + + + + Gets the list of the types of decorators that have already been applied to this instance. + + The applied decorators. + + + + Gets the current object that describes the intention to create a new + instance with its currently applied decorators. + + The current expression that is about to be decorated. + + + + Extension methods for applying decorators. + + + + + Ensures that the supplied decorator is returned and cached with + the given , wrapping the original registered + , by injecting that service type into the constructor of the + supplied . Multiple decorators may be applied to the same + . Decorators can be applied to both open, closed, and non-generic + service types. + + + + The RegisterOpenGenericDecorator method works by hooking onto the container's + ExpressionBuilt event. This event fires after the + ResolveUnregisteredType event, which allows + decoration of types that are resolved using unregistered type resolution. The + RegisterOpenGeneric + extension method, for instance, hooks onto the ResolveUnregisteredType. This allows you to + use RegisterOpenGenericDecorator on the same service type as RegisterOpenGeneric. + + + Multiple decorators can be applied to the same service type. The order in which they are registered + is the order they get applied in. This means that the decorator that gets registered first, gets + applied first, which means that the next registered decorator, will wrap the first decorator, which + wraps the original service type. + + + Constructor injection will be used on that type, and although it may have many constructor + arguments, it must have exactly one argument of the type of , or an + argument of type where TResult is . + An exception will be thrown when this is not the case. + + + The registered may have a constructor with an argument of type + where T is . In this case, the + will not inject the decorated itself into the + instance, but it will inject a that allows + creating instances of the decorated type, according to the lifestyle of that type. This enables + more advanced scenarios, such as executing the decorated types on a different thread, or executing + decorated instance within a certain scope (such as a lifetime scope). + + + + Please see the RegisterDecorator method + for more information. + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the given . + The definition of the open generic decorator type that will + be used to wrap the original service type. + The lifestyle that specifies how the returned decorator will be cached. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type, when does not inherit from or + implement , when + does not have a single public constructor, or when does + not contain a constructor that has exactly one argument of type + or where T is + . + + + + Ensures that the supplied decorator is returned when the supplied + returns true and cached with the given + , wrapping the original registered , by + injecting that service type into the constructor of the supplied . + Multiple decorators may be applied to the same . Decorators can be + applied to both open, closed, and non-generic service types. + + + + The RegisterOpenGenericDecorator method works by hooking onto the container's + ExpressionBuilt event. This event fires after the + ResolveUnregisteredType event, which allows + decoration of types that are resolved using unregistered type resolution. The + RegisterOpenGeneric + extension method, for instance, hooks onto the ResolveUnregisteredType. This allows you to + use RegisterOpenGenericDecorator on the same service type as RegisterOpenGeneric. + + + Multiple decorators can be applied to the same service type. The order in which they are registered + is the order they get applied in. This means that the decorator that gets registered first, gets + applied first, which means that the next registered decorator, will wrap the first decorator, which + wraps the original service type. + + + Constructor injection will be used on that type, and although it may have many constructor + arguments, it must have exactly one argument of the type of , or an + argument of type where TResult is . + An exception will be thrown when this is not the case. + + + The registered may have a constructor with an argument of type + where T is . In this case, the + will not inject the decorated itself into the + instance, but it will inject a that allows + creating instances of the decorated type, according to the lifestyle of that type. This enables + more advanced scenarios, such as executing the decorated types on a different thread, or executing + decorated instance within a certain scope (such as a lifetime scope). + + + + Please see the RegisterDecorator method + for more information. + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the given . + The definition of the open generic decorator type that will + be used to wrap the original service type. + The lifestyle that specifies how the returned decorator will be cached. + The predicate that determines whether the + must be applied to a service type. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type, when does not inherit from or + implement , when + does not have a single public constructor, or when does + not contain a constructor that has exactly one argument of type + or where T is + . + + + + Ensures that the decorator type that is returned from is + supplied when the supplied returns true and cached with the given + , wrapping the original registered , by + injecting that service type into the constructor of the decorator type that is returned by the + supplied . + Multiple decorators may be applied to the same . Decorators can be + applied to both open, closed, and non-generic service types. + + + + The types returned from the may be open-generic. The + container will try to fill in the generic parameters based on the resolved service type. + + + The RegisterOpenGenericDecorator method works by hooking onto the container's + ExpressionBuilt event. This event fires after the + ResolveUnregisteredType event, which allows + decoration of types that are resolved using unregistered type resolution. The + RegisterOpenGeneric + extension method, for instance, hooks onto the ResolveUnregisteredType. This allows you to + use RegisterOpenGenericDecorator on the same service type as RegisterOpenGeneric. + + + Multiple decorators can be applied to the same service type. The order in which they are registered + is the order they get applied in. This means that the decorator that gets registered first, gets + applied first, which means that the next registered decorator, will wrap the first decorator, which + wraps the original service type. + + + Constructor injection will be used on that type, and although it may have many constructor + arguments, it must have exactly one argument of the type of , or an + argument of type where TResult is . + An exception will be thrown when this is not the case. + + + The type returned from may have a constructor with an + argument of type where T is . In this + case, the framework will not inject the decorated itself into the + decorator instance, but it will inject a that allows + creating instances of the decorated type, according to the lifestyle of that type. This enables + more advanced scenarios, such as executing the decorated types on a different thread, or executing + decorated instance within a certain scope (such as a lifetime scope). + + + + The following is an example of the registration of a decorator through the factory delegate: + , MoveCustomerCommandHandler>(); + + container.RegisterDecorator( + typeof(ICommandHandler<>), + context => typeof(LoggingCommandHandler<,>).MakeGenericType( + typeof(LoggingCommandHandler<,>).GetGenericArguments().First(), + context.ImplementationType), + Lifestyle.Transient, + context => true); + + var handler = container.GetInstance>(); + + Assert.IsInstanceOfType(handler, + typeof(LoggingCommandHandler)); + + ]]> + The code above allows a generic LoggingCommandHandler<TCommand, TImplementation> to + be applied to command handlers, where the second generic argument will be filled in using the + contextual information. + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the decorator type returned by the supplied . + A factory that allows building Type objects that define the + decorators to inject, based on the given contextual information. The delegate is allowed to return + open-generic types. + The lifestyle that specifies how the returned decorator will be cached. + The predicate that determines whether the decorator must be applied to a + service type. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type. + + + + Ensures that the supplied decorator is returned, wrapping the + original registered , by injecting that service type into the + constructor of the supplied . Multiple decorators may be applied + to the same . Decorators can be applied to both open, closed, and + non-generic service types. By default, a new instance will be + returned on each request (according the Transient lifestyle), + independently of the lifestyle of the wrapped service. + + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + + The RegisterDecorator method works by hooking onto the container's + ExpressionBuilt event. This event fires after the + ResolveUnregisteredType event, which allows + decoration of types that are resolved using unregistered type resolution. The + RegisterOpenGeneric + extension method, for instance, hooks onto the ResolveUnregisteredType. This allows you to + use RegisterDecorator on the same generic service type as RegisterOpenGeneric. + + + Multiple decorators can be applied to the same service type. The order in which they are registered + is the order they get applied in. This means that the decorator that gets registered first, gets + applied first, which means that the next registered decorator, will wrap the first decorator, which + wraps the original service type. + + + Constructor injection will be used on that type, and although it may have many constructor + arguments, it must have exactly one argument of the type of , or an + argument of type where TResult is . + An exception will be thrown when this is not the case. + + + The registered may have a constructor with an argument of type + where T is . In this case, an decorated + instance will not injected into the , but it will inject a + that allows creating instances of the decorated type, according to the + lifestyle of that type. This enables more advanced scenarios, such as executing the decorated + types on a different thread, or executing decorated instance within a certain scope (such as a + lifetime scope). + + + + The following example shows the definition of a generic ICommandHandler<T> interface, + a CustomerMovedCommandHandler implementing that interface, and a + ValidatorCommandHandlerDecorator<T> that acts as a decorator for that interface. + + { + void Handle(TCommand command); + } + + public class CustomerMovedCommand + { + [Required] + public int CustomerId { get; set; } + + [Required] + public Address Address { get; set; } + } + + public class CustomerMovedCommandHandler + : ICommandHandler + { + public void Handle(CustomerMovedCommand command) + { + // some logic + } + } + + // Decorator that validates commands before they get executed. + public class ValidatorCommandHandlerDecorator + : ICommandHandler + { + private readonly ICommandHandler decoratedHandler; + private readonly Container container; + + public ValidatorCommandHandlerDecorator( + ICommandHandler decoratedHandler, + Container container) + { + this.decoratedHandler = decoratedHandler; + this.container = container; + } + + public void Handle(TCommand command) + { + this.Validate(command); + + this.decoratedHandler.Handle(command); + } + + private void Validate(TCommand command) + { + var validationContext = + new ValidationContext(command, this.container, null); + + Validator.ValidateObject(command, validationContext); + } + } + + // Decorator that measures the time it takes to execute a command. + public class MonitoringCommandHandlerDecorator + : ICommandHandler + { + private readonly ICommandHandler decoratedHandler; + private readonly ILogger logger; + + public MonitoringCommandHandlerDecorator( + ICommandHandler decoratedHandler, + ILogger logger) + { + this.decoratedHandler = decoratedHandler; + this.logger = logger; + } + + public void Handle(TCommand command) + { + var watch = Stopwatch.StartNew(); + + this.decoratedHandler.Handle(command); + + this.logger.Log(string.Format("{0} executed in {1} ms.", + command.GetType().Name, watch.ElapsedMilliseconds)); + } + } + + [TestMethod] + public static void TestRegisterOpenGenericDecorator() + { + // Arrange + var container = new Container(); + + container.RegisterSingle(); + + // Search the given assembly and register all concrete types that + // implement ICommandHandler. + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), + typeof(ICommandHandler<>).Assembly); + + // Wrap all ICommandHandler service types with a decorator + // that measures and logs the duration of that handler. + container.RegisterDecorator(typeof(ICommandHandler<>), + typeof(MonitoringCommandHandlerDecorator<>)); + + // Wrap all ICommandHandler types (in this case it will + // wrap the monitoring decorator), but only if the TCommand contains + // any properties. + container.RegisterDecorator(typeof(ICommandHandler<>), + typeof(ValidatorCommandHandlerDecorator<>), context => + { + var commandType = context.ServiceType.GetGenericArguments()[0]; + bool mustDecorate = commandType.GetProperties().Any(); + return mustDecorate; + }); + + // Act + var handler = + container.GetInstance>(); + + // Assert + Assert.IsInstanceOfType(handler, + typeof(ValidatorCommandHandlerDecorator)); + } + ]]> + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the given . + The definition of the open generic decorator type that will + be used to wrap the original service type. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type, when does not inherit from or implement + , when does not + have a single public constructor, or when does not + contain a constructor that has exactly one argument of type + or where T is + . + + + + Ensures that the supplied decorator is returned when the supplied + returns true, wrapping the original registered + , by injecting that service type into the constructor of the + supplied . Multiple decorators may be applied to the same + . Decorators can be applied to both open, closed, and non-generic + service types. By default, a new instance will be returned on + each request (according the Transient lifestyle), + independently of the lifestyle of the wrapped service. + + + + This method uses the container's + LifestyleSelectionBehavior to select + the exact lifestyle for the specified type. By default this will be + Transient. + + + The RegisterOpenGenericDecorator method works by hooking onto the container's + ExpressionBuilt event. This event fires after the + ResolveUnregisteredType event, which allows + decoration of types that are resolved using unregistered type resolution. The + RegisterOpenGeneric + extension method, for instance, hooks onto the ResolveUnregisteredType. This allows you to + use RegisterOpenGenericDecorator on the same service type as RegisterOpenGeneric. + + + Multiple decorators can be applied to the same service type. The order in which they are registered + is the order they get applied in. This means that the decorator that gets registered first, gets + applied first, which means that the next registered decorator, will wrap the first decorator, which + wraps the original service type. + + + Constructor injection will be used on that type, and although it may have many constructor + arguments, it must have exactly one argument of the type of , or an + argument of type where TResult is . + An exception will be thrown when this is not the case. + + + The registered may have a constructor with an argument of type + where T is . In this case, the + will not inject the decorated itself into the + instance, but it will inject a that allows + creating instances of the decorated type, according to the lifestyle of that type. This enables + more advanced scenarios, such as executing the decorated types on a different thread, or executing + decorated instance within a certain scope (such as a lifetime scope). + + + + Please see the RegisterDecorator method + for more information. + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the given . + The definition of the open generic decorator type that will + be used to wrap the original service type. + The predicate that determines whether the + must be applied to a service type. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type, when does not inherit from or + implement , when + does not have a single public constructor, or when does + not contain a constructor that has exactly one argument of type + or where T is + . + + + + Ensures that a single instance of the supplied decorator is + returned, wrapping the original registered , by injecting that + service type into the constructor of the supplied . Multiple + decorators may be applied to the same . Decorators can be applied + to both open, closed, and non-generic service types. + + + + This method ensures that a single instance of the supplied is + returned, no matter what the lifestyle of the wrapped service type is. Use with care, because the + wrapped service type will also become a singleton. This method is especially useful when use for + injecting factory methods, which will allow the wrapped service type to get + it's own lifestyle back. + + + + Please see the RegisterDecorator method + for more information. + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the given . + The definition of the open generic decorator type that will + be used to wrap the original service type. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type, when does not inherit from or implement + , when does not + have a single public constructor, or when does not + contain a constructor that has exactly one argument of type + or where T is + . + + + + Ensures that the supplied decorator is returned when the supplied + returns true, wrapping the original registered + , by injecting that service type into the constructor of the + supplied . Multiple decorators may be applied to the same + . Decorators can be applied to both open, closed, and non-generic + service types. + + + + This method ensures that a single instance of the supplied is + returned, no matter what the lifestyle of the wrapped service type is. Use with care, because the + wrapped service type will also become a singleton. This method is especially useful when use for + injecting factory methods, which will allow the wrapped service type to get + it's own lifestyle back. + + + + Please see the RegisterDecorator method + for more information. + + The container to make the registrations in. + The definition of the open generic service type that will + be wrapped by the given . + The definition of the open generic decorator type that will + be used to wrap the original service type. + The predicate that determines whether the + must be applied to a service type. + Thrown when one of the arguments is a null reference. + Thrown when is not + an open generic type, when does not inherit from or + implement , when + does not have a single public constructor, or when does + not contain a constructor that has exactly one argument of type + or where T is + . + + + + An instance of this type will be supplied to the + delegate that is that is supplied to the + RegisterDecorator + overload that takes this delegate. This type contains information about the decoration that is about + to be applied and it allows users to examine the given instance to see whether the decorator should + be applied or not. + + + Please see the + RegisterDecorator + method for more information. + + + + + Gets the closed generic service type for which the decorator is about to be applied. The original + service type will be returned, even if other decorators have already been applied to this type. + + The closed generic service type. + + + + Gets the type of the implementation that is created by the container and for which the decorator + is about to be applied. The original implementation type will be returned, even if other decorators + have already been applied to this type. Please not that the implementation type can not always be + determined. In that case the closed generic service type will be returned. + + The implementation type. + + + + Gets the list of the types of decorators that have already been applied to this instance. + + The applied decorators. + + + + Gets the current object that describes the intention to create a new + instance with its currently applied decorators. + + The current expression that is about to be decorated. + + + + Hooks into the building process and adds a decorator if needed. + + + + + A Registration implements lifestyle based caching for a single service and allows building an + that describes the creation of the service. + + + implementations create a new Registration instance for each registered + service type. s returned from the + BuildExpression method can be intercepted by any event + registered with , have + initializers + applied, and the caching particular to its lifestyle have been applied. Interception using the + Container.ExpressionBuilt will not + be applied in the Registration, but will be applied in . + + See the documentation for an example. + + + + + Initializes a new instance of the class. + + The this that created this registration. + The instance for this registration. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + + + Builds a new with the correct caching (according to the specifications of + its ) applied. + + An . + + + + Gets the list of instances. Note that the list is only available + after calling . + + A new array containing the instances. + + + + Initializes an already created instance and applies properties and initializers to that instance. + + + This method is especially useful in integration scenarios where the given platform is in control + of creating certain types. By passing the instance created by the platform to this method, the + container is still able to apply any properties (as defined using a custom + ) and by applying any initializers. + + The instance to initialize. + Thrown when is a null reference + (Nothing in VB). + Thrown when the supplied is not + of type . + + + + Builds a delegate for the creation of the + using the supplied . The returned might + be intercepted by a + Container.ExpressionBuilding event, + and the will have been wrapped with a delegate that executes the + registered initializers + that are applicable to the given (if any). + + The interface or base type that can be used to retrieve instances. + + The delegate supplied by the user that allows building or creating new instances. + A delegate. + + + + Builds a delegate for the creation of . + The returned might be intercepted by a + Container.ExpressionBuilding event, + and the creation of the will have been wrapped with a + delegate that executes the registered + initializers + that are applicable to the given (if any). + + The interface or base type that can be used to retrieve instances. + The concrete type that will be registered. + A delegate. + + + + Builds an that describes the creation of the + using the supplied . The returned might + be intercepted by a + Container.ExpressionBuilding event, + and the will have been wrapped with a delegate that executes the + registered initializers that are + applicable to the given (if any). + + The interface or base type that can be used to retrieve instances. + + The delegate supplied by the user that allows building or creating new instances. + An . + + + + Builds an that describes the creation of + . The returned might be intercepted + by a Container.ExpressionBuilding + event, and the creation of the will have been wrapped with + a delegate that executes the registered + initializers + that are applicable to the given (if any). + + The interface or base type that can be used to retrieve instances. + The concrete type that will be registered. + An . + + + Gets the type that this instance will create. + The type that this instance will create. + + + Gets the this that created this registration. + The this that created this registration. + + + Gets the instance for this registration. + The instance for this registration. + + + + Helper methods for the extensions. + + + + + Allows retrieving the concrete types of the generic type arguments of that must be used to create a + closed generic implementation of a given open generic implementation, based on on the concrete + arguments of the given closed base type. + + + + + Helper class for building closed generic type for a given open generic type and a closed generic base. + + + + Result of the GenericTypeBuilder. + + + + A open generic type with the concrete arguments that can be used to create a closed generic type. + + + + + Represents the method that will called to register one or multiple concrete non-generic + of the given closed generic type + . + + The service type that needs to be registered. + One or more concrete types that implement the given + . + + + { + foreach (Type implementation in implementations) + { + container.RegisterSingle(implementation); + } + + container.RegisterAll(closedServiceType, implementations); + }; + + container.RegisterManyForOpenGeneric( + typeof(ICommandHandler<>), + registerAsCollectionAsSingletons, + typeof(ICommandHandler<>).Assembly); + ]]> + The BatchRegistrationCallback can be supplied to some overloads of the + RegisterManyForOpenGeneric extension methods. + The default behavior of the RegisterManyForOpenGeneric methods is to register a closed generic + type with the corresponding implementation (and will throw when multiple implementations are found for + a single closed generic service type). The given example overrides this default registration by + registering the found list of implementations (one or more) as collection of singletons for the given + closed generic service type. + + + + Defines the accessibility of the types to search. + This type is not available in Silverlight. + + + Load both public as internal types from the given assemblies. + + + Only load publicly exposed types from the given assemblies. + + + + Provides a set of static (Shared in Visual Basic) methods for registration many concrete types at + once that implement the same open generic service types in the . + + + + + Registers all concrete, non-generic, public and internal types in the given set of + that implement the given + with a transient lifetime. + + The container to make the registrations in. + The definition of the open generic type. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Registers all concrete, non-generic, public and internal types that are located in the given + that implement the given + with a transient lifetime. + + The container to make the registrations in. + The definition of the open generic type. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Registers all concrete, non-generic, public and internal types in the given set of + that implement the given + with the supplied . When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will point at the same registration and return the same instance based on the caching + behavior of the supplied . + + The container to make the registrations in. + The definition of the open generic type. + The lifestyle that will be used for the registration of the types. + A list of assemblies that will be searched. + Thrown when , + , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Registers all concrete, non-generic, public and internal types that are located in the given + that implement the given + with the supplied . When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will point at the same registration and return the same instance based on the caching + behavior of the supplied . + + The container to make the registrations in. + The definition of the open generic type. + The lifestyle that will be used for the registration of the types. + A list of assemblies that will be searched. + Thrown when , + , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Allows registration of all concrete, public and internal, non-generic types that are located in the given set of + that implement the given , + by supplying a delegate, that will be called for each + found closed generic implementation of the given . + + The container to make the registrations in. + The definition of the open generic type. + The delegate that will be called for each found closed generic version of + the given open generic to do the actual registration. + A list of assemblies that will be searched. + Thrown when , + , , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type. + + + + Allows registration of all concrete, public and internal, non-generic types that are located in the given set of + that implement the given , + by supplying a delegate, that will be called for each + found closed generic implementation of the given . + + The container to make the registrations in. + The definition of the open generic type. + The delegate that will be called for each found closed generic version of + the given open generic to do the actual registration. + A list of assemblies that will be searched. + Thrown when , + , , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type. + + + + Registers all concrete, non-generic, public and internal types that are located in the given + that implement the given + with a singleton lifetime. + + The container to make the registrations in. + The definition of the open generic type. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Registers all concrete, non-generic, public and internal types that are located in the given + that implement the given + with a singleton lifetime. + + The container to make the registrations in. + The definition of the open generic type. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Registers all supplied by a closed generic definition of the + given with a transient lifetime. + + The container to make the registrations in. + The definition of the open generic type. + The list of types that must be registered according to the given + definition. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + Thrown when there are multiple types in the given + collection that implement the same closed version of the + supplied . + + + + + Registers all supplied by a closed generic definition of the + given with a transient lifetime. + + The container to make the registrations in. + The definition of the open generic type. + The list of types that must be registered according to the given + definition. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + Thrown when there are multiple types in the given + collection that implement the same closed version of the + supplied . + + + + + Allows registration of all supplied by a closed generic + definition of the given , by supplying a + delegate, that will be called for each found closed generic + implementation. + If the list contains open generic types, matching closed generic versions of each open generic + type will be added to the list of implementations that is passed on to the + delegate. + + The container to make the registrations in. + The definition of the open generic type. + The delegate that will be called for each found closed generic version of + the given open generic to do the actual registration. + The list of types that must be registered according to the given + definition. + Thrown when , + , , or + contain a null reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + + + + Registers all supplied by a closed generic definition of the + given with a singleton lifetime. + When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will return the exact same instance. + + The container to make the registrations in. + The definition of the open generic type. + The list of types that must be registered according to the given + definition. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + Thrown when there are multiple types in the given + collection that implement the same closed version of the + supplied . + + + + + Registers all supplied by a closed generic definition of the + given with the supplied . + When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will return the exact same instance. + + The container to make the registrations in. + The definition of the open generic type. + The lifestyle the registrations are made in. + The list of types that must be registered according to the given + definition. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + Thrown when there are multiple types in the given + collection that implement the same closed version of the + supplied . + + + + + Registers all supplied by a closed generic definition of the + given with a singleton lifetime. + When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will return the exact same instance. + + The container to make the registrations in. + The definition of the open generic type. + The list of types that must be registered according to the given + definition. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + Thrown when there are multiple types in the given + collection that implement the same closed version of the + supplied . + + + + + Registers all supplied by a closed generic definition of the + given with the supplied + When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will return the exact same instance. + + The container to make the registrations in. + The definition of the open generic type. + The lifestyle the registrations are made in. + The list of types that must be registered according to the given + definition. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when contains a null + (Nothing in VB) element, when the is not an open generic + type, or one of the types supplied in does not implement a + closed version of . + + Thrown when there are multiple types in the given + collection that implement the same closed version of the + supplied . + + + + + Registers all concrete, non-generic types with the given + that are located in the given that implement the given + with a transient lifetime. + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + Thrown when the given set of + contain multiple types that implement the same closed generic + version of the given . + + + + Registers all concrete, non-generic types with the given + that are located in the given that implement the given + with a transient lifetime. + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type or when the argument contains an invalid + value. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Registers all concrete, non-generic types with the given + that are located in the given that implement the given + with the supplied . + When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will point at the same registration and return the same instance based on the caching + behavior of the supplied . + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + The lifestyle that will be used for the registration of the types. + A list of assemblies that will be searched. + Thrown when , + , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + Thrown when the given set of + contain multiple types that implement the same closed generic + version of the given . + + + + Registers all concrete, non-generic types with the given + that are located in the given that implement the given + with the supplied . + When a found type implements multiple + closed-generic versions of the given , both closed-generic + service types will point at the same registration and return the same instance based on the caching + behavior of the supplied . + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + The lifestyle that will be used for the registration of the types. + A list of assemblies that will be searched. + Thrown when , + , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Allows registration of all concrete, non-generic types with the given + that are located in the given set of + that implement the given , by supplying a + delegate, that will be called for each found closed generic + implementation of the given . + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + The delegate that will be called for each found closed generic version of + the given open generic to do the actual registration. + A list of assemblies that will be searched. + Thrown when , + , , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + + + + Allows registration of all concrete, non-generic types with the given + that are located in the given set of + that implement the given , by supplying a + delegate, that will be called for each found closed generic + implementation of the given . + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + The delegate that will be called for each found closed generic version of + the given open generic to do the actual registration. + A list of assemblies that will be searched. + Thrown when , + , , or + contain a null reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + + + + Registers all concrete, non-generic types with the given + that are located in the given that implement the given + with a singleton lifetime. + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + Thrown when the given set of + contain multiple types that implement the same closed generic + version of the given . + + + + Registers all concrete, non-generic types with the given + that are located in the given that implement the given + with a singleton lifetime. + + This method is not available in Silverlight. + The container to make the registrations in. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + Thrown when , + , or contain a null + reference (Nothing in VB). + Thrown when is not + an open generic type or when contains an invalid value. + Thrown when the given set of + contain multiple types that implement the same + closed generic version of the given . + + + + Returns all types that are located in the supplied + and implement or inherit from the supplied . + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), AccessibilityOption.PublicTypesOnly, + typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the + registration. + + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + A list of types. + Thrown when + contains an invalid value. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all types that are located in the supplied + and implement or inherit from the supplied . + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), AccessibilityOption.PublicTypesOnly, + typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the registration. + + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + A list of types. + Thrown when + contains an invalid value. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all types that are located in the supplied + and implement or inherit from the supplied . + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), AccessibilityOption.PublicTypesOnly, + typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the + registration. + + The container to use. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + A list of types. + Thrown when + contains an invalid value. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all types that are located in the supplied + and implement or inherit from the supplied . + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), AccessibilityOption.PublicTypesOnly, + typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the registration. + + The container to use. + The definition of the open generic type. + Defines which types should be used from the given assemblies. + A list of assemblies that will be searched. + A list of types. + Thrown when + contains an invalid value. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all public and internal types that are located in the supplied + and implement or inherit from the supplied . + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the + registration. + + The definition of the open generic type. + A list of assemblies that will be searched. + A list of types. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all public and internal types that are located in the supplied + and implement or inherit from the supplied . + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the registration. + + The definition of the open generic type. + A list of assemblies that will be searched. + A list of types. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all public and internal types that are located in the supplied + and implement or inherit from the supplied . + Types that are considered to be decorators are not returned. + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the + registration. + + The container to use. + The definition of the open generic type. + A list of assemblies that will be searched. + A list of types. + Thrown when , or + contain a null reference (Nothing in VB). + + + + Returns all public and internal types that are located in the supplied + and implement or inherit from the supplied . + Types that are considered to be decorators are not returned. + + + Use this method when you need influence the types that are registered using + RegisterManyForOpenGeneric. + The RegisterManyForOpenGeneric overloads that take a collection of + objects use this method to get the list of types that need to be registered. Instead of calling + such overload, you can call an overload that takes a list of objects and pass + in a filtered result from this GetTypesToRegister method. + ), typeof(ICommandHandler<>).Assembly) + .Where(type => !type.Name.EndsWith("Decorator")); + + container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), types); + ]]> + This example calls the GetTypesToRegister method to request a list of concrete implementations + of the ICommandHandler<T> interface from the assembly of that interface. After that + all types which name ends with 'Decorator' are filtered out. This list is supplied to an + RegisterManyForOpenGeneric + overload that takes a list of types to finish the registration. + + The container to use. + The definition of the open generic type. + A list of assemblies that will be searched. + A list of types. + Thrown when , or + contain a null reference (Nothing in VB). + + + + An instance of this type will be supplied to the + delegate that is that is supplied to the + RegisterOpenGeneric + overload that takes this delegate. This type contains information about the open generic service that is about + to be created and it allows the user to examine the given instance to decide whether this implementation should + be created or not. + + + Please see the + RegisterOpenGeneric + method for more information. + + + + Gets the closed generic service type that is to be created. + The closed generic service type. + + + Gets the closed generic implementation type that will be created by the container. + The implementation type. + + + Gets a value indicating whether a previous RegisterOpenGeneric registration has already + been applied for the given . + The indication whether the event has been handled. + + + + Provides a set of static (Shared in Visual Basic) methods for registration of open generic service + types in the . + + + + + Registers that a new instance of will be returned + every time a is requested. + + + Please see the + RegisterOpenGeneric(Container,Type,Type,Lifestyle) + overload for an example. + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances. + The definition of the open generic implementation type + that will be returned when a is requested. + + + + Registers that the same instance of will be returned + every time a is requested. + + + Please see the + RegisterOpenGeneric(Container,Type,Type,Lifestyle) + overload for an example. + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances.. + The definition of the open generic implementation type + that will be returned when a is requested. + + + + Registers that a closed generic instance of the supplied + will be returned when a closed generic version of + the is requested. The instance will be cached + according to the specified . + + + Types registered using the RegisterOpenGeneric are resolved using unregistered type + resolution. This means that an explicit registration made for a closed generic version of the + always gets resolved first and the given + only gets resolved when there is no such registration. + + + The following example shows the definition of a generic IValidator<T> interface + and, a NullValidator<T> implementation and a specific validator for Orders. + The registration ensures a OrderValidator is returned when a + IValidator<Order> is requested. For all requests for a + IValidator<T> other than a IValidator<Order>, an + implementation of NullValidator<T> will be returned. + + { + void Validate(T instance); + } + + public class NullValidator : IValidator + { + public void Validate(T instance) + { + } + } + + public class OrderValidator : IValidator + { + public void Validate(Order instance) + { + if (instance.Total < 0) + { + throw new ValidationException("Total can not be negative."); + } + } + } + + [TestMethod] + public static void TestRegisterOpenGeneric() + { + // Arrange + var container = new Container(); + + container.Register, OrderValidator>(Lifestyle.Transient); + container.RegisterOpenGeneric(typeof(IValidator<>), typeof(NullValidator<>), Lifestyle.Singleton); + + // Act + var orderValidator = container.GetInstance>(); + var customerValidator = container.GetInstance>(); + var productValidator = container.GetInstance>(); + + // Assert + Assert.IsInstanceOfType(orderValidator, typeof(OrderValidator)); + Assert.IsInstanceOfType(customerValidator, typeof(NullValidator)); + Assert.IsInstanceOfType(productValidator, typeof(NullValidator)); + } + ]]> + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances. + The definition of the open generic implementation type + that will be returned when a is requested. + The lifestyle that defines how returned instances are cached. + + + + Registers that the same instance of will be returned + every time a is requested. + + + Please see the + RegisterOpenGeneric(Container,Type,Type,Lifestyle) + overload for an example. + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances.. + The definition of the open generic implementation type + that will be returned when a is requested. + The lifestyle that defines how returned instances are cached. + The predicate that determines whether the + can implement the service type. + + + + Registers that instances of will be returned + when a collection of is requested. New instances of + the registered will be returned whenever the + resolved collection is iterated. + + + Please see the + RegisterAllOpenGeneric(Container,Type,Lifestyle,IEnumerable<Type>) + overload for an example. + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances. + The list of open generic implementation types + that will be returned when a collection of is requested. + + + + + Registers that instances of will be returned + when a collection of is requested. New instances of + the registered will be returned whenever the + resolved collection is iterated. + + + Please see the + RegisterAllOpenGeneric(Container,Type,Lifestyle,IEnumerable<Type>) + overload for an example. + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances. + The list of open generic implementation types + that will be returned when a collection of is requested. + + + + + Registers that instances of will be returned + when a collection of is requested. The instances will be + cached according to the specified . + + + Please see the + RegisterAllOpenGeneric(Container,Type,Lifestyle,IEnumerable<Type>) + overload for an example. + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances. + The lifestyle that defines how returned instances are cached. + The list of open generic implementation types + that will be returned when a collection of is requested. + + + + + Registers that instances of will be returned + when a collection of is requested. The instances will be + cached according to the specified . + + + + Collections registered using the RegisterAllOpenGeneric are resolved using unregistered type + resolution. This means that an explicit registration made for a collection of the closed generic + version of the always gets resolved first and a + collection of only gets resolved when there is no + such registration. + + + + The following example shows the definition of a generic IValidator<T> interface + and, a NullValidator<T> implementation and a specific validator for Orders. + The registration ensures a OrderValidator is returned when a + IValidator<Order> is requested. For all requests for a + IValidator<T> other than a IValidator<Order>, an + implementation of NullValidator<T> will be returned. + + { + void Validate(T instance); + } + + public class DefaultValidator : IValidator + { + public void Validate(T instance) + { + // some default validation + } + } + + [TestMethod] + public static void TestRegisterAllOpenGeneric() + { + // Arrange + var container = new Container(); + + Type[] types = new[] { typeof(OrderValidator), typeof(DefaultValidator<>) }; + + container.RegisterManyForOpenGeneric(typeof(IValidator<>), + (serviceType, implementationTypes) => container.RegisterAll(serviceType, implementationTypes), + types); + + container.RegisterAllOpenGeneric(typeof(IValidator<>), typeof(DefaultValidator<>)); + + // Act + var orderValidators = container.GetAllInstances>(); + var customerValidators = container.GetAllInstances>(); + + // Assert + Assert.IsTrue(orderValidators.SequenceEqual( + new[] { typeof(OrderValidator), typeof(DefaultValidator) })); + + // Without the call to RegisterAllOpenGeneric this customerValidators would be empty. + Assert.IsTrue(customerValidators.SequenceEqual(new[] { typeof(DefaultValidator) })); + } + ]]> + + The container to make the registrations in. + The definition of the open generic service type that can be + used to retrieve instances. + The lifestyle that defines how returned instances are cached. + The list of open generic implementation types + that will be returned when a collection of is requested. + + + + Resolves a given open generic type. + + + + Allows validating an ArgumentMapping. + + + + + Helper methods for the container. + + + + + Produces instances for a given registration. Instances of this type are generally created by the + container when calling one of the Register overloads. Instances can be retrieved by calling + or . + + + The Register method overloads create InstanceProducer instances internally, but + InstanceProducers can be created manually to implement special scenarios. An + InstanceProducer wraps instance. The Registration builds an + that describes the intend to create the instance according to a certain + lifestyle. The InstanceProducer on the other hand transforms this Expression to a + delegate and allows the actual instance to be created. A Registration itself can't create any + instance. The InsanceProducer allows intercepting created instances by hooking onto the + Container.ExpressionBuilt event. The + RegisterDecorator + extension methods for instance work by hooking onto the ExpressionBuilt event and allow + wrapping the returned instance with a decorator. + + + The following example shows the creation of two different InstanceProducer instances that wrap + the same Registration instance. Since the Registration is created using the + Singleton lifestyle, both producers will return + the same instance. The InstanceProducer for the Interface1 however, will wrap that + instance in a (transient) Interface1Decorator. + (container); + + var producer1 = new InstanceProducer(typeof(Interface1), registration); + var producer2 = new InstanceProducer(typeof(Interface2), registration); + + container.RegisterDecorator(typeof(Interface1), typeof(Interface1Decorator)); + + var instance1 = (Interface1)producer1.GetInstance(); + var instance2 = (Interface2)producer2.GetInstance(); + + Assert.IsInstanceOfType(instance1, typeof(Interface1Decorator)); + Assert.IsInstanceOfType(instance2, typeof(ServiceImpl)); + + Assert.AreSame(((Interface1Decorator)instance1).DecoratedInstance, instance2); + ]]> + + + + Initializes a new instance of the class. + The service type for which this instance is created. + The . + + + Produces an instance. + An instance. Will never return null. + When the instance could not be retrieved or is null. + + + + Builds an expression that expresses the intent to get an instance by the current producer. A call + to this method locks the container. No new registrations can't be made after a call to this method. + + An Expression. + + + + Gets the collection of relationships for this instance that the container knows about. + This includes relationships between the registered type and its dependencies and relationships + between applied decorators and their dependencies. Note that types that are not newed up by the + container, property dependencies that are injected using the (legacy) + InjectProperties method, and + properties that are injected inside a custom delegate that is registered using the + RegisterInitializer method are unknown + to the container and are not returned from this method. + Also note that this method will return an empty collection when called before the the + registered type is requested from the container (or before Verify + is called). + + An array of instances. + + + + Builds a string representation of the object graph with the current instance as root of the + graph. + + A string representation of the object graph. + Thrown when this method is called before + or have been called. These calls can be + done directly and explicitly by the user on this instance, indirectly by calling + or on an instance that depends on this + instance, or by calling Verify on the container. + + + + Gets the for this registration. The returned lifestyle can differ from the + lifestyle that is used during the registration. This can happen for instance when the registration + is changed by an ExpressionBuilt registration or + gets decorated. + + The for this registration. + + + Gets the service type for which this producer produces instances. + A instance. + + + Gets the instance for this instance. + The . + + + + Factory for the creation of a delegate that applies caching to the supplied + . + + A factory for creating new instances. + A factory that returns cached instances. + + + + Instances returned from the container can be cached. The contains several + overloads of the Register method that take a Lifestyle instance as argument to define + how returned instances should be cached. The core library contains two lifestyles out of the box. By + supplying Lifestyle.Transient, the registered instance is not + cached; a new instance is returned every time it is requested or injected. By supplying + Lifestyle.Singleton instances can be cached indefinitely; only + a single instance of the registered component will be returned by that container instance. Other + lifestyles are defined in integration and extension packages. The + CreateCustom method allows defining a custom lifestyle and + the CreateHybrid method + allows creating a lifestyle that mixes multiple other lifestyles. + + + This type is abstract and can be overridden to implement a custom lifestyle. + + + + + The lifestyle instance that doesn't cache instances. A new instance of the specified + component is created every time the registered service it is requested or injected. + + + The following example registers the SomeServiceImpl implementation for the + ISomeService service type using the Transient lifestyle: + (Lifestyle.Transient); + ]]> + Note that Transient is the default lifestyle, the previous registration can be reduced to + the following: + (); + ]]> + + + + + The lifestyle that caches components during the lifetime of the instance + and guarantees that only a single instance of that component is created for that instance. Since + general use is to create a single Container instance for the lifetime of the application / + AppDomain, this would mean that only a single instance of that component would exist during the + lifetime of the application. In a multi-threaded applications, implementations registered using + this lifestyle must be thread-safe. + + + The following example registers the RealTimeProvider implementation for the + ITimeProvider service type using the Singleton lifestyle: + (Lifestyle.Singleton); + ]]> + Note that using the + RegisterSingle method has + the same effect: + (); + ]]> + + + + Initializes a new instance of the class. + The user friendly name of this lifestyle. + Thrown when is null (Nothing in VB) + or an empty string. + + + + The hybrid lifestyle allows mixing two lifestyles in a single registration. Based on the supplied + delegate the hybrid lifestyle will redirect the creation of + the instance to the correct lifestyle. The result of the + delegate will not be cached; it is invoked each time an instance is requested or injected. By + nesting hybrid lifestyles, any number of lifestyles can be mixed. + + The delegate that determines which + lifestyle should be used. The will be used if true is + returned; the otherwise. This delegate will be called every + time an instance needs to be resolved or injected. + The lifestyle to use when + returns true. + The lifestyle to use when + returns false. + A new hybrid lifestyle that wraps the supplied lifestyles. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + + The following example shows the creation of a HybridLifestyle that mixes an + WebRequestLifestyle and LifetimeScopeLifestyle: + + HttpContext.Current != null, + new WebRequestLifestyle(), + new LifetimeScopeLifestyle()); + + // The created lifestyle can be reused for many registrations. + container.Register(mixedScopeLifestyle); + container.Register(mixedScopeLifestyle); + ]]> + + Hybrid lifestyles can be nested: + + container.GetCurrentLifetimeScope() != null, + new LifetimeScopeLifestyle(), + Lifestyle.Transient); + + var mixedScopeLifestyle = Lifestyle.CreateHybrid( + () => HttpContext.Current != null, + new WebRequestLifestyle(), + mixedLifetimeTransientLifestyle); + ]]> + + The mixedScopeLifestyle now mixed three lifestyles: Web Request, Lifetime Scope and + Transient. + + + + + + The hybrid lifestyle allows mixing two lifestyles in a single registration. Based on the supplied + delegate the hybrid lifestyle will redirect the creation of + the instance to the correct lifestyle. The result of the + delegate will not be cached; it is invoked each time an instance is requested or injected. By + nesting hybrid lifestyles, any number of lifestyles can be mixed. + + The delegate that determines which + lifestyle should be used. The will be used if true is + returned; the otherwise. This delegate will be called every + time an instance needs to be resolved or injected. + The scoped lifestyle to use when + returns true. + The scoped lifestyle to use when + returns false. + A new scoped hybrid lifestyle that wraps the supplied lifestyles. + Thrown when one of the supplied arguments is a null + reference (Nothing in VB). + + + The following example shows the creation of a HybridLifestyle that mixes an + WebRequestLifestyle and LifetimeScopeLifestyle: + + HttpContext.Current != null, + new WebRequestLifestyle(), + new LifetimeScopeLifestyle()); + + // The created lifestyle can be reused for many registrations. + container.Register(mixedScopeLifestyle); + container.Register(mixedScopeLifestyle); + ]]> + + + + + Creates a custom lifestyle using the supplied delegate. + + + The supplied will be called just once per registered + service. The supplied will be called by the framework + when the type is resolved for the first time, and the framework will supply the factory with a + Func<object> for creating new (transient) instances of that type (that might + have been intercepted and + initializers might have been applied). + It is the job of the to return a Func<object> + that applies the proper caching. The Func<object> that is returned by the + will be stored for that registration (every + registration will store its own Func<object> delegate) and this delegate will be + called every time the service is resolved (by calling + container.GetInstance<TService> or when that service is injected into another + type). + + The name of the lifestyle to create. The name is used to display the lifestyle + in the debugger. + A factory delegate that takes a Func<object> delegate + that will produce a transient instance and returns a delegate that returns cached instances. + A new . + Thrown when one of the arguments is a null reference + (Nothing in VB). + Thrown when is an empty string. + + The following example shows the creation of a lifestyle that caches registered instances for 10 + minutes: + + { + TimeSpan timeout = TimeSpan.FromMinutes(10); + var syncRoot = new object(); + var expirationTime = DateTime.MinValue; + object instance = null; + + // If the application has multiple registrations using this lifestyle, each registration + // will get its own Func delegate (created here) and therefore get its own set + // of variables as defined above. + return () => + { + lock (syncRoot) + { + if (expirationTime < DateTime.UtcNow) + { + instance = instanceCreator(); + expirationTime = DateTime.UtcNow.Add(timeout); + } + + return instance; + } + }; + }); + + var container = new Container(); + + // We can reuse the created lifestyle for multiple registrations. + container.Register(customLifestyle); + container.Register(customLifestyle); + ]]> + + + + + Creates a new instance for the given + that will create new instances of specified with the + caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be created. + The instance for which a + must be created. + A new instance. + Thrown when is a null + reference (Nothing in VB). + + + + Creates a new instance for the given + that will create new instances instance using the supplied + with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + A delegate that will create a new instance of + every time it is called. + The instance for which a + must be created. + A new instance. + Thrown when either or + are null references (Nothing in VB). + + + + Creates a new instance for the given + that will create new instances of specified with the + caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + The instance for which a + must be created. + A new instance. + Thrown when on of the supplied arguments is a null + reference (Nothing in VB). + + + + Creates a new instance defining the creation of the + specified with the caching as specified by this lifestyle. + + The concrete type that will be registered. + The instance for which a + must be created. + A new instance. + Thrown when is a null + reference (Nothing in VB). + + + + Creates a new instance defining the creation of the + specified with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be created. + The instance for which a + must be created. + A new instance. + Thrown when is a null + reference (Nothing in VB). + + + + Creates a new instance defining the creation of the + specified using the supplied + with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + A delegate that will create a new instance of + every time it is called. + The instance for which a + must be created. + A new instance. + Thrown when either or + are null references (Nothing in VB). + + + + Creates a new instance defining the creation of the + specified with the caching as specified by this lifestyle. + This method might fail when run in a partial trust sandbox when + is an internal type. + + The concrete type that will be registered. + The instance for which a + must be created. + A new instance. + Thrown when on of the supplied arguments is a null + reference (Nothing in VB). + + + + Creates a new instance defining the creation of the + specified with the caching as specified by this lifestyle. + This method might fail when run in a partial trust sandbox when + is an internal type. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + The instance for which a + must be created. + A new instance. + Thrown when on of the supplied arguments is a null + reference (Nothing in VB). + + + + Creates a new instance defining the creation of the + specified using the supplied + with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + The delegate that will be responsible for creating new instances. + The instance for which a + must be created. + A new instance. + Thrown when on of the supplied arguments is a null + reference (Nothing in VB). + + + + When overridden in a derived class, + creates a new instance defining the creation of the + specified with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + The instance for which a + must be created. + A new instance. + + If you are implementing your own lifestyle, override this method to implement the code necessary + to create and return a new . Note that you should always create + a new instance. They should never be cached. + + + + + When overridden in a derived class, + creates a new instance defining the creation of the + specified using the supplied + with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + A delegate that will create a new instance of + every time it is called. + The instance for which a + must be created. + A new instance. + + If you are implementing your own lifestyle, override this method to implement the code necessary + to create and return a new . Note that you should always create + a new instance. They should never be cached. + + + + Gets the user friendly name of this lifestyle. + The user friendly name of this lifestyle. + + + + Gets the length of the lifestyle. Implementers must implement this property. The diagnostic + services use this value to compare lifestyles with each other to determine lifestyle + misconfigurations. + + The representing the length of this lifestyle. + + + + Forwards CreateRegistration calls to the lifestyle that is returned from the registered + container.Options.LifestyleSelectionBehavior. + + + + + Base class for scoped lifestyles. A scoped lifestyle caches instances for the duration of an implicitly + or explicitly defined scope. Such scope can be an (implicitly defined) web request or an explicitly + defined Lifetime Scope. The lifetime of instances registered with a scoped lifestyle is always equal + or bigger than one-instance-per-object-graph. In other words, a call to GetInstance() will never create + more than one instance of such registered type. + + + + Initializes a new instance of the class. + The user friendly name of this lifestyle. + Thrown when is null (Nothing in VB) + or an empty string. + + + Initializes a new instance of the class. + The user friendly name of this lifestyle. + Signals the lifestyle whether instances should be + disposed or not. + Thrown when is null (Nothing in VB) + or an empty string. + + + + Allows registering an delegate that will be called when the scope ends, + but before the scope disposes any instances. + + + During the call to all registered delegates are + processed in the order of registration. Do note that registered actions are not guaranteed + to run. In case an exception is thrown during the call to , the + will stop running any actions that might not have been invoked at that point. + Instances that are registered for disposal using on the other + hand, are guaranteed to be disposed. Note that registered actions won't be invoked during a call + to . + + The instance. + The delegate to run when the scope ends. + Thrown when one of the arguments is a null reference + (Nothing in VB). + Will be thrown when there is currently no active + scope for the supplied . + + + + Adds the to the list of items that will get disposed when the + scope ends. + + + Note to implementers: Instances registered for disposal will have to be disposed in the opposite + order of registration, since disposable components might still need to call disposable dependencies + in their Dispose() method. + + The instance. + The instance that should be disposed when the scope ends. + Thrown when one of the arguments is a null reference + (Nothing in VB). + Will be thrown when there is currently no active + scope for the supplied . + + + + Returns the current for this lifestyle and the given + , or null when this method is executed outside the context of a scope. + + The container instance that is related to the scope to return. + A instance or null when there is no scope active in this context. + + + + Creates a delegate that upon invocation return the current for this + lifestyle and the given , or null when the delegate is executed outside + the context of such scope. + + The container for which the delegate gets created. + A delegate. This method never returns null. + + + + Returns the current for this lifestyle and the given + , or null when this method is executed outside the context of a scope. + + The container instance that is related to the scope to return. + A instance or null when there is no scope active in this context. + + + + Creates a new instance defining the creation of the + specified using the supplied + with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + A delegate that will create a new instance of + every time it is called. + The instance for which a + must be created. + A new instance. + + + + Creates a new instance defining the creation of the + specified with the caching as specified by this lifestyle. + + The interface or base type that can be used to retrieve the instances. + The concrete type that will be registered. + The instance for which a + must be created. + A new instance. + + + + Disposes the list of supplied . The list is iterated in reverse + order (the first element in the list will be disposed last) and the method ensures that the + Dispose method of each element is called, regardless of any exceptions raised from any previously + called Dispose methods. If multiple exceptions are thrown, the last thrown exception will bubble + up the call stack. + + The list of objects to be disposed. + Thrown when the is a null + reference. + + + Internal helper for string resources. + + + + Provides data for and interaction with the + ResolveUnregisteredType event of + the . An observer can check the + to see whether the unregistered type can be handled. The + method can be called to register a delegate + that allows creation of instances of the unregistered for this and future requests. + + + + Initializes a new instance of the UnregisteredTypeEventArgs class. + The unregistered service type. + + + + Registers a delegate that allows creation of instances of the type + expressed by the for this and future requests. The delegate + will be caches and future requests will directly call that delegate. + + The delegate that allows creation of instances of the type + expressed by the . + Thrown when the is a + null reference. + Thrown when multiple observers that have registered to + the ResolveUnregisteredType event + called this method for the same type. + + + + Registers an that describes the creation of instances of the type + expressed by the for this and future requests. The delegate + will be cached and future requests will directly use that expression or the compiled delegate. + + + NOTE: If possible, use the Register(Registration) overload, + since this allows the analysis services to determine any configuration errors on the lifestyle of + the registration. + + The expression that describes the creation of instances of the type + expressed by the . + Thrown when the is a + null reference. + Thrown when multiple observers that have registered to + the ResolveUnregisteredType event + called this method for the same type. + + + + Registers a that describes the creation of instances of the type + expressed by the for this and future requests. The + registration will be cached and future requests will directly call unon that registration, the + expression that it generates or the delegate that gets compiled from that expression. + + The registration that describes the creation of instances according to + the registration's lifestyle of the type expressed by the . + Thrown when the is a + null reference. + Thrown when the is a + not exactly of type where T equals the . + + Thrown when multiple observers that have registered to + the ResolveUnregisteredType event + called this method for the same type. + + + Gets the unregistered service type that is currently requested. + The unregistered service type that is currently requested. + + + + Gets a value indicating whether the event represented by this instance has been handled. + This property will return true when has been called on + this instance. + + The indication whether the event has been handled. + + + + This class is for internal use only. + + + + Gets or sets the value. + The value. + + + diff --git a/packages/repositories.config b/packages/repositories.config index c80dc44..f2cd2cf 100644 --- a/packages/repositories.config +++ b/packages/repositories.config @@ -1,10 +1,11 @@ - - - - - - - - - + + + + + + + + + + \ No newline at end of file