From 295b584969897ccc9e1bc3ee33bf25acba8d575f Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Mon, 19 Aug 2019 16:36:26 +0200 Subject: [PATCH] Added integration packages for Autofac, Castle Windsor, Ninject and Unity IoC containers First example shows the various implementations --- .../01-PublishSubscribe.csproj | 8 + Examples/01-PublishSubscribe/Program.cs | 93 ++++++++++- Tapeti.Autofac/AutofacDependencyResolver.cs | 148 ++++++++++++++++++ Tapeti.Autofac/Tapeti.Autofac.csproj | 16 ++ Tapeti.Autofac/Tapeti.Autofac.nuspec | 24 +++ .../Tapeti.CastleWindsor.csproj | 16 ++ .../Tapeti.CastleWindsor.nuspec | 24 +++ .../WindsorDependencyResolver.cs | 98 ++++++++++++ Tapeti.Ninject/NinjectDependencyResolver.cs | 89 +++++++++++ Tapeti.Ninject/Tapeti.Ninject.csproj | 16 ++ Tapeti.Ninject/Tapeti.Ninject.nuspec | 24 +++ .../Tapeti.UnityContainer.csproj | 16 ++ .../Tapeti.UnityContainer.nuspec | 24 +++ .../UnityDependencyResolver.cs | 89 +++++++++++ Tapeti.sln | 45 +++++- appveyor.yml | 18 ++- docs/gettingstarted.rst | 13 +- 17 files changed, 749 insertions(+), 12 deletions(-) create mode 100644 Tapeti.Autofac/AutofacDependencyResolver.cs create mode 100644 Tapeti.Autofac/Tapeti.Autofac.csproj create mode 100644 Tapeti.Autofac/Tapeti.Autofac.nuspec create mode 100644 Tapeti.CastleWindsor/Tapeti.CastleWindsor.csproj create mode 100644 Tapeti.CastleWindsor/Tapeti.CastleWindsor.nuspec create mode 100644 Tapeti.CastleWindsor/WindsorDependencyResolver.cs create mode 100644 Tapeti.Ninject/NinjectDependencyResolver.cs create mode 100644 Tapeti.Ninject/Tapeti.Ninject.csproj create mode 100644 Tapeti.Ninject/Tapeti.Ninject.nuspec create mode 100644 Tapeti.UnityContainer/Tapeti.UnityContainer.csproj create mode 100644 Tapeti.UnityContainer/Tapeti.UnityContainer.nuspec create mode 100644 Tapeti.UnityContainer/UnityDependencyResolver.cs diff --git a/Examples/01-PublishSubscribe/01-PublishSubscribe.csproj b/Examples/01-PublishSubscribe/01-PublishSubscribe.csproj index e14883b..a2d0d06 100644 --- a/Examples/01-PublishSubscribe/01-PublishSubscribe.csproj +++ b/Examples/01-PublishSubscribe/01-PublishSubscribe.csproj @@ -7,12 +7,20 @@ + + + + + + + + diff --git a/Examples/01-PublishSubscribe/Program.cs b/Examples/01-PublishSubscribe/Program.cs index 75eb7c8..a53b65b 100644 --- a/Examples/01-PublishSubscribe/Program.cs +++ b/Examples/01-PublishSubscribe/Program.cs @@ -1,12 +1,21 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using Autofac; +using Castle.MicroKernel.Registration; +using Castle.Windsor; using ExampleLib; -using SimpleInjector; +using Ninject; using Tapeti; +using Tapeti.Autofac; +using Tapeti.CastleWindsor; using Tapeti.DataAnnotations; using Tapeti.Default; +using Tapeti.Ninject; using Tapeti.SimpleInjector; +using Tapeti.UnityContainer; +using Unity; +using Container = SimpleInjector.Container; namespace _01_PublishSubscribe { @@ -14,12 +23,13 @@ namespace _01_PublishSubscribe { public static void Main(string[] args) { - var container = new Container(); - var dependencyResolver = new SimpleInjectorDependencyResolver(container); - - container.Register(); - container.Register(); + var dependencyResolver = GetSimpleInjectorDependencyResolver(); + // or use your IoC container of choice: + //var dependencyResolver = GetAutofacDependencyResolver(); + //var dependencyResolver = GetCastleWindsorDependencyResolver(); + //var dependencyResolver = GetUnityDependencyResolver(); + //var dependencyResolver = GetNinjectDependencyResolver(); // This helper is used because this example is not run as a service. You do not // need it in your own applications. @@ -53,6 +63,11 @@ namespace _01_PublishSubscribe } }) { + // IoC containers that separate the builder from the resolver (Autofac) must be built after + // creating a TapetConnection, as it modifies the container by injecting IPublisher. + (dependencyResolver as AutofacDependencyResolver)?.Build(); + + // Create the queues and start consuming immediately. // If you need to do some processing before processing messages, but after the // queues have initialized, pass false as the startConsuming parameter and store @@ -69,5 +84,71 @@ namespace _01_PublishSubscribe await waitForDone(); } } + + + internal static IDependencyContainer GetSimpleInjectorDependencyResolver() + { + var container = new Container(); + + container.Register(); + container.Register(); + + return new SimpleInjectorDependencyResolver(container); + } + + + internal static IDependencyContainer GetAutofacDependencyResolver() + { + var containerBuilder = new ContainerBuilder(); + + containerBuilder + .RegisterType() + .As(); + + containerBuilder + .RegisterType() + .AsSelf(); + + return new AutofacDependencyResolver(containerBuilder); + } + + + internal static IDependencyContainer GetCastleWindsorDependencyResolver() + { + var container = new WindsorContainer(); + + // This exact combination is registered by TapetiConfig when running in a console, + // and Windsor will throw an exception for that. This is specific to the WindsorDependencyResolver as it + // relies on the "first one wins" behaviour of Windsor and does not check the registrations. + // + // You can of course register another ILogger instead, like DevNullLogger. + //container.Register(Component.For().ImplementedBy()); + + container.Register(Component.For()); + + return new WindsorDependencyResolver(container); + } + + + internal static IDependencyContainer GetUnityDependencyResolver() + { + var container = new UnityContainer(); + + container.RegisterType(); + container.RegisterType(); + + return new UnityDependencyResolver(container); + } + + + internal static IDependencyContainer GetNinjectDependencyResolver() + { + var kernel = new StandardKernel(); + + kernel.Bind().To(); + kernel.Bind().ToSelf(); + + return new NinjectDependencyResolver(kernel); + } } } diff --git a/Tapeti.Autofac/AutofacDependencyResolver.cs b/Tapeti.Autofac/AutofacDependencyResolver.cs new file mode 100644 index 0000000..cf6cee8 --- /dev/null +++ b/Tapeti.Autofac/AutofacDependencyResolver.cs @@ -0,0 +1,148 @@ +using System; +using Autofac; +using Autofac.Builder; + +namespace Tapeti.Autofac +{ + /// + /// + /// Dependency resolver and container implementation for Autofac. + /// Since this class needs access to both the ContainerBuilder and the built IContainer, + /// either let AutofacDependencyResolver build the container by calling it's Build method, + /// or set the Container property manually. + /// + public class AutofacDependencyResolver : IDependencyContainer + { + private ContainerBuilder containerBuilder; + private IContainer container; + + + /// + /// The built container. Either set directly, or use the Build method to built the + /// update this reference. + /// + public IContainer Container + { + get => container; + set + { + container = value; + if (value != null) + containerBuilder = null; + } + } + + + /// + public AutofacDependencyResolver(ContainerBuilder containerBuilder) + { + this.containerBuilder = containerBuilder; + } + + + /// + /// Builds the container, updates the Container property and returns the newly built IContainer. + /// + public IContainer Build(ContainerBuildOptions options = ContainerBuildOptions.None) + { + CheckContainerBuilder(); + Container = containerBuilder.Build(options); + + return container; + } + + + /// + public T Resolve() where T : class + { + CheckContainer(); + return Container.Resolve(); + } + + /// + public object Resolve(Type type) + { + CheckContainer(); + return Container.Resolve(type); + } + + + /// + public void RegisterDefault() where TService : class where TImplementation : class, TService + { + CheckContainerBuilder(); + containerBuilder + .RegisterType() + .As() + .PreserveExistingDefaults(); + } + + /// + public void RegisterDefault(Func factory) where TService : class + { + CheckContainerBuilder(); + containerBuilder + .Register(context => factory()) + .As() + .PreserveExistingDefaults(); + } + + + /// + public void RegisterDefaultSingleton() where TService : class where TImplementation : class, TService + { + CheckContainerBuilder(); + containerBuilder + .RegisterType() + .As() + .SingleInstance() + .PreserveExistingDefaults(); + } + + /// + public void RegisterDefaultSingleton(TService instance) where TService : class + { + CheckContainerBuilder(); + containerBuilder + .RegisterInstance(instance) + .As() + .SingleInstance() + .PreserveExistingDefaults(); + } + + /// + public void RegisterDefaultSingleton(Func factory) where TService : class + { + CheckContainerBuilder(); + containerBuilder + .Register(context => factory()) + .As() + .SingleInstance() + .PreserveExistingDefaults(); + } + + + /// + public void RegisterController(Type type) + { + CheckContainerBuilder(); + containerBuilder + .RegisterType(type) + .AsSelf(); + } + + + private void CheckContainer() + { + if (container == null) + throw new InvalidOperationException("Container property has not been set yet on AutofacDependencyResolver"); + } + + + private void CheckContainerBuilder() + { + if (containerBuilder == null) + throw new InvalidOperationException("Container property has already been set on AutofacDependencyResolver"); + } + } +} diff --git a/Tapeti.Autofac/Tapeti.Autofac.csproj b/Tapeti.Autofac/Tapeti.Autofac.csproj new file mode 100644 index 0000000..e0100ee --- /dev/null +++ b/Tapeti.Autofac/Tapeti.Autofac.csproj @@ -0,0 +1,16 @@ + + + + netstandard2.0 + true + + + + + + + + + + + diff --git a/Tapeti.Autofac/Tapeti.Autofac.nuspec b/Tapeti.Autofac/Tapeti.Autofac.nuspec new file mode 100644 index 0000000..023ea84 --- /dev/null +++ b/Tapeti.Autofac/Tapeti.Autofac.nuspec @@ -0,0 +1,24 @@ + + + + Tapeti.Autofac + $version$ + Tapeti Autofac + Mark van Renswoude + Mark van Renswoude + https://raw.githubusercontent.com/MvRens/Tapeti/master/UNLICENSE + https://github.com/MvRens/Tapeti + https://raw.githubusercontent.com/MvRens/Tapeti/master/resources/icons/Tapeti.SimpleInjector.png + false + Autofac integration package for Tapeti + + rabbitmq tapeti autofac + + + + + + + + + \ No newline at end of file diff --git a/Tapeti.CastleWindsor/Tapeti.CastleWindsor.csproj b/Tapeti.CastleWindsor/Tapeti.CastleWindsor.csproj new file mode 100644 index 0000000..7ec6d35 --- /dev/null +++ b/Tapeti.CastleWindsor/Tapeti.CastleWindsor.csproj @@ -0,0 +1,16 @@ + + + + netstandard2.0 + true + + + + + + + + + + + diff --git a/Tapeti.CastleWindsor/Tapeti.CastleWindsor.nuspec b/Tapeti.CastleWindsor/Tapeti.CastleWindsor.nuspec new file mode 100644 index 0000000..6486a33 --- /dev/null +++ b/Tapeti.CastleWindsor/Tapeti.CastleWindsor.nuspec @@ -0,0 +1,24 @@ + + + + Tapeti.CastleWindsor + $version$ + Tapeti Castle Windsor + Mark van Renswoude + Mark van Renswoude + https://raw.githubusercontent.com/MvRens/Tapeti/master/UNLICENSE + https://github.com/MvRens/Tapeti + https://raw.githubusercontent.com/MvRens/Tapeti/master/resources/icons/Tapeti.SimpleInjector.png + false + Castle.Windsor integration package for Tapeti + + rabbitmq tapeti castle windsor + + + + + + + + + \ No newline at end of file diff --git a/Tapeti.CastleWindsor/WindsorDependencyResolver.cs b/Tapeti.CastleWindsor/WindsorDependencyResolver.cs new file mode 100644 index 0000000..419d115 --- /dev/null +++ b/Tapeti.CastleWindsor/WindsorDependencyResolver.cs @@ -0,0 +1,98 @@ +using System; +using Castle.MicroKernel.Registration; +using Castle.Windsor; + +namespace Tapeti.CastleWindsor +{ + /// + /// + /// Dependency resolver and container implementation for Castle Windsor. + /// + public class WindsorDependencyResolver : IDependencyContainer + { + private readonly IWindsorContainer container; + + + /// + public WindsorDependencyResolver(IWindsorContainer container) + { + this.container = container; + } + + + /// + public T Resolve() where T : class + { + return container.Resolve(); + } + + /// + public object Resolve(Type type) + { + return container.Resolve(type); + } + + + /// + public void RegisterDefault() where TService : class where TImplementation : class, TService + { + // No need for anything special to register as default, because "In Windsor first one wins": + // https://github.com/castleproject/Windsor/blob/master/docs/registering-components-one-by-one.md + container.Register( + Component + .For() + .ImplementedBy() + ); + } + + /// + public void RegisterDefault(Func factory) where TService : class + { + container.Register( + Component + .For() + .UsingFactoryMethod(() => factory()) + ); + } + + + /// + public void RegisterDefaultSingleton() where TService : class where TImplementation : class, TService + { + container.Register( + Component + .For() + .ImplementedBy() + .LifestyleSingleton() + ); + } + + /// + public void RegisterDefaultSingleton(TService instance) where TService : class + { + container.Register( + Component + .For() + .Instance(instance) + ); + } + + /// + public void RegisterDefaultSingleton(Func factory) where TService : class + { + container.Register( + Component + .For() + .UsingFactoryMethod(() => factory()) + .LifestyleSingleton() + ); + } + + + /// + public void RegisterController(Type type) + { + container.Register(Component.For(type)); + } + } +} diff --git a/Tapeti.Ninject/NinjectDependencyResolver.cs b/Tapeti.Ninject/NinjectDependencyResolver.cs new file mode 100644 index 0000000..7a2ac17 --- /dev/null +++ b/Tapeti.Ninject/NinjectDependencyResolver.cs @@ -0,0 +1,89 @@ +using System; +using System.Linq; +using Ninject; + +namespace Tapeti.Ninject +{ + /// + /// + /// Dependency resolver and container implementation for Ninject. + /// + public class NinjectDependencyResolver : IDependencyContainer + { + private readonly IKernel kernel; + + + /// + public NinjectDependencyResolver(IKernel kernel) + { + this.kernel = kernel; + } + + + /// + public T Resolve() where T : class + { + return kernel.Get(); + } + + /// + public object Resolve(Type type) + { + return kernel.Get(type); + } + + + /// + public void RegisterDefault() where TService : class where TImplementation : class, TService + { + if (kernel.GetBindings(typeof(TService)).Any()) + return; + + kernel.Bind().To(); + } + + /// + public void RegisterDefault(Func factory) where TService : class + { + if (kernel.GetBindings(typeof(TService)).Any()) + return; + + kernel.Bind().ToMethod(context => factory()); + } + + + /// + public void RegisterDefaultSingleton() where TService : class where TImplementation : class, TService + { + if (kernel.GetBindings(typeof(TService)).Any()) + return; + + kernel.Bind().To().InSingletonScope(); + } + + /// + public void RegisterDefaultSingleton(TService instance) where TService : class + { + if (kernel.GetBindings(typeof(TService)).Any()) + return; + + kernel.Bind().ToConstant(instance); + } + + /// + public void RegisterDefaultSingleton(Func factory) where TService : class + { + if (kernel.GetBindings(typeof(TService)).Any()) + return; + + kernel.Bind().ToMethod(context => factory()).InSingletonScope(); + } + + + /// + public void RegisterController(Type type) + { + kernel.Bind(type).ToSelf(); + } + } +} diff --git a/Tapeti.Ninject/Tapeti.Ninject.csproj b/Tapeti.Ninject/Tapeti.Ninject.csproj new file mode 100644 index 0000000..864ff7a --- /dev/null +++ b/Tapeti.Ninject/Tapeti.Ninject.csproj @@ -0,0 +1,16 @@ + + + + netstandard2.0 + true + + + + + + + + + + + diff --git a/Tapeti.Ninject/Tapeti.Ninject.nuspec b/Tapeti.Ninject/Tapeti.Ninject.nuspec new file mode 100644 index 0000000..1a4051f --- /dev/null +++ b/Tapeti.Ninject/Tapeti.Ninject.nuspec @@ -0,0 +1,24 @@ + + + + Tapeti.Ninject + $version$ + Tapeti Ninject + Mark van Renswoude + Mark van Renswoude + https://raw.githubusercontent.com/MvRens/Tapeti/master/UNLICENSE + https://github.com/MvRens/Tapeti + https://raw.githubusercontent.com/MvRens/Tapeti/master/resources/icons/Tapeti.SimpleInjector.png + false + Ninject integration package for Tapeti + + rabbitmq tapeti ninject + + + + + + + + + \ No newline at end of file diff --git a/Tapeti.UnityContainer/Tapeti.UnityContainer.csproj b/Tapeti.UnityContainer/Tapeti.UnityContainer.csproj new file mode 100644 index 0000000..16df73c --- /dev/null +++ b/Tapeti.UnityContainer/Tapeti.UnityContainer.csproj @@ -0,0 +1,16 @@ + + + + netstandard2.0 + true + + + + + + + + + + + diff --git a/Tapeti.UnityContainer/Tapeti.UnityContainer.nuspec b/Tapeti.UnityContainer/Tapeti.UnityContainer.nuspec new file mode 100644 index 0000000..0d40763 --- /dev/null +++ b/Tapeti.UnityContainer/Tapeti.UnityContainer.nuspec @@ -0,0 +1,24 @@ + + + + Tapeti.UnityContainer + $version$ + Tapeti UnityContainer + Mark van Renswoude + Mark van Renswoude + https://raw.githubusercontent.com/MvRens/Tapeti/master/UNLICENSE + https://github.com/MvRens/Tapeti + https://raw.githubusercontent.com/MvRens/Tapeti/master/resources/icons/Tapeti.SimpleInjector.png + false + Unity container integration package for Tapeti + + rabbitmq tapeti unity + + + + + + + + + \ No newline at end of file diff --git a/Tapeti.UnityContainer/UnityDependencyResolver.cs b/Tapeti.UnityContainer/UnityDependencyResolver.cs new file mode 100644 index 0000000..98db82b --- /dev/null +++ b/Tapeti.UnityContainer/UnityDependencyResolver.cs @@ -0,0 +1,89 @@ +using System; +using Unity; +using Unity.Lifetime; + +namespace Tapeti.UnityContainer +{ + /// + /// + /// Dependency resolver and container implementation for SimpleInjector. + /// + public class UnityDependencyResolver : IDependencyContainer + { + private readonly IUnityContainer container; + + + /// + public UnityDependencyResolver(IUnityContainer container) + { + this.container = container; + } + + + /// + public T Resolve() where T : class + { + return container.Resolve(); + } + + /// + public object Resolve(Type type) + { + return container.Resolve(type); + } + + + /// + public void RegisterDefault() where TService : class where TImplementation : class, TService + { + if (container.IsRegistered(typeof(TService))) + return; + + container.RegisterType(); + } + + /// + public void RegisterDefault(Func factory) where TService : class + { + if (container.IsRegistered(typeof(TService))) + return; + + container.RegisterFactory(c => factory()); + } + + + /// + public void RegisterDefaultSingleton() where TService : class where TImplementation : class, TService + { + if (container.IsRegistered(typeof(TService))) + return; + + container.RegisterSingleton(); + } + + /// + public void RegisterDefaultSingleton(TService instance) where TService : class + { + if (container.IsRegistered(typeof(TService))) + return; + + container.RegisterInstance(instance); + } + + /// + public void RegisterDefaultSingleton(Func factory) where TService : class + { + if (container.IsRegistered(typeof(TService))) + return; + + container.RegisterFactory(c => factory(), new SingletonLifetimeManager()); + } + + + /// + public void RegisterController(Type type) + { + container.RegisterType(type); + } + } +} diff --git a/Tapeti.sln b/Tapeti.sln index 801f5ae..04187e1 100644 --- a/Tapeti.sln +++ b/Tapeti.sln @@ -37,7 +37,21 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "03-FlowRequestResponse", "E EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "04-Transient", "Examples\04-Transient\04-Transient.csproj", "{46DFC131-A398-435F-A7DF-3C41B656BF11}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "05-SpeedTest", "Examples\05-SpeedTest\05-SpeedTest.csproj", "{330D05CE-5321-4C7D-8017-2070B891289E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "05-SpeedTest", "Examples\05-SpeedTest\05-SpeedTest.csproj", "{330D05CE-5321-4C7D-8017-2070B891289E}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IoC", "IoC", "{99380F97-AD1A-459F-8AB3-D404E1E6AD4F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{8E757FF7-F6D7-42B1-827F-26FA95D97803}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions", "{57996ADC-18C5-4991-9F95-58D58D442461}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tapeti.CastleWindsor", "Tapeti.CastleWindsor\Tapeti.CastleWindsor.csproj", "{374AAE64-598B-4F67-8870-4A05168FF987}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tapeti.Autofac", "Tapeti.Autofac\Tapeti.Autofac.csproj", "{B3802005-C941-41B6-A9A5-20573A7C24AE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tapeti.UnityContainer", "Tapeti.UnityContainer\Tapeti.UnityContainer.csproj", "{BA8CA9A2-BAFF-42BB-8439-3DD9D1F6C32E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tapeti.Ninject", "Tapeti.Ninject\Tapeti.Ninject.csproj", "{29478B10-FC53-4E93-ADEF-A775D9408131}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -113,11 +127,36 @@ Global {330D05CE-5321-4C7D-8017-2070B891289E}.Debug|Any CPU.Build.0 = Debug|Any CPU {330D05CE-5321-4C7D-8017-2070B891289E}.Release|Any CPU.ActiveCfg = Release|Any CPU {330D05CE-5321-4C7D-8017-2070B891289E}.Release|Any CPU.Build.0 = Release|Any CPU + {374AAE64-598B-4F67-8870-4A05168FF987}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {374AAE64-598B-4F67-8870-4A05168FF987}.Debug|Any CPU.Build.0 = Debug|Any CPU + {374AAE64-598B-4F67-8870-4A05168FF987}.Release|Any CPU.ActiveCfg = Release|Any CPU + {374AAE64-598B-4F67-8870-4A05168FF987}.Release|Any CPU.Build.0 = Release|Any CPU + {B3802005-C941-41B6-A9A5-20573A7C24AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B3802005-C941-41B6-A9A5-20573A7C24AE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B3802005-C941-41B6-A9A5-20573A7C24AE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B3802005-C941-41B6-A9A5-20573A7C24AE}.Release|Any CPU.Build.0 = Release|Any CPU + {BA8CA9A2-BAFF-42BB-8439-3DD9D1F6C32E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BA8CA9A2-BAFF-42BB-8439-3DD9D1F6C32E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BA8CA9A2-BAFF-42BB-8439-3DD9D1F6C32E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BA8CA9A2-BAFF-42BB-8439-3DD9D1F6C32E}.Release|Any CPU.Build.0 = Release|Any CPU + {29478B10-FC53-4E93-ADEF-A775D9408131}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {29478B10-FC53-4E93-ADEF-A775D9408131}.Debug|Any CPU.Build.0 = Debug|Any CPU + {29478B10-FC53-4E93-ADEF-A775D9408131}.Release|Any CPU.ActiveCfg = Release|Any CPU + {29478B10-FC53-4E93-ADEF-A775D9408131}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution + {4B742AB2-59DD-4792-8E0F-D80B5366B844} = {8E757FF7-F6D7-42B1-827F-26FA95D97803} + {2952B141-C54D-4E6F-8108-CAD735B0279F} = {8E757FF7-F6D7-42B1-827F-26FA95D97803} + {6504D430-AB4A-4DE3-AE76-0384591BEEE7} = {57996ADC-18C5-4991-9F95-58D58D442461} + {14CF8F01-570B-4B84-AB4A-E0C3EC117F89} = {57996ADC-18C5-4991-9F95-58D58D442461} + {775CAB72-F443-442E-8E10-313B2548EDF8} = {57996ADC-18C5-4991-9F95-58D58D442461} + {A190C736-E95A-4BDA-AA80-6211226DFCAD} = {99380F97-AD1A-459F-8AB3-D404E1E6AD4F} + {43AA5DF3-49D5-4795-A290-D6511502B564} = {57996ADC-18C5-4991-9F95-58D58D442461} + {A6355E63-19AB-47EA-91FA-49B5E9B41F88} = {57996ADC-18C5-4991-9F95-58D58D442461} + {1AAA5A2C-EAA8-4C49-96A6-673EA1EEE831} = {57996ADC-18C5-4991-9F95-58D58D442461} {8350A0AB-F0EE-48CF-9CA6-6019467101CF} = {266B9B94-A4D2-41C2-860C-24A7C3B63B56} {F3B38753-06B4-4932-84B4-A07692AD802D} = {266B9B94-A4D2-41C2-860C-24A7C3B63B56} {D24120D4-50A2-44B6-A4EA-6ADAAEBABA84} = {266B9B94-A4D2-41C2-860C-24A7C3B63B56} @@ -125,6 +164,10 @@ Global {463A12CE-E221-450D-ADEA-91A599612DFA} = {266B9B94-A4D2-41C2-860C-24A7C3B63B56} {46DFC131-A398-435F-A7DF-3C41B656BF11} = {266B9B94-A4D2-41C2-860C-24A7C3B63B56} {330D05CE-5321-4C7D-8017-2070B891289E} = {266B9B94-A4D2-41C2-860C-24A7C3B63B56} + {374AAE64-598B-4F67-8870-4A05168FF987} = {99380F97-AD1A-459F-8AB3-D404E1E6AD4F} + {B3802005-C941-41B6-A9A5-20573A7C24AE} = {99380F97-AD1A-459F-8AB3-D404E1E6AD4F} + {BA8CA9A2-BAFF-42BB-8439-3DD9D1F6C32E} = {99380F97-AD1A-459F-8AB3-D404E1E6AD4F} + {29478B10-FC53-4E93-ADEF-A775D9408131} = {99380F97-AD1A-459F-8AB3-D404E1E6AD4F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {B09CC2BF-B2AF-4CB6-8728-5D1D8E5C50FA} diff --git a/appveyor.yml b/appveyor.yml index 43409b3..96fe67d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -31,12 +31,24 @@ after_build: # Tapeti.Transient - cmd: nuget pack Tapeti.Transient\Tapeti.Transient.nuspec -version "%GitVersion_NuGetVersion%" -prop "target=%CONFIGURATION%" - cmd: appveyor PushArtifact "Tapeti.Transient.%GitVersion_NuGetVersion%.nupkg" - # Tapeti.SimpleInjector - - cmd: nuget pack Tapeti.SimpleInjector\Tapeti.SimpleInjector.nuspec -version "%GitVersion_NuGetVersion%" -prop "target=%CONFIGURATION%" - - cmd: appveyor PushArtifact "Tapeti.SimpleInjector.%GitVersion_NuGetVersion%.nupkg" # Tapeti.Serilog - cmd: nuget pack Tapeti.Serilog\Tapeti.Serilog.nuspec -version "%GitVersion_NuGetVersion%" -prop "target=%CONFIGURATION%" - cmd: appveyor PushArtifact "Tapeti.Serilog.%GitVersion_NuGetVersion%.nupkg" + # Tapeti.SimpleInjector + - cmd: nuget pack Tapeti.SimpleInjector\Tapeti.SimpleInjector.nuspec -version "%GitVersion_NuGetVersion%" -prop "target=%CONFIGURATION%" + - cmd: appveyor PushArtifact "Tapeti.SimpleInjector.%GitVersion_NuGetVersion%.nupkg" + # Tapeti.Autofac + - cmd: nuget pack Tapeti.Autofac\Tapeti.Autofac.nuspec -version "%GitVersion_NuGetVersion%" -prop "target=%CONFIGURATION%" + - cmd: appveyor PushArtifact "Tapeti.Autofac.%GitVersion_NuGetVersion%.nupkg" + # Tapeti.CastleWindsor + - cmd: nuget pack Tapeti.CastleWindsor\Tapeti.CastleWindsor.nuspec -version "%GitVersion_NuGetVersion%" -prop "target=%CONFIGURATION%" + - cmd: appveyor PushArtifact "Tapeti.CastleWindsor.%GitVersion_NuGetVersion%.nupkg" + # Tapeti.Ninject + - cmd: nuget pack Tapeti.Ninject\Tapeti.Ninject.nuspec -version "%GitVersion_NuGetVersion%" -prop "target=%CONFIGURATION%" + - cmd: appveyor PushArtifact "Tapeti.Ninject.%GitVersion_NuGetVersion%.nupkg" + # Tapeti.UnityContainer + - cmd: nuget pack Tapeti.UnityContainer\Tapeti.UnityContainer.nuspec -version "%GitVersion_NuGetVersion%" -prop "target=%CONFIGURATION%" + - cmd: appveyor PushArtifact "Tapeti.UnityContainer.%GitVersion_NuGetVersion%.nupkg" assembly_info: patch: false diff --git a/docs/gettingstarted.rst b/docs/gettingstarted.rst index f913f1b..a4826c7 100644 --- a/docs/gettingstarted.rst +++ b/docs/gettingstarted.rst @@ -9,9 +9,18 @@ I'll assume you are familiar with installing NuGet.org packages into your projec Find and install the *Tapeti* package. This will also install *Tapeti.Annotations*, which contains the various attributes. -You will need an integration package as well for your IoC (Inversion of Control) container of choice. At the time of writing, one is provided for `SimpleInjector `_. Simply install *Tapeti.SimpleInjector* as well. +You will need an integration package as well for your IoC (Inversion of Control) container of choice. Various containers are supported by default: -.. note:: If you need support for your favourite library, implement *IDependencyContainer* using the *Tapeti.SimpleInjector* source as a reference and replace *SimpleInjectorDependencyResolver* with your class name in the example code below. +- `SimpleInjector `_ (Tapeti.SimpleInjector) +- `Autofac `_ (Tapeti.Autofac) +- `Castle Windsor `_ (Tapeti.CastleWindsor) +- `Ninject `_ (Tapeti.Ninject) +- `Unity `_ (Tapeti.UnityContainer) + + +SimpleInjector is used in all examples. The "01-PublishSubscribe" example included in the source shows how the other integration packages can be used. + +.. note:: If you need support for your favourite library, implement *IDependencyContainer* using the existing packages' source as a reference and replace *SimpleInjectorDependencyResolver* with your class name in the example code. Configuring Tapeti ------------------