diff --git a/NzbDrone.Core.Test/Ninject.Moq/MockingKernel.cs b/NzbDrone.Core.Test/Ninject.Moq/MockingKernel.cs
index 40224b86f..0a0eba8fd 100644
--- a/NzbDrone.Core.Test/Ninject.Moq/MockingKernel.cs
+++ b/NzbDrone.Core.Test/Ninject.Moq/MockingKernel.cs
@@ -4,38 +4,38 @@ using Ninject.Planning.Bindings;
namespace Ninject.Moq
{
- ///
- /// A kernel that will create mocked instances (via Moq) for any service that is
- /// requested for which no binding is registered.
- ///
- public class MockingKernel : StandardKernel
- {
- ///
- /// Clears the kernel's cache, immediately deactivating all activated instances regardless of scope.
- /// This does not remove any modules, extensions, or bindings.
- ///
- public void Reset()
- {
- Components.Get().Clear();
- }
+ ///
+ /// A kernel that will create mocked instances (via Moq) for any service that is
+ /// requested for which no binding is registered.
+ ///
+ public class MockingKernel : StandardKernel
+ {
+ ///
+ /// Clears the kernel's cache, immediately deactivating all activated instances regardless of scope.
+ /// This does not remove any modules, extensions, or bindings.
+ ///
+ public void Reset()
+ {
+ Components.Get().Clear();
+ }
- ///
- /// Attempts to handle a missing binding for a service.
- ///
- /// The service.
- /// True if the missing binding can be handled; otherwise false.
- protected override bool HandleMissingBinding(Type service)
- {
- var binding = new Binding(service)
- {
- ProviderCallback = MockProvider.GetCreationCallback(),
- ScopeCallback = ctx => null,
- IsImplicit = true
- };
+ ///
+ /// Attempts to handle a missing binding for a service.
+ ///
+ /// The service.
+ /// True if the missing binding can be handled; otherwise false.
+ protected override bool HandleMissingBinding(Type service)
+ {
+ var binding = new Binding(service)
+ {
+ ProviderCallback = MockProvider.GetCreationCallback(),
+ ScopeCallback = ctx => null,
+ IsImplicit = true
+ };
- AddBinding(binding);
+ AddBinding(binding);
- return true;
- }
- }
+ return true;
+ }
+ }
}
diff --git a/NzbDrone.Core/Libraries/Castle.Core.dll b/NzbDrone.Core/Libraries/Castle.Core.dll
deleted file mode 100644
index 34c155ab4..000000000
Binary files a/NzbDrone.Core/Libraries/Castle.Core.dll and /dev/null differ
diff --git a/NzbDrone.Core/Libraries/Ninject.dll b/NzbDrone.Core/Libraries/Ninject.dll
index 35fdfc41b..90489c33a 100644
Binary files a/NzbDrone.Core/Libraries/Ninject.dll and b/NzbDrone.Core/Libraries/Ninject.dll differ
diff --git a/NzbDrone.Core/Libraries/Ninject.xml b/NzbDrone.Core/Libraries/Ninject.xml
index d9cf2f22a..05f3b527d 100644
--- a/NzbDrone.Core/Libraries/Ninject.xml
+++ b/NzbDrone.Core/Libraries/Ninject.xml
@@ -139,9 +139,9 @@
Occurs when the object is disposed.
-
+
- Tracks instances for re-use in certain scopes.
+ Stores the objects that were activated
@@ -164,6 +164,135 @@
Gets or sets the settings.
+
+
+ Stores the objects that were activated
+
+
+
+
+ Clears the cache.
+
+
+
+
+ Adds an activated instance.
+
+ The instance to be added.
+
+
+
+ Adds an deactivated instance.
+
+ The instance to be added.
+
+
+
+ Determines whether the specified instance is activated.
+
+ The instance.
+
+ true if the specified instance is activated; otherwise, false.
+
+
+
+
+ Determines whether the specified instance is deactivated.
+
+ The instance.
+
+ true if the specified instance is deactivated; otherwise, false.
+
+
+
+
+ An object that is prunealble.
+
+
+
+
+ Removes instances from the cache which should no longer be re-used.
+
+
+
+
+ The objects that were activated as reference equal weak references.
+
+
+
+
+ The objects that were activated as reference equal weak references.
+
+
+
+
+ Initializes a new instance of the class.
+
+ The cache pruner.
+
+
+
+ Clears the cache.
+
+
+
+
+ Adds an activated instance.
+
+ The instance to be added.
+
+
+
+ Adds an deactivated instance.
+
+ The instance to be added.
+
+
+
+ Determines whether the specified instance is activated.
+
+ The instance.
+
+ true if the specified instance is activated; otherwise, false.
+
+
+
+
+ Determines whether the specified instance is deactivated.
+
+ The instance.
+
+ true if the specified instance is deactivated; otherwise, false.
+
+
+
+
+ Prunes this instance.
+
+
+
+
+ Removes all dead objects.
+
+ The objects collection to be freed of dead objects.
+
+
+
+ Gets the activated object count.
+
+ The activated object count.
+
+
+
+ Gets the deactivated object count.
+
+ The deactivated object count.
+
+
+
+ Tracks instances for re-use in certain scopes.
+
+
Tracks instances for re-use in certain scopes.
@@ -190,11 +319,6 @@
The instance to release.
if the instance was found and released; otherwise .
-
-
- Removes instances from the cache which should no longer be re-used.
-
-
Immediately deactivates and removes all instances in the cache that are owned by
@@ -212,6 +336,12 @@
Gets the number of entries currently stored in the cache.
+
+
+ Contains all cached instances.
+ This is a dictionary of scopes to a multimap for bindings to cache entries.
+
+
Initializes a new instance of the class.
@@ -223,6 +353,7 @@
Releases resources held by the object.
+
@@ -262,9 +393,34 @@
Immediately deactivates and removes all instances in the cache, regardless of scope.
+
+
+ Gets all entries for a binding withing the selected scope.
+
+ The bindings.
+ All bindings of a binding.
+
+
+
+ Gets all cache entries.
+
+ Returns all cache entries.
+
+
+
+ Forgets the specified cache entries.
+
+ The cache entries.
+
+
+
+ Forgets the specified entry.
+
+ The entry.
+
- Gets or sets the pipeline component.
+ Gets the pipeline component.
@@ -272,6 +428,30 @@
Gets the number of entries currently stored in the cache.
+
+
+ An entry in the cache.
+
+
+
+
+ Initializes a new instance of the class.
+
+ The context.
+ The instance reference.
+
+
+
+ Gets the context of the instance.
+
+ The context.
+
+
+
+ Gets the instance reference.
+
+ The instance reference.
+
Uses a and some magic to poll
@@ -283,7 +463,7 @@
Prunes instances from an based on environmental information.
-
+
Starts pruning the specified cache based on the rules of the pruner.
@@ -294,27 +474,27 @@
Stops pruning.
+
+
+ The caches that are being pruned.
+
+
Releases resources held by the object.
-
+
- Starts pruning the specified cache based on the rules of the pruner.
+ Starts pruning the specified pruneable based on the rules of the pruner.
- The cache that will be pruned.
+ The pruneable that will be pruned.
Stops pruning.
-
-
- Gets the cache that is being pruned.
-
-
A provider that delegates to a callback method to create instances.
@@ -464,10 +644,9 @@
Gets or sets the selector component.
-
+
- Contributes to a , and is called during the activation
- and deactivation of an instance.
+ Adds all activated instances to the activation cache.
@@ -490,6 +669,48 @@
The context.
A reference to the instance being deactivated.
+
+
+ The activation cache.
+
+
+
+
+ Initializes a new instance of the class.
+
+ The activation cache.
+
+
+
+ Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+
+
+
+
+ Contributes to the activation of the instance in the specified context.
+
+ The context.
+ A reference to the instance being activated.
+
+
+
+ Contributes to the deactivation of the instance in the specified context.
+
+ The context.
+ A reference to the instance being deactivated.
+
+
+
+ Gets or sets the settings.
+
+ The ninject settings.
+
+
+
+ Contributes to a , and is called during the activation
+ and deactivation of an instance.
+
+
Contributes to the activation of the instance in the specified context.
@@ -899,11 +1120,17 @@
Drives the activation (injection, etc.) of an instance.
-
+
+
+ The activation cache.
+
+
+
Initializes a new instance of the class.
The strategies to execute during activation and deactivation.
+ The activation cache.
@@ -1191,6 +1418,59 @@
Gets or sets the kernel that owns the component container.
+
+
+ Extensions for MemberInfo
+
+
+
+
+ Determines whether the specified member has attribute.
+
+ The type of the attribute.
+ The member.
+
+ true if the specified member has attribute; otherwise, false.
+
+
+
+
+ Determines whether the specified member has attribute.
+
+ The member.
+ The type of the attribute.
+
+ true if the specified member has attribute; otherwise, false.
+
+
+
+
+ Gets the property info from its declared tpe.
+
+ The member info.
+ The property definition.
+ The flags.
+ The property info from the declared type of the property.
+
+
+
+ Determines whether the specified property info is private.
+
+ The property info.
+
+ true if the specified property info is private; otherwise, false.
+
+
+
+
+ Gets the custom attributes.
+ This version is able to get custom attributes for properties from base types even if the property is none public.
+
+ The member.
+ Type of the attribute.
+ if set to true [inherited].
+
+
Represents a future value.
@@ -1311,6 +1591,57 @@
Gets the collection of collections of values.
+
+
+ Weak reference that can be used in collections. It is equal to the
+ object it references and has the same hash code.
+
+
+
+
+ Initializes a new instance of the class.
+
+ The target.
+
+
+
+ Initializes a new instance of the class.
+
+ The target.
+ if set to true [track resurrection].
+
+
+
+ Determines whether the specified is equal to this instance.
+
+ The to compare with this instance.
+
+ true if the specified is equal to this instance; otherwise, false.
+
+
+ The parameter is null.
+
+
+
+
+ Returns a hash code for this instance.
+
+
+ A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
+
+
+
+
+ Gets a value indicating whether this instance is alive.
+
+ true if this instance is alive; otherwise, false.
+
+
+
+ Gets or sets the target of this weak reference.
+
+ The targe of this weak reference.
+
Defines the style of request (single or multi-injection, whether it is optional, etc.)
@@ -1870,6 +2201,20 @@
The service in question.
The series of matching bindings.
+
+
+ Contains logic about which bindings to use for a given service request
+ when other attempts have failed.
+
+
+
+
+ Returns any bindings from the specified collection that match the specified request.
+
+ The multimap of all registered bindings.
+ The request in question.
+ The series of matching bindings.
+
Resolves bindings for open generic types.
@@ -1883,6 +2228,25 @@
The service in question.
The series of matching bindings.
+
+
+
+
+
+
+ Returns any bindings from the specified collection that match the specified service.
+
+ The multimap of all registered bindings.
+ The service in question.
+ The series of matching bindings.
+
+
+
+ Returns a value indicating whether the specified service is self-bindable.
+
+ The service.
+ if the type is self-bindable; otherwise .
+
Resolves bindings that have been registered directly for the service.
@@ -2342,12 +2706,24 @@
The action callback.
+
+
+ Indicates that the specified callback should be invoked when instances are activated.
+
+ The action callback.
+
Indicates that the specified callback should be invoked when instances are deactivated.
The action callback.
+
+
+ Indicates that the specified callback should be invoked when instances are deactivated.
+
+ The action callback.
+
Used to set the scope, name, or add additional information or actions to a binding.
@@ -2573,16 +2949,23 @@
The action callback.
+
+
+ Indicates that the specified callback should be invoked when instances are activated.
+
+ The action callback.
+
Indicates that the specified callback should be invoked when instances are deactivated.
The action callback.
-
+
- Provides a root for the fluent syntax associated with an .
+ Indicates that the specified callback should be invoked when instances are deactivated.
+ The action callback.
@@ -2989,6 +3372,14 @@
The parent context in which the target is being injected.
A series of values that are available for injection.
+
+
+ Gets the value that should be injected into the target.
+
+ The service that the target is requesting.
+ The parent context in which the target is being injected.
+ The value that is to be injected.
+
Reads whether the target represents an optional dependency.
@@ -3715,6 +4106,34 @@
Gets a value indicating whether Ninject should inject non public members.
+
+
+ Gets a value indicating whether Ninject should inject private properties of base classes.
+
+
+ Activating this setting has an impact on the performance. It is recomended not
+ to use this feature and use constructor injection instead.
+
+
+
+
+ Gets or sets a value indicating whether the activation cache is disabled.
+ If the activation cache is disabled less memory is used. But in some cases
+ instances are activated or deactivated multiple times. e.g. in the following scenario:
+ Bind{A}().ToSelf();
+ Bind{IA}().ToMethod(ctx => kernel.Get{IA}();
+
+
+ true if activation cache is disabled; otherwise, false.
+
+
+
+
+ Gets or sets a value indicating whether Null is a valid value for injection.
+ By defualt this is disabled and whenever a provider returns null an eception is thrown.
+
+ true if null is allowed as injected value otherwise false.
+
A service that is started when activated, and stopped when deactivated.
@@ -3735,6 +4154,11 @@
The base implementation of an .
+
+
+ Lock used when adding missing bindings.
+
+
Initializes a new instance of the class.
@@ -3850,6 +4274,19 @@
The request to resolve.
An enumerator of instances that match the request.
+
+
+ Returns an IComparer that is used to determine resolution precedence.
+
+ An IComparer that is used to determine resolution precedence.
+
+
+
+ Returns a predicate that can determine if a given IBinding matches the request.
+
+ The request/
+ A predicate that can determine if a given IBinding matches the request.
+
Creates a request for the specified service.
@@ -3894,6 +4331,13 @@
The service.
True if the missing binding can be handled; otherwise false.
+
+
+ Attempts to handle a missing binding for a request.
+
+ The request.
+ True if the missing binding can be handled; otherwise false.
+
Returns a value indicating whether the specified service is self-bindable.
@@ -3971,6 +4415,36 @@
Gets a value indicating whether Ninject should inject non public members.
+
+
+ Gets a value indicating whether Ninject should inject private properties of base classes.
+
+
+ Activating this setting has an impact on the performance. It is recomended not
+ to use this feature and use constructor injection instead.
+
+
+
+
+ Gets or sets a value indicating whether the activation cache is disabled.
+ If the activation cache is disabled less memory is used. But in some cases
+ instances are activated or deactivated multiple times. e.g. in the following scenario:
+ Bind{A}().ToSelf();
+ Bind{IA}().ToMethod(ctx => kernel.Get{IA}();
+
+
+ true if activation cache is disabled; otherwise, false.
+
+
+
+
+ Gets or sets a value indicating whether Null is a valid value for injection.
+ By defualt this is disabled and whenever a provider returns null an eception is thrown.
+
+
+ true if null is allowed as injected value otherwise false.
+
+
Provides callbacks to more aggressively collect objects scoped to HTTP requests.
diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj
index 334dc532a..e36678b54 100644
--- a/NzbDrone.Core/NzbDrone.Core.csproj
+++ b/NzbDrone.Core/NzbDrone.Core.csproj
@@ -121,17 +121,13 @@
-
- False
- Libraries\Castle.Core.dll
-
False
Libraries\Exceptioneer.WindowsFormsClient.dll
-
+
False
@@ -219,7 +215,6 @@
-
diff --git a/NzbDrone.Web/Ninject.Web.Mvc/ControllerMissingBindingResolver.cs b/NzbDrone.Web/Ninject.Web.Mvc/ControllerMissingBindingResolver.cs
new file mode 100644
index 000000000..34b1b33f7
--- /dev/null
+++ b/NzbDrone.Web/Ninject.Web.Mvc/ControllerMissingBindingResolver.cs
@@ -0,0 +1,50 @@
+//
+// Authors: Nate Kohari , Remo Gloor
+// Copyright (c) 2007-2010, Enkari, Ltd. and contributors
+//
+// Dual-licensed under the Apache License, Version 2.0, and the Microsoft Public License (Ms-PL).
+// See the file LICENSE.txt for details.
+//
+
+namespace Ninject.Web.Mvc
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Web.Mvc;
+ using Ninject.Activation;
+ using Ninject.Activation.Providers;
+ using Ninject.Components;
+ using Ninject.Infrastructure;
+ using Ninject.Parameters;
+ using Ninject.Planning.Bindings;
+ using Ninject.Planning.Bindings.Resolvers;
+
+ ///
+ /// Missing binding resolver that creates a binding for unknown controllers.
+ ///
+ public class ControllerMissingBindingResolver : NinjectComponent, IMissingBindingResolver
+ {
+ ///
+ /// Returns any bindings from the specified collection that match the specified request.
+ ///
+ /// The multimap of all registered bindings.
+ /// The request in question.
+ /// The series of matching bindings.
+ public IEnumerable Resolve(Multimap bindings, IRequest request)
+ {
+ var service = request.Service;
+ if (typeof(Controller).IsAssignableFrom(service))
+ {
+ var binding = new Binding(service) { ProviderCallback = StandardProvider.GetCreationCallback(service) };
+ binding.Parameters.Add(
+ typeof(AsyncController).IsAssignableFrom(service)
+ ? new PropertyValue("ActionInvoker", ctx => ctx.Kernel.Get())
+ : new PropertyValue("ActionInvoker", ctx => ctx.Kernel.Get()));
+ return new[] { binding };
+ }
+
+ return Enumerable.Empty();
+ }
+ }
+}
\ No newline at end of file
diff --git a/NzbDrone.Web/Ninject.Web.Mvc/FilterInjector.cs b/NzbDrone.Web/Ninject.Web.Mvc/FilterInjector.cs
new file mode 100644
index 000000000..265926228
--- /dev/null
+++ b/NzbDrone.Web/Ninject.Web.Mvc/FilterInjector.cs
@@ -0,0 +1,60 @@
+//
+// Authors: Nate Kohari , Remo Gloor
+// Copyright (c) 2007-2010, Enkari, Ltd. and contributors
+//
+// Dual-licensed under the Apache License, Version 2.0, and the Microsoft Public License (Ms-PL).
+// See the file LICENSE.txt for details.
+//
+
+namespace Ninject.Web.Mvc
+{
+ using System.Linq;
+ using System.Web.Mvc;
+
+ ///
+ /// Injects all filters of a filter info.
+ ///
+ public class FilterInjector : IFilterInjector
+ {
+ ///
+ /// The kernel
+ ///
+ private readonly IKernel kernel;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The kernel.
+ public FilterInjector(IKernel kernel)
+ {
+ this.kernel = kernel;
+ }
+
+ ///
+ /// Injects all filters of the specified filter info.
+ ///
+ /// The filter info.
+ public void Inject(FilterInfo filterInfo)
+ {
+ foreach (IActionFilter filter in filterInfo.ActionFilters.Where(f => f != null))
+ {
+ this.kernel.Inject(filter);
+ }
+
+ foreach (IAuthorizationFilter filter in filterInfo.AuthorizationFilters.Where(f => f != null))
+ {
+ this.kernel.Inject(filter);
+ }
+
+ foreach (IExceptionFilter filter in filterInfo.ExceptionFilters.Where(f => f != null))
+ {
+ this.kernel.Inject(filter);
+ }
+
+ foreach (IResultFilter filter in filterInfo.ResultFilters.Where(f => f != null))
+ {
+ this.kernel.Inject(filter);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/NzbDrone.Web/Ninject.Web.Mvc/IFilterInjector.cs b/NzbDrone.Web/Ninject.Web.Mvc/IFilterInjector.cs
new file mode 100644
index 000000000..d97b866c2
--- /dev/null
+++ b/NzbDrone.Web/Ninject.Web.Mvc/IFilterInjector.cs
@@ -0,0 +1,24 @@
+//
+// Authors: Nate Kohari , Remo Gloor
+// Copyright (c) 2007-2010, Enkari, Ltd. and contributors
+//
+// Dual-licensed under the Apache License, Version 2.0, and the Microsoft Public License (Ms-PL).
+// See the file LICENSE.txt for details.
+//
+
+namespace Ninject.Web.Mvc
+{
+ using System.Web.Mvc;
+
+ ///
+ /// Injects all filters of a FiltorInfo.
+ ///
+ public interface IFilterInjector
+ {
+ ///
+ /// Injects all filters of the specified filter info.
+ ///
+ /// The filter info.
+ void Inject(FilterInfo filterInfo);
+ }
+}
\ No newline at end of file
diff --git a/NzbDrone.Web/Ninject.Web.Mvc/NinjectActionInvoker.cs b/NzbDrone.Web/Ninject.Web.Mvc/NinjectActionInvoker.cs
index 5421d54f6..e9d6ca714 100644
--- a/NzbDrone.Web/Ninject.Web.Mvc/NinjectActionInvoker.cs
+++ b/NzbDrone.Web/Ninject.Web.Mvc/NinjectActionInvoker.cs
@@ -1,4 +1,3 @@
-#region License
//
// Authors: Nate Kohari , Josh Close
// Copyright (c) 2007-2009, Enkari, Ltd.
@@ -6,56 +5,38 @@
// Dual-licensed under the Apache License, Version 2.0, and the Microsoft Public License (Ms-PL).
// See the file LICENSE.txt for details.
//
-#endregion
-#region Using Directives
-using System.Linq;
-using System.Web.Mvc;
-#endregion
namespace Ninject.Web.Mvc
{
- ///
- /// An that injects filters with dependencies.
- ///
- public class NinjectActionInvoker : ControllerActionInvoker
- {
- ///
- /// Gets or sets the kernel.
- ///
- public IKernel Kernel { get; private set; }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The kernel.
- public NinjectActionInvoker(IKernel kernel)
- {
- Kernel = kernel;
- }
-
- ///
- /// Gets the filters for the specified request and action.
- ///
- /// The controller context.
- /// The action descriptor.
- /// The filters.
- protected override FilterInfo GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
- {
- FilterInfo filterInfo = base.GetFilters(controllerContext, actionDescriptor);
-
- foreach (IActionFilter filter in filterInfo.ActionFilters.Where(f => f != null))
- Kernel.Inject(filter);
-
- foreach (IAuthorizationFilter filter in filterInfo.AuthorizationFilters.Where(f => f != null))
- Kernel.Inject(filter);
-
- foreach (IExceptionFilter filter in filterInfo.ExceptionFilters.Where(f => f != null))
- Kernel.Inject(filter);
-
- foreach (IResultFilter filter in filterInfo.ResultFilters.Where(f => f != null))
- Kernel.Inject(filter);
-
- return filterInfo;
- }
- }
+ using System.Web.Mvc;
+
+ ///
+ /// An that injects filters with dependencies.
+ ///
+ public class NinjectActionInvoker : ControllerActionInvoker
+ {
+ private readonly IFilterInjector filterInjector;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The filter injector.
+ public NinjectActionInvoker(IFilterInjector filterInjector)
+ {
+ this.filterInjector = filterInjector;
+ }
+
+ ///
+ /// Gets the filters for the specified request and action.
+ ///
+ /// The controller context.
+ /// The action descriptor.
+ /// The filters.
+ protected override FilterInfo GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
+ {
+ FilterInfo filterInfo = base.GetFilters(controllerContext, actionDescriptor);
+ this.filterInjector.Inject(filterInfo);
+ return filterInfo;
+ }
+ }
}
\ No newline at end of file
diff --git a/NzbDrone.Web/Ninject.Web.Mvc/NinjectAsyncActionInvoker.cs b/NzbDrone.Web/Ninject.Web.Mvc/NinjectAsyncActionInvoker.cs
new file mode 100644
index 000000000..10308a7b2
--- /dev/null
+++ b/NzbDrone.Web/Ninject.Web.Mvc/NinjectAsyncActionInvoker.cs
@@ -0,0 +1,43 @@
+//
+// Authors: Nate Kohari , Josh Close
+// Copyright (c) 2007-2009, Enkari, Ltd.
+//
+// Dual-licensed under the Apache License, Version 2.0, and the Microsoft Public License (Ms-PL).
+// See the file LICENSE.txt for details.
+//
+
+namespace Ninject.Web.Mvc
+{
+ using System.Web.Mvc;
+ using System.Web.Mvc.Async;
+
+ ///
+ /// An that injects filters with dependencies.
+ ///
+ public class NinjectAsyncActionInvoker : AsyncControllerActionInvoker
+ {
+ private readonly IFilterInjector filterInjector;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The filter injector.
+ public NinjectAsyncActionInvoker(IFilterInjector filterInjector)
+ {
+ this.filterInjector = filterInjector;
+ }
+
+ ///
+ /// Gets the filters for the specified request and action.
+ ///
+ /// The controller context.
+ /// The action descriptor.
+ /// The filters.
+ protected override FilterInfo GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
+ {
+ FilterInfo filterInfo = base.GetFilters(controllerContext, actionDescriptor);
+ this.filterInjector.Inject(filterInfo);
+ return filterInfo;
+ }
+ }
+}
\ No newline at end of file
diff --git a/NzbDrone.Web/Ninject.Web.Mvc/NinjectControllerFactory.cs b/NzbDrone.Web/Ninject.Web.Mvc/NinjectControllerFactory.cs
index eb60b9ab3..6904211f5 100644
--- a/NzbDrone.Web/Ninject.Web.Mvc/NinjectControllerFactory.cs
+++ b/NzbDrone.Web/Ninject.Web.Mvc/NinjectControllerFactory.cs
@@ -1,4 +1,3 @@
-#region License
//
// Authors: Nate Kohari , Josh Close
// Copyright (c) 2007-2009, Enkari, Ltd.
@@ -6,69 +5,84 @@
// Dual-licensed under the Apache License, Version 2.0, and the Microsoft Public License (Ms-PL).
// See the file LICENSE.txt for details.
//
-#endregion
-#region Using Directives
-using System;
-using System.Diagnostics;
-using System.Web.Mvc;
-using System.Web.Routing;
-#endregion
namespace Ninject.Web.Mvc
{
+ using System;
+ using System.Web.Mvc;
+ using System.Web.Routing;
+
///
- /// A controller factory that creates s via Ninject.
- ///
- public class NinjectControllerFactory : DefaultControllerFactory
- {
- ///
- /// Gets the kernel that will be used to create controllers.
- ///
- public IKernel Kernel { get; private set; }
+ /// A controller factory that creates s via Ninject.
+ ///
+ public class NinjectControllerFactory : DefaultControllerFactory
+ {
+ ///
+ /// Gets the kernel that will be used to create controllers.
+ ///
+ public IKernel Kernel { get; private set; }
- ///
- /// Initializes a new instance of the class.
- ///
- /// The kernel that should be used to create controllers.
- public NinjectControllerFactory(IKernel kernel)
- {
- Kernel = kernel;
- }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The kernel that should be used to create controllers.
+ public NinjectControllerFactory(IKernel kernel)
+ {
+ Kernel = kernel;
+ }
- ///
- /// Gets a controller instance of type controllerType.
- ///
- /// The request context.
- /// Type of controller to create.
- /// The controller instance.
- protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
- {
- if (controllerType == null)
- {
- // let the base handle 404 errors with proper culture information
- return base.GetControllerInstance(requestContext, controllerType);
- }
+ ///
+ /// Gets a controller instance of type controllerType.
+ ///
+ /// The request context.
+ /// Type of controller to create.
+ /// The controller instance.
+ protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
+ {
+ if(controllerType == null)
+ {
+ // let the base handle 404 errors with proper culture information
+ return base.GetControllerInstance(requestContext, controllerType);
+ }
- var controller = Kernel.GetService(controllerType) as IController;
+ var controller = Kernel.TryGet(controllerType) as IController;
- if (controller == null)
- return base.GetControllerInstance(requestContext, controllerType);
+ if (controller == null)
+ return base.GetControllerInstance(requestContext, controllerType);
- var standardController = controller as Controller;
+ /*
+ var asyncController = controller as AsyncController;
+ if (asyncController != null)
+ {
+ asyncController.ActionInvoker = this.CreateAsyncActionInvoker();
+ }
+ else
+ {
+ var standardController = controller as Controller;
+ if (standardController != null)
+ standardController.ActionInvoker = CreateActionInvoker();
+ }*/
- if (standardController != null)
- standardController.ActionInvoker = CreateActionInvoker();
+ return controller;
+ }
- return controller;
- }
+ /*
+ ///
+ /// Creates the action invoker.
+ ///
+ /// The action invoker.
+ protected virtual NinjectActionInvoker CreateActionInvoker()
+ {
+ return new NinjectActionInvoker(Kernel);
+ }
///
/// Creates the action invoker.
///
/// The action invoker.
- protected virtual NinjectActionInvoker CreateActionInvoker()
+ protected virtual NinjectAsyncActionInvoker CreateAsyncActionInvoker()
{
- return new NinjectActionInvoker(Kernel);
- }
+ return new NinjectAsyncActionInvoker(Kernel);
+ }*/
}
}
\ No newline at end of file
diff --git a/NzbDrone.Web/Ninject.Web.Mvc/NinjectHttpApplication.cs b/NzbDrone.Web/Ninject.Web.Mvc/NinjectHttpApplication.cs
index 4edb40cda..03fb19b92 100644
--- a/NzbDrone.Web/Ninject.Web.Mvc/NinjectHttpApplication.cs
+++ b/NzbDrone.Web/Ninject.Web.Mvc/NinjectHttpApplication.cs
@@ -16,7 +16,9 @@ using Ninject.Infrastructure;
namespace Ninject.Web.Mvc
{
- ///
+ using Ninject.Planning.Bindings.Resolvers;
+
+ ///
/// Defines an that is controlled by a Ninject .
///
public abstract class NinjectHttpApplication : HttpApplication, IHaveKernel
@@ -40,9 +42,14 @@ namespace Ninject.Web.Mvc
{
_kernel = CreateKernel();
- _kernel.Bind().ToConstant(RouteTable.Routes);
+ _kernel.Components.RemoveAll();
+ _kernel.Components.Add();
+ _kernel.Components.Add();
+
+ _kernel.Bind().ToConstant(RouteTable.Routes);
_kernel.Bind().ToMethod(ctx => HttpContext.Current).InTransientScope();
_kernel.Bind().ToMethod(ctx => new HttpContextWrapper(HttpContext.Current)).InTransientScope();
+ _kernel.Bind().To().InSingletonScope();
ControllerBuilder.Current.SetControllerFactory(CreateControllerFactory());
@@ -53,9 +60,9 @@ namespace Ninject.Web.Mvc
}
///
- /// Stops the application.
+ /// Releases the kernel on application end.
///
- public void Application_Stop()
+ public void Application_End()
{
lock (this)
{
diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj
index fd7649a09..08497b220 100644
--- a/NzbDrone.Web/NzbDrone.Web.csproj
+++ b/NzbDrone.Web/NzbDrone.Web.csproj
@@ -36,10 +36,7 @@
4
-
- False
- ..\NzbDrone.Core\Libraries\Ninject.dll
-
+
@@ -86,7 +83,11 @@
+
+
+
+