diff --git a/src/Boxes.Integration/Boxes.Integration.csproj b/src/Boxes.Integration/Boxes.Integration.csproj index 9f60dc8..b2f1f9b 100644 --- a/src/Boxes.Integration/Boxes.Integration.csproj +++ b/src/Boxes.Integration/Boxes.Integration.csproj @@ -47,14 +47,14 @@ + - - + @@ -68,7 +68,7 @@ - + diff --git a/src/Boxes.Integration/BoxesWrapperBase.cs b/src/Boxes.Integration/BoxesWrapperBase.cs index aee09ab..705735f 100644 --- a/src/Boxes.Integration/BoxesWrapperBase.cs +++ b/src/Boxes.Integration/BoxesWrapperBase.cs @@ -13,7 +13,6 @@ // limitations under the License. namespace Boxes.Integration { - using System; using Boxes.Tasks; using Discovering; using Factories; @@ -23,25 +22,33 @@ namespace Boxes.Integration using Tasks; using Trust; + /// + /// this wrapper of boxes.core, this will integrate the features of boxes with an IoC container + /// + /// the type used to build registrations + /// the type of the container, this will be used to resolve the instances + /// + /// do not remove the TContainer this is used with the extension methods and with the other classes in the system public abstract class BoxesWrapperBase : IBoxesWrapper { - //TODO: look at disabling registrations http://ayende.com/blog/2792/introducing-monorail-hotswap + //TODO: look at disabling registrations (controllable in a module) + //http://ayende.com/blog/2792/introducing-monorail-hotswap //issue is around the containers, a subset allow to deletions of registrations //an other way is to restart the app and only register the required packages with the IoC //the second way can be supported by coding a module //favored way, use of child container, will need to re-initialise the container (delete, create a new one) - //TODO: migrations + //TODO: migrations (possible in a module) //updates of a module will require a restart, currently the Loaders do not support //app domains. they do offer a level of isolation - //TODO: Multi-tenancy + //TODO: Multi-tenancy (possible in a module) //use child containers to handle tenants. implement a IProcess (consider PLinq) to register //the correct packages with the correct child container. - //TODO: consider how to admin an application + //TODO: consider how to admin an application (need feedback) - //TODO: events + //TODO: events (possible in a module) private IPackageScanner _defaultPackageScanner; private ILoader _loader; @@ -55,6 +62,16 @@ protected BoxesWrapperBase() PackageRegistry = new PackageRegistry(); _extensionRunner = new TaskRunner(new ExtendBoxesTask(_internalContainer)); _loaderFactory = new LoaderFactory(); + + //setup the internal IoC + _internalContainer.Add(); + _internalContainer.Add(typeof(IIocSetup<>), typeof(IocSetup<>)); + _internalContainer.Add(); + + _internalContainer.Add(); + _internalContainer.setInstance(typeof(LoaderFactory), _loaderFactory); + + Initialize(_internalContainer); } public PackageRegistry PackageRegistry { get; private set; } @@ -97,29 +114,11 @@ public virtual void Dispose() { _internalContainer.Dispose(); } - - } - - - public class App - { - public void Main() - { - //IBoxesWrapper<> boxes = null; - ////boxes.BoxesIntegrationSetup - ////how do we want to configure? - - //boxes.Setup(new PackageScanner("folder")); - //boxes.DiscoverPackages(); - //boxes.LoadPackages(); - - - - //boxes.EnablePackages("", "", "", "", ""); //auto detect the tenant - //boxes.DependencyResolver.Resolve(); - } + /// + /// setup boxes integration with the IoC implementation (register types with the internal IoC) + /// + protected abstract void Initialize(IInternalContainer internalContainer); } - } \ No newline at end of file diff --git a/src/Boxes.Integration/Factories/FuncCreateLoader.cs b/src/Boxes.Integration/Factories/FuncCreateLoader.cs index 407cdb9..cd2ff9a 100644 --- a/src/Boxes.Integration/Factories/FuncCreateLoader.cs +++ b/src/Boxes.Integration/Factories/FuncCreateLoader.cs @@ -14,7 +14,7 @@ namespace Boxes.Integration.Factories { using System; - using Boxes.Loading; + using Loading; /// /// creates a Loader, based on a Func which is passed in via the ctor diff --git a/src/Boxes.Integration/Factories/IIoCFactory.cs b/src/Boxes.Integration/Factories/IIoCFactory.cs index a79084c..9335297 100644 --- a/src/Boxes.Integration/Factories/IIoCFactory.cs +++ b/src/Boxes.Integration/Factories/IIoCFactory.cs @@ -16,7 +16,7 @@ namespace Boxes.Integration.Factories /// /// create instances of containers as required /// - public interface IIoCFactory + public interface IIocFactory { /// diff --git a/src/Boxes.Integration/Factories/IIocSetup.cs b/src/Boxes.Integration/Factories/IIocSetup.cs new file mode 100644 index 0000000..701d75f --- /dev/null +++ b/src/Boxes.Integration/Factories/IIocSetup.cs @@ -0,0 +1,51 @@ +// Copyright 2012 - 2013 dbones.co.uk (David Rundle) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +namespace Boxes.Integration.Factories +{ + /// + /// A Setup to use with the IoC (this should be injected into the ) + /// + /// the IoC setup + public interface IIocSetup + { + /// + /// configure the main container + /// + /// the main container builder, (this should be before any registrations) + void Configure(TBuilder builder); + + /// + /// configure a child container + /// + /// the child builder, (this should be before any registrations) + void ConfigureChild(TBuilder builder); + } + + /// + /// does nothing, vanilla setup of the ioc + /// + /// + public class IocSetup : IIocSetup + { + public void Configure(TBuilder builder) + { + + } + + public void ConfigureChild(TBuilder builder) + { + + } + } +} \ No newline at end of file diff --git a/src/Boxes.Integration/IBoxesWrapper.cs b/src/Boxes.Integration/IBoxesWrapper.cs index 3b20aad..e907980 100644 --- a/src/Boxes.Integration/IBoxesWrapper.cs +++ b/src/Boxes.Integration/IBoxesWrapper.cs @@ -68,22 +68,6 @@ public interface IBoxesWrapper : IDisposable /// public static class BoxesWrapperExtensions { - /// - /// A mechanism to handle type registration with the Tenant(s) IoC container. - /// - public static ITenantContainerSetup Registrations(this IBoxesWrapper boxes) - { - return boxes.GetService>(); - } - - /// - /// A mechanism to handle type registration with the underlying Global/Parent IoC container. - /// - public static IApplicationContainerSetup GlobalRegistrations(this IBoxesWrapper boxes) - { - return boxes.GetService>(); - } - /// /// the trust manager being used by boxes. /// diff --git a/src/Boxes.Integration/InternalContainerExtensions.cs b/src/Boxes.Integration/InternalContainerExtensions.cs index ac6194a..9a8b4db 100644 --- a/src/Boxes.Integration/InternalContainerExtensions.cs +++ b/src/Boxes.Integration/InternalContainerExtensions.cs @@ -18,7 +18,7 @@ namespace Boxes.Integration /// /// some extensions for the internal container /// - internal static class InternalContainerExtensions + public static class InternalContainerExtensions { public static void Add(this IInternalContainer internalContainer) where TService : TContract { diff --git a/src/Boxes.Integration/InternalIoc/IInternalContainer.cs b/src/Boxes.Integration/InternalIoc/IInternalContainer.cs index 043c923..b5fa176 100644 --- a/src/Boxes.Integration/InternalIoc/IInternalContainer.cs +++ b/src/Boxes.Integration/InternalIoc/IInternalContainer.cs @@ -18,7 +18,7 @@ namespace Boxes.Integration.InternalIoc /// /// A simple internal container, which will manage the services available in Boxes. /// - internal interface IInternalContainer : IDisposable + public interface IInternalContainer : IDisposable { void Add(Type contract, Type service); diff --git a/src/Boxes.Integration/InternalIoc/InternalInternalContainer.cs b/src/Boxes.Integration/InternalIoc/InternalInternalContainer.cs index 70361ed..dd4f01d 100644 --- a/src/Boxes.Integration/InternalIoc/InternalInternalContainer.cs +++ b/src/Boxes.Integration/InternalIoc/InternalInternalContainer.cs @@ -72,7 +72,7 @@ public object Resolve(Type contract) { //no support for list or lazy, this is a simple internalContainer Type[] genericArguments = contract.GetGenericArguments(); - getServiceType = r => r.Service.MakeGenericType(genericArguments); + getServiceType = r => r.Service.IsGenericType ? r.Service.MakeGenericType(genericArguments) : r.Service; contract = contract.GetGenericTypeDefinition(); } else diff --git a/src/Boxes.Integration/Setup/ITenantContainerSetup.cs b/src/Boxes.Integration/Setup/DefaultContainerSetup.cs similarity index 68% rename from src/Boxes.Integration/Setup/ITenantContainerSetup.cs rename to src/Boxes.Integration/Setup/DefaultContainerSetup.cs index e2a41fa..3ed4aba 100644 --- a/src/Boxes.Integration/Setup/ITenantContainerSetup.cs +++ b/src/Boxes.Integration/Setup/DefaultContainerSetup.cs @@ -13,16 +13,19 @@ // limitations under the License. namespace Boxes.Integration.Setup { + //TODO:move into the base/default module + /// /// the tenants container setup /// /// the ioc builder class - public interface ITenantContainerSetup : IContainerSetup { } + public interface IDefaultContainerSetup : IContainerSetup { } - public class TenantContainerSetup : ContainerSetupBase, ITenantContainerSetup + public class DefaultContainerSetup : ContainerSetupBase, IDefaultContainerSetup { - public TenantContainerSetup(IRegistrationTaskMapper registrationTaskMapper) : base(registrationTaskMapper) + public DefaultContainerSetup(IRegistrationTaskMapper registrationTaskMapper) + : base(registrationTaskMapper) { } } diff --git a/src/Boxes.Integration/Setup/IApplicationContainerSetup.cs b/src/Boxes.Integration/Setup/IApplicationContainerSetup.cs deleted file mode 100644 index cb5ad25..0000000 --- a/src/Boxes.Integration/Setup/IApplicationContainerSetup.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 - 2013 dbones.co.uk (David Rundle) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -namespace Boxes.Integration.Setup -{ - /// - /// the global container setup - /// - /// the ioc builder class - public interface IApplicationContainerSetup : IContainerSetup{} -} \ No newline at end of file diff --git a/src/Boxes.Integration/Setup/IContainerSetup.cs b/src/Boxes.Integration/Setup/IContainerSetup.cs index 3983c0c..d870a88 100644 --- a/src/Boxes.Integration/Setup/IContainerSetup.cs +++ b/src/Boxes.Integration/Setup/IContainerSetup.cs @@ -54,12 +54,6 @@ public interface IContainerSetup : IBoxesExtensionWithSetup /// name of the package /// null if there is not filter ITypeRegistrationFilter GetTypeRegistrationFilter(string packageName); - - - //void RegisterPreProcessTask(IBoxesTask task); - - - //void RegisterProcessTask(IBoxesTask task); } @@ -72,12 +66,7 @@ public interface IContainerSetup : IContainerSetup /// all the registration to run the types through /// IEnumerable>> Registrations { get; } - - //IEnumerable> PreProcessTasks { get; } - - //IEnumerable> ProcessTasks { get; } - - - } + + } \ No newline at end of file diff --git a/src/Boxes.Integration/Setup/RegistrationContext.cs b/src/Boxes.Integration/Setup/RegistrationContext.cs index d5ffb37..7fbfd88 100644 --- a/src/Boxes.Integration/Setup/RegistrationContext.cs +++ b/src/Boxes.Integration/Setup/RegistrationContext.cs @@ -15,8 +15,7 @@ namespace Boxes.Integration.Setup { using System; - //TODO: keep an eye on this class, look at some profiling - + //TODO: keep an eye on the use of this class, look at some profiling /// /// the context for the registration