updated Ninject and Ninject.Web.Mvc

This commit is contained in:
Keivan 2010-10-18 11:04:07 -07:00
parent 9c7500d4ae
commit 41d9b0364f
13 changed files with 814 additions and 165 deletions

View File

@ -4,38 +4,38 @@ using Ninject.Planning.Bindings;
namespace Ninject.Moq
{
/// <summary>
/// A kernel that will create mocked instances (via Moq) for any service that is
/// requested for which no binding is registered.
/// </summary>
public class MockingKernel : StandardKernel
{
/// <summary>
/// Clears the kernel's cache, immediately deactivating all activated instances regardless of scope.
/// This does not remove any modules, extensions, or bindings.
/// </summary>
public void Reset()
{
Components.Get<ICache>().Clear();
}
/// <summary>
/// A kernel that will create mocked instances (via Moq) for any service that is
/// requested for which no binding is registered.
/// </summary>
public class MockingKernel : StandardKernel
{
/// <summary>
/// Clears the kernel's cache, immediately deactivating all activated instances regardless of scope.
/// This does not remove any modules, extensions, or bindings.
/// </summary>
public void Reset()
{
Components.Get<ICache>().Clear();
}
/// <summary>
/// Attempts to handle a missing binding for a service.
/// </summary>
/// <param name="service">The service.</param>
/// <returns><c>True</c> if the missing binding can be handled; otherwise <c>false</c>.</returns>
protected override bool HandleMissingBinding(Type service)
{
var binding = new Binding(service)
{
ProviderCallback = MockProvider.GetCreationCallback(),
ScopeCallback = ctx => null,
IsImplicit = true
};
/// <summary>
/// Attempts to handle a missing binding for a service.
/// </summary>
/// <param name="service">The service.</param>
/// <returns><c>True</c> if the missing binding can be handled; otherwise <c>false</c>.</returns>
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;
}
}
}

Binary file not shown.

View File

@ -139,9 +139,9 @@
Occurs when the object is disposed.
</summary>
</member>
<member name="T:Ninject.Activation.Caching.Cache">
<member name="T:Ninject.Activation.Caching.ActivationCache">
<summary>
Tracks instances for re-use in certain scopes.
Stores the objects that were activated
</summary>
</member>
<member name="T:Ninject.Components.NinjectComponent">
@ -164,6 +164,135 @@
Gets or sets the settings.
</summary>
</member>
<member name="T:Ninject.Activation.Caching.IActivationCache">
<summary>
Stores the objects that were activated
</summary>
</member>
<member name="M:Ninject.Activation.Caching.IActivationCache.Clear">
<summary>
Clears the cache.
</summary>
</member>
<member name="M:Ninject.Activation.Caching.IActivationCache.AddActivatedInstance(System.Object)">
<summary>
Adds an activated instance.
</summary>
<param name="instance">The instance to be added.</param>
</member>
<member name="M:Ninject.Activation.Caching.IActivationCache.AddDeactivatedInstance(System.Object)">
<summary>
Adds an deactivated instance.
</summary>
<param name="instance">The instance to be added.</param>
</member>
<member name="M:Ninject.Activation.Caching.IActivationCache.IsActivated(System.Object)">
<summary>
Determines whether the specified instance is activated.
</summary>
<param name="instance">The instance.</param>
<returns>
<c>true</c> if the specified instance is activated; otherwise, <c>false</c>.
</returns>
</member>
<member name="M:Ninject.Activation.Caching.IActivationCache.IsDeactivated(System.Object)">
<summary>
Determines whether the specified instance is deactivated.
</summary>
<param name="instance">The instance.</param>
<returns>
<c>true</c> if the specified instance is deactivated; otherwise, <c>false</c>.
</returns>
</member>
<member name="T:Ninject.Activation.Caching.IPruneable">
<summary>
An object that is prunealble.
</summary>
</member>
<member name="M:Ninject.Activation.Caching.IPruneable.Prune">
<summary>
Removes instances from the cache which should no longer be re-used.
</summary>
</member>
<member name="F:Ninject.Activation.Caching.ActivationCache.activatedObjects">
<summary>
The objects that were activated as reference equal weak references.
</summary>
</member>
<member name="F:Ninject.Activation.Caching.ActivationCache.deactivatedObjects">
<summary>
The objects that were activated as reference equal weak references.
</summary>
</member>
<member name="M:Ninject.Activation.Caching.ActivationCache.#ctor(Ninject.Activation.Caching.ICachePruner)">
<summary>
Initializes a new instance of the <see cref="T:Ninject.Activation.Caching.ActivationCache"/> class.
</summary>
<param name="cachePruner">The cache pruner.</param>
</member>
<member name="M:Ninject.Activation.Caching.ActivationCache.Clear">
<summary>
Clears the cache.
</summary>
</member>
<member name="M:Ninject.Activation.Caching.ActivationCache.AddActivatedInstance(System.Object)">
<summary>
Adds an activated instance.
</summary>
<param name="instance">The instance to be added.</param>
</member>
<member name="M:Ninject.Activation.Caching.ActivationCache.AddDeactivatedInstance(System.Object)">
<summary>
Adds an deactivated instance.
</summary>
<param name="instance">The instance to be added.</param>
</member>
<member name="M:Ninject.Activation.Caching.ActivationCache.IsActivated(System.Object)">
<summary>
Determines whether the specified instance is activated.
</summary>
<param name="instance">The instance.</param>
<returns>
<c>true</c> if the specified instance is activated; otherwise, <c>false</c>.
</returns>
</member>
<member name="M:Ninject.Activation.Caching.ActivationCache.IsDeactivated(System.Object)">
<summary>
Determines whether the specified instance is deactivated.
</summary>
<param name="instance">The instance.</param>
<returns>
<c>true</c> if the specified instance is deactivated; otherwise, <c>false</c>.
</returns>
</member>
<member name="M:Ninject.Activation.Caching.ActivationCache.Prune">
<summary>
Prunes this instance.
</summary>
</member>
<member name="M:Ninject.Activation.Caching.ActivationCache.RemoveDeadObjects(System.Collections.Generic.HashSet{System.Object})">
<summary>
Removes all dead objects.
</summary>
<param name="objects">The objects collection to be freed of dead objects.</param>
</member>
<member name="P:Ninject.Activation.Caching.ActivationCache.ActivatedObjectCount">
<summary>
Gets the activated object count.
</summary>
<value>The activated object count.</value>
</member>
<member name="P:Ninject.Activation.Caching.ActivationCache.DeactivatedObjectCount">
<summary>
Gets the deactivated object count.
</summary>
<value>The deactivated object count.</value>
</member>
<member name="T:Ninject.Activation.Caching.Cache">
<summary>
Tracks instances for re-use in certain scopes.
</summary>
</member>
<member name="T:Ninject.Activation.Caching.ICache">
<summary>
Tracks instances for re-use in certain scopes.
@ -190,11 +319,6 @@
<param name="instance">The instance to release.</param>
<returns><see langword="True"/> if the instance was found and released; otherwise <see langword="false"/>.</returns>
</member>
<member name="M:Ninject.Activation.Caching.ICache.Prune">
<summary>
Removes instances from the cache which should no longer be re-used.
</summary>
</member>
<member name="M:Ninject.Activation.Caching.ICache.Clear(System.Object)">
<summary>
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.
</summary>
</member>
<member name="F:Ninject.Activation.Caching.Cache.entries">
<summary>
Contains all cached instances.
This is a dictionary of scopes to a multimap for bindings to cache entries.
</summary>
</member>
<member name="M:Ninject.Activation.Caching.Cache.#ctor(Ninject.Activation.IPipeline,Ninject.Activation.Caching.ICachePruner)">
<summary>
Initializes a new instance of the <see cref="T:Ninject.Activation.Caching.Cache"/> class.
@ -223,6 +353,7 @@
<summary>
Releases resources held by the object.
</summary>
<param name="disposing"></param>
</member>
<member name="M:Ninject.Activation.Caching.Cache.Remember(Ninject.Activation.IContext,Ninject.Activation.InstanceReference)">
<summary>
@ -262,9 +393,34 @@
Immediately deactivates and removes all instances in the cache, regardless of scope.
</summary>
</member>
<member name="M:Ninject.Activation.Caching.Cache.GetAllBindingEntries(System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{Ninject.Planning.Bindings.IBinding,System.Collections.Generic.ICollection{Ninject.Activation.Caching.Cache.CacheEntry}}})">
<summary>
Gets all entries for a binding withing the selected scope.
</summary>
<param name="bindings">The bindings.</param>
<returns>All bindings of a binding.</returns>
</member>
<member name="M:Ninject.Activation.Caching.Cache.GetAllCacheEntries">
<summary>
Gets all cache entries.
</summary>
<returns>Returns all cache entries.</returns>
</member>
<member name="M:Ninject.Activation.Caching.Cache.Forget(System.Collections.Generic.IEnumerable{Ninject.Activation.Caching.Cache.CacheEntry})">
<summary>
Forgets the specified cache entries.
</summary>
<param name="cacheEntries">The cache entries.</param>
</member>
<member name="M:Ninject.Activation.Caching.Cache.Forget(Ninject.Activation.Caching.Cache.CacheEntry)">
<summary>
Forgets the specified entry.
</summary>
<param name="entry">The entry.</param>
</member>
<member name="P:Ninject.Activation.Caching.Cache.Pipeline">
<summary>
Gets or sets the pipeline component.
Gets the pipeline component.
</summary>
</member>
<member name="P:Ninject.Activation.Caching.Cache.Count">
@ -272,6 +428,30 @@
Gets the number of entries currently stored in the cache.
</summary>
</member>
<member name="T:Ninject.Activation.Caching.Cache.CacheEntry">
<summary>
An entry in the cache.
</summary>
</member>
<member name="M:Ninject.Activation.Caching.Cache.CacheEntry.#ctor(Ninject.Activation.IContext,Ninject.Activation.InstanceReference)">
<summary>
Initializes a new instance of the <see cref="T:Ninject.Activation.Caching.Cache.CacheEntry"/> class.
</summary>
<param name="context">The context.</param>
<param name="reference">The instance reference.</param>
</member>
<member name="P:Ninject.Activation.Caching.Cache.CacheEntry.Context">
<summary>
Gets the context of the instance.
</summary>
<value>The context.</value>
</member>
<member name="P:Ninject.Activation.Caching.Cache.CacheEntry.Reference">
<summary>
Gets the instance reference.
</summary>
<value>The instance reference.</value>
</member>
<member name="T:Ninject.Activation.Caching.GarbageCollectionCachePruner">
<summary>
Uses a <see cref="T:System.Threading.Timer"/> and some <see cref="T:System.WeakReference"/> magic to poll
@ -283,7 +463,7 @@
Prunes instances from an <see cref="T:Ninject.Activation.Caching.ICache"/> based on environmental information.
</summary>
</member>
<member name="M:Ninject.Activation.Caching.ICachePruner.Start(Ninject.Activation.Caching.ICache)">
<member name="M:Ninject.Activation.Caching.ICachePruner.Start(Ninject.Activation.Caching.IPruneable)">
<summary>
Starts pruning the specified cache based on the rules of the pruner.
</summary>
@ -294,27 +474,27 @@
Stops pruning.
</summary>
</member>
<member name="F:Ninject.Activation.Caching.GarbageCollectionCachePruner.caches">
<summary>
The caches that are being pruned.
</summary>
</member>
<member name="M:Ninject.Activation.Caching.GarbageCollectionCachePruner.Dispose(System.Boolean)">
<summary>
Releases resources held by the object.
</summary>
</member>
<member name="M:Ninject.Activation.Caching.GarbageCollectionCachePruner.Start(Ninject.Activation.Caching.ICache)">
<member name="M:Ninject.Activation.Caching.GarbageCollectionCachePruner.Start(Ninject.Activation.Caching.IPruneable)">
<summary>
Starts pruning the specified cache based on the rules of the pruner.
Starts pruning the specified pruneable based on the rules of the pruner.
</summary>
<param name="cache">The cache that will be pruned.</param>
<param name="pruneable">The pruneable that will be pruned.</param>
</member>
<member name="M:Ninject.Activation.Caching.GarbageCollectionCachePruner.Stop">
<summary>
Stops pruning.
</summary>
</member>
<member name="P:Ninject.Activation.Caching.GarbageCollectionCachePruner.Cache">
<summary>
Gets the cache that is being pruned.
</summary>
</member>
<member name="T:Ninject.Activation.Providers.CallbackProvider`1">
<summary>
A provider that delegates to a callback method to create instances.
@ -464,10 +644,9 @@
Gets or sets the selector component.
</summary>
</member>
<member name="T:Ninject.Activation.Strategies.ActivationStrategy">
<member name="T:Ninject.Activation.Strategies.ActivationCacheStrategy">
<summary>
Contributes to a <see cref="T:Ninject.Activation.IPipeline"/>, and is called during the activation
and deactivation of an instance.
Adds all activated instances to the activation cache.
</summary>
</member>
<member name="T:Ninject.Activation.Strategies.IActivationStrategy">
@ -490,6 +669,48 @@
<param name="context">The context.</param>
<param name="reference">A reference to the instance being deactivated.</param>
</member>
<member name="F:Ninject.Activation.Strategies.ActivationCacheStrategy.activationCache">
<summary>
The activation cache.
</summary>
</member>
<member name="M:Ninject.Activation.Strategies.ActivationCacheStrategy.#ctor(Ninject.Activation.Caching.IActivationCache)">
<summary>
Initializes a new instance of the <see cref="T:Ninject.Activation.Strategies.ActivationCacheStrategy"/> class.
</summary>
<param name="activationCache">The activation cache.</param>
</member>
<member name="M:Ninject.Activation.Strategies.ActivationCacheStrategy.Dispose">
<summary>
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
</summary>
</member>
<member name="M:Ninject.Activation.Strategies.ActivationCacheStrategy.Activate(Ninject.Activation.IContext,Ninject.Activation.InstanceReference)">
<summary>
Contributes to the activation of the instance in the specified context.
</summary>
<param name="context">The context.</param>
<param name="reference">A reference to the instance being activated.</param>
</member>
<member name="M:Ninject.Activation.Strategies.ActivationCacheStrategy.Deactivate(Ninject.Activation.IContext,Ninject.Activation.InstanceReference)">
<summary>
Contributes to the deactivation of the instance in the specified context.
</summary>
<param name="context">The context.</param>
<param name="reference">A reference to the instance being deactivated.</param>
</member>
<member name="P:Ninject.Activation.Strategies.ActivationCacheStrategy.Settings">
<summary>
Gets or sets the settings.
</summary>
<value>The ninject settings.</value>
</member>
<member name="T:Ninject.Activation.Strategies.ActivationStrategy">
<summary>
Contributes to a <see cref="T:Ninject.Activation.IPipeline"/>, and is called during the activation
and deactivation of an instance.
</summary>
</member>
<member name="M:Ninject.Activation.Strategies.ActivationStrategy.Activate(Ninject.Activation.IContext,Ninject.Activation.InstanceReference)">
<summary>
Contributes to the activation of the instance in the specified context.
@ -899,11 +1120,17 @@
Drives the activation (injection, etc.) of an instance.
</summary>
</member>
<member name="M:Ninject.Activation.Pipeline.#ctor(System.Collections.Generic.IEnumerable{Ninject.Activation.Strategies.IActivationStrategy})">
<member name="F:Ninject.Activation.Pipeline.activationCache">
<summary>
The activation cache.
</summary>
</member>
<member name="M:Ninject.Activation.Pipeline.#ctor(System.Collections.Generic.IEnumerable{Ninject.Activation.Strategies.IActivationStrategy},Ninject.Activation.Caching.IActivationCache)">
<summary>
Initializes a new instance of the <see cref="T:Ninject.Activation.Pipeline"/> class.
</summary>
<param name="strategies">The strategies to execute during activation and deactivation.</param>
<param name="activationCache">The activation cache.</param>
</member>
<member name="M:Ninject.Activation.Pipeline.Activate(Ninject.Activation.IContext,Ninject.Activation.InstanceReference)">
<summary>
@ -1191,6 +1418,59 @@
Gets or sets the kernel that owns the component container.
</summary>
</member>
<member name="T:Ninject.Infrastructure.Language.ExtensionsForMemberInfo">
<summary>
Extensions for MemberInfo
</summary>
</member>
<member name="M:Ninject.Infrastructure.Language.ExtensionsForMemberInfo.HasAttribute``1(System.Reflection.MemberInfo)">
<summary>
Determines whether the specified member has attribute.
</summary>
<typeparam name="T">The type of the attribute.</typeparam>
<param name="member">The member.</param>
<returns>
<c>true</c> if the specified member has attribute; otherwise, <c>false</c>.
</returns>
</member>
<member name="M:Ninject.Infrastructure.Language.ExtensionsForMemberInfo.HasAttribute(System.Reflection.MemberInfo,System.Type)">
<summary>
Determines whether the specified member has attribute.
</summary>
<param name="member">The member.</param>
<param name="type">The type of the attribute.</param>
<returns>
<c>true</c> if the specified member has attribute; otherwise, <c>false</c>.
</returns>
</member>
<member name="M:Ninject.Infrastructure.Language.ExtensionsForMemberInfo.GetPropertyFromDeclaredType(System.Reflection.MemberInfo,System.Reflection.PropertyInfo,System.Reflection.BindingFlags)">
<summary>
Gets the property info from its declared tpe.
</summary>
<param name="memberInfo">The member info.</param>
<param name="propertyDefinition">The property definition.</param>
<param name="flags">The flags.</param>
<returns>The property info from the declared type of the property.</returns>
</member>
<member name="M:Ninject.Infrastructure.Language.ExtensionsForMemberInfo.IsPrivate(System.Reflection.PropertyInfo)">
<summary>
Determines whether the specified property info is private.
</summary>
<param name="propertyInfo">The property info.</param>
<returns>
<c>true</c> if the specified property info is private; otherwise, <c>false</c>.
</returns>
</member>
<member name="M:Ninject.Infrastructure.Language.ExtensionsForMemberInfo.GetCustomAttributesExtended(System.Reflection.MemberInfo,System.Type,System.Boolean)">
<summary>
Gets the custom attributes.
This version is able to get custom attributes for properties from base types even if the property is none public.
</summary>
<param name="member">The member.</param>
<param name="attributeType">Type of the attribute.</param>
<param name="inherited">if set to <c>true</c> [inherited].</param>
<returns></returns>
</member>
<member name="T:Ninject.Infrastructure.Future`1">
<summary>
Represents a future value.
@ -1311,6 +1591,57 @@
Gets the collection of collections of values.
</summary>
</member>
<member name="T:Ninject.Infrastructure.ReferenceEqualWeakReference">
<summary>
Weak reference that can be used in collections. It is equal to the
object it references and has the same hash code.
</summary>
</member>
<member name="M:Ninject.Infrastructure.ReferenceEqualWeakReference.#ctor(System.Object)">
<summary>
Initializes a new instance of the <see cref="T:Ninject.Infrastructure.ReferenceEqualWeakReference"/> class.
</summary>
<param name="target">The target.</param>
</member>
<member name="M:Ninject.Infrastructure.ReferenceEqualWeakReference.#ctor(System.Object,System.Boolean)">
<summary>
Initializes a new instance of the <see cref="T:Ninject.Infrastructure.ReferenceEqualWeakReference"/> class.
</summary>
<param name="target">The target.</param>
<param name="trackResurrection">if set to <c>true</c> [track resurrection].</param>
</member>
<member name="M:Ninject.Infrastructure.ReferenceEqualWeakReference.Equals(System.Object)">
<summary>
Determines whether the specified <see cref="T:System.Object"/> is equal to this instance.
</summary>
<param name="obj">The <see cref="T:System.Object"/> to compare with this instance.</param>
<returns>
<c>true</c> if the specified <see cref="T:System.Object"/> is equal to this instance; otherwise, <c>false</c>.
</returns>
<exception cref="T:System.NullReferenceException">
The <paramref name="obj"/> parameter is null.
</exception>
</member>
<member name="M:Ninject.Infrastructure.ReferenceEqualWeakReference.GetHashCode">
<summary>
Returns a hash code for this instance.
</summary>
<returns>
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
</returns>
</member>
<member name="P:Ninject.Infrastructure.ReferenceEqualWeakReference.IsAlive">
<summary>
Gets a value indicating whether this instance is alive.
</summary>
<value><c>true</c> if this instance is alive; otherwise, <c>false</c>.</value>
</member>
<member name="P:Ninject.Infrastructure.ReferenceEqualWeakReference.Target">
<summary>
Gets or sets the target of this weak reference.
</summary>
<value>The targe of this weak reference.</value>
</member>
<member name="T:Ninject.Infrastructure.RequestFlags">
<summary>
Defines the style of request (single or multi-injection, whether it is optional, etc.)
@ -1870,6 +2201,20 @@
<param name="service">The service in question.</param>
<returns>The series of matching bindings.</returns>
</member>
<member name="T:Ninject.Planning.Bindings.Resolvers.IMissingBindingResolver">
<summary>
Contains logic about which bindings to use for a given service request
when other attempts have failed.
</summary>
</member>
<member name="M:Ninject.Planning.Bindings.Resolvers.IMissingBindingResolver.Resolve(Ninject.Infrastructure.Multimap{System.Type,Ninject.Planning.Bindings.IBinding},Ninject.Activation.IRequest)">
<summary>
Returns any bindings from the specified collection that match the specified request.
</summary>
<param name="bindings">The multimap of all registered bindings.</param>
<param name="request">The request in question.</param>
<returns>The series of matching bindings.</returns>
</member>
<member name="T:Ninject.Planning.Bindings.Resolvers.OpenGenericBindingResolver">
<summary>
Resolves bindings for open generic types.
@ -1883,6 +2228,25 @@
<param name="service">The service in question.</param>
<returns>The series of matching bindings.</returns>
</member>
<member name="T:Ninject.Planning.Bindings.Resolvers.SelfBindingResolver">
<summary>
</summary>
</member>
<member name="M:Ninject.Planning.Bindings.Resolvers.SelfBindingResolver.Resolve(Ninject.Infrastructure.Multimap{System.Type,Ninject.Planning.Bindings.IBinding},Ninject.Activation.IRequest)">
<summary>
Returns any bindings from the specified collection that match the specified service.
</summary>
<param name="bindings">The multimap of all registered bindings.</param>
<param name="request">The service in question.</param>
<returns>The series of matching bindings.</returns>
</member>
<member name="M:Ninject.Planning.Bindings.Resolvers.SelfBindingResolver.TypeIsSelfBindable(System.Type)">
<summary>
Returns a value indicating whether the specified service is self-bindable.
</summary>
<param name="service">The service.</param>
<returns><see langword="True"/> if the type is self-bindable; otherwise <see langword="false"/>.</returns>
</member>
<member name="T:Ninject.Planning.Bindings.Resolvers.StandardBindingResolver">
<summary>
Resolves bindings that have been registered directly for the service.
@ -2342,12 +2706,24 @@
</summary>
<param name="action">The action callback.</param>
</member>
<member name="M:Ninject.Syntax.IBindingOnSyntax`1.OnActivation(System.Action{Ninject.Activation.IContext,`0})">
<summary>
Indicates that the specified callback should be invoked when instances are activated.
</summary>
<param name="action">The action callback.</param>
</member>
<member name="M:Ninject.Syntax.IBindingOnSyntax`1.OnDeactivation(System.Action{`0})">
<summary>
Indicates that the specified callback should be invoked when instances are deactivated.
</summary>
<param name="action">The action callback.</param>
</member>
<member name="M:Ninject.Syntax.IBindingOnSyntax`1.OnDeactivation(System.Action{Ninject.Activation.IContext,`0})">
<summary>
Indicates that the specified callback should be invoked when instances are deactivated.
</summary>
<param name="action">The action callback.</param>
</member>
<member name="T:Ninject.Syntax.IBindingInNamedWithOrOnSyntax`1">
<summary>
Used to set the scope, name, or add additional information or actions to a binding.
@ -2573,16 +2949,23 @@
</summary>
<param name="action">The action callback.</param>
</member>
<member name="M:Ninject.Planning.Bindings.BindingBuilder`1.OnActivation(System.Action{Ninject.Activation.IContext,`0})">
<summary>
Indicates that the specified callback should be invoked when instances are activated.
</summary>
<param name="action">The action callback.</param>
</member>
<member name="M:Ninject.Planning.Bindings.BindingBuilder`1.OnDeactivation(System.Action{`0})">
<summary>
Indicates that the specified callback should be invoked when instances are deactivated.
</summary>
<param name="action">The action callback.</param>
</member>
<member name="M:Ninject.Planning.Bindings.BindingBuilder`1.Ninject#Syntax#IFluentSyntax#GetType">
<member name="M:Ninject.Planning.Bindings.BindingBuilder`1.OnDeactivation(System.Action{Ninject.Activation.IContext,`0})">
<summary>
Provides a root for the fluent syntax associated with an <see cref="P:Ninject.Planning.Bindings.BindingBuilder`1.Binding"/>.
Indicates that the specified callback should be invoked when instances are deactivated.
</summary>
<param name="action">The action callback.</param>
</member>
<member name="P:Ninject.Planning.Bindings.BindingBuilder`1.Binding">
<summary>
@ -2989,6 +3372,14 @@
<param name="parent">The parent context in which the target is being injected.</param>
<returns>A series of values that are available for injection.</returns>
</member>
<member name="M:Ninject.Planning.Targets.Target`1.GetValue(System.Type,Ninject.Activation.IContext)">
<summary>
Gets the value that should be injected into the target.
</summary>
<param name="service">The service that the target is requesting.</param>
<param name="parent">The parent context in which the target is being injected.</param>
<returns>The value that is to be injected.</returns>
</member>
<member name="M:Ninject.Planning.Targets.Target`1.ReadOptionalFromTarget">
<summary>
Reads whether the target represents an optional dependency.
@ -3715,6 +4106,34 @@
Gets a value indicating whether Ninject should inject non public members.
</summary>
</member>
<member name="P:Ninject.INinjectSettings.InjectParentPrivateProperties">
<summary>
Gets a value indicating whether Ninject should inject private properties of base classes.
</summary>
<remarks>
Activating this setting has an impact on the performance. It is recomended not
to use this feature and use constructor injection instead.
</remarks>
</member>
<member name="P:Ninject.INinjectSettings.ActivationCacheDisabled">
<summary>
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}();
</summary>
<value>
<c>true</c> if activation cache is disabled; otherwise, <c>false</c>.
</value>
</member>
<member name="P:Ninject.INinjectSettings.AllowNullInjection">
<summary>
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.
</summary>
<value><c>true</c> if null is allowed as injected value otherwise false.</value>
</member>
<member name="T:Ninject.IStartable">
<summary>
A service that is started when activated, and stopped when deactivated.
@ -3735,6 +4154,11 @@
The base implementation of an <see cref="T:Ninject.IKernel"/>.
</summary>
</member>
<member name="F:Ninject.KernelBase.HandleMissingBindingLockObject">
<summary>
Lock used when adding missing bindings.
</summary>
</member>
<member name="M:Ninject.KernelBase.#ctor">
<summary>
Initializes a new instance of the <see cref="T:Ninject.KernelBase"/> class.
@ -3850,6 +4274,19 @@
<param name="request">The request to resolve.</param>
<returns>An enumerator of instances that match the request.</returns>
</member>
<member name="M:Ninject.KernelBase.GetBindingPrecedenceComparer">
<summary>
Returns an IComparer that is used to determine resolution precedence.
</summary>
<returns>An IComparer that is used to determine resolution precedence.</returns>
</member>
<member name="M:Ninject.KernelBase.SatifiesRequest(Ninject.Activation.IRequest)">
<summary>
Returns a predicate that can determine if a given IBinding matches the request.
</summary>
<param name="request">The request/</param>
<returns>A predicate that can determine if a given IBinding matches the request.</returns>
</member>
<member name="M:Ninject.KernelBase.CreateRequest(System.Type,System.Func{Ninject.Planning.Bindings.IBindingMetadata,System.Boolean},System.Collections.Generic.IEnumerable{Ninject.Parameters.IParameter},System.Boolean,System.Boolean)">
<summary>
Creates a request for the specified service.
@ -3894,6 +4331,13 @@
<param name="service">The service.</param>
<returns><c>True</c> if the missing binding can be handled; otherwise <c>false</c>.</returns>
</member>
<member name="M:Ninject.KernelBase.HandleMissingBinding(Ninject.Activation.IRequest)">
<summary>
Attempts to handle a missing binding for a request.
</summary>
<param name="request">The request.</param>
<returns><c>True</c> if the missing binding can be handled; otherwise <c>false</c>.</returns>
</member>
<member name="M:Ninject.KernelBase.TypeIsSelfBindable(System.Type)">
<summary>
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.
</summary>
</member>
<member name="P:Ninject.NinjectSettings.InjectParentPrivateProperties">
<summary>
Gets a value indicating whether Ninject should inject private properties of base classes.
</summary>
<remarks>
Activating this setting has an impact on the performance. It is recomended not
to use this feature and use constructor injection instead.
</remarks>
</member>
<member name="P:Ninject.NinjectSettings.ActivationCacheDisabled">
<summary>
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 =&gt; kernel.Get{IA}();
</summary>
<value>
<c>true</c> if activation cache is disabled; otherwise, <c>false</c>.
</value>
</member>
<member name="P:Ninject.NinjectSettings.AllowNullInjection">
<summary>
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.
</summary>
<value>
<c>true</c> if null is allowed as injected value otherwise false.
</value>
</member>
<member name="T:Ninject.OnePerRequestModule">
<summary>
Provides callbacks to more aggressively collect objects scoped to HTTP requests.

View File

@ -121,17 +121,13 @@
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="Castle.Core, Version=2.5.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Libraries\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="Exceptioneer.WindowsFormsClient, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Libraries\Exceptioneer.WindowsFormsClient.dll</HintPath>
</Reference>
<Reference Include="Gallio, Version=3.2.0.0, Culture=neutral, PublicKeyToken=eb9cfa67ee6ab36e, processorArchitecture=MSIL" />
<Reference Include="MbUnit, Version=3.2.0.0, Culture=neutral, PublicKeyToken=eb9cfa67ee6ab36e, processorArchitecture=MSIL" />
<Reference Include="Ninject, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL" />
<Reference Include="Ninject, Version=2.1.0.76, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL" />
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL" />
<Reference Include="NLog.Extended, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
@ -219,7 +215,6 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Content Include="Libraries\Castle.Core.dll" />
<Content Include="Libraries\Exceptioneer.WindowsFormsClient.dll" />
<Content Include="Libraries\Ninject.dll" />
<Content Include="Libraries\Ninject.xml" />

View File

@ -0,0 +1,50 @@
//
// Authors: Nate Kohari <nate@enkari.com>, Remo Gloor <remo.gloor@gmail.com>
// 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;
/// <summary>
/// Missing binding resolver that creates a binding for unknown controllers.
/// </summary>
public class ControllerMissingBindingResolver : NinjectComponent, IMissingBindingResolver
{
/// <summary>
/// Returns any bindings from the specified collection that match the specified request.
/// </summary>
/// <param name="bindings">The multimap of all registered bindings.</param>
/// <param name="request">The request in question.</param>
/// <returns>The series of matching bindings.</returns>
public IEnumerable<IBinding> Resolve(Multimap<Type, IBinding> 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<NinjectAsyncActionInvoker>())
: new PropertyValue("ActionInvoker", ctx => ctx.Kernel.Get<NinjectActionInvoker>()));
return new[] { binding };
}
return Enumerable.Empty<IBinding>();
}
}
}

View File

@ -0,0 +1,60 @@
//
// Authors: Nate Kohari <nate@enkari.com>, Remo Gloor <remo.gloor@gmail.com>
// 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;
/// <summary>
/// Injects all filters of a filter info.
/// </summary>
public class FilterInjector : IFilterInjector
{
/// <summary>
/// The kernel
/// </summary>
private readonly IKernel kernel;
/// <summary>
/// Initializes a new instance of the <see cref="FilterInjector"/> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
public FilterInjector(IKernel kernel)
{
this.kernel = kernel;
}
/// <summary>
/// Injects all filters of the specified filter info.
/// </summary>
/// <param name="filterInfo">The filter info.</param>
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);
}
}
}
}

View File

@ -0,0 +1,24 @@
//
// Authors: Nate Kohari <nate@enkari.com>, Remo Gloor <remo.gloor@gmail.com>
// 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;
/// <summary>
/// Injects all filters of a FiltorInfo.
/// </summary>
public interface IFilterInjector
{
/// <summary>
/// Injects all filters of the specified filter info.
/// </summary>
/// <param name="filterInfo">The filter info.</param>
void Inject(FilterInfo filterInfo);
}
}

View File

@ -1,4 +1,3 @@
#region License
//
// Authors: Nate Kohari <nate@enkari.com>, Josh Close <narshe@gmail.com>
// 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
{
/// <summary>
/// An <see cref="IActionInvoker"/> that injects filters with dependencies.
/// </summary>
public class NinjectActionInvoker : ControllerActionInvoker
{
/// <summary>
/// Gets or sets the kernel.
/// </summary>
public IKernel Kernel { get; private set; }
using System.Web.Mvc;
/// <summary>
/// An <see cref="IActionInvoker"/> that injects filters with dependencies.
/// </summary>
public class NinjectActionInvoker : ControllerActionInvoker
{
private readonly IFilterInjector filterInjector;
/// <summary>
/// Initializes a new instance of the <see cref="NinjectActionInvoker"/> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
public NinjectActionInvoker(IKernel kernel)
{
Kernel = kernel;
}
/// <summary>
/// Initializes a new instance of the <see cref="NinjectActionInvoker"/> class.
/// </summary>
/// <param name="filterInjector">The filter injector.</param>
public NinjectActionInvoker(IFilterInjector filterInjector)
{
this.filterInjector = filterInjector;
}
/// <summary>
/// Gets the filters for the specified request and action.
/// </summary>
/// <param name="controllerContext">The controller context.</param>
/// <param name="actionDescriptor">The action descriptor.</param>
/// <returns>The filters.</returns>
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;
}
}
/// <summary>
/// Gets the filters for the specified request and action.
/// </summary>
/// <param name="controllerContext">The controller context.</param>
/// <param name="actionDescriptor">The action descriptor.</param>
/// <returns>The filters.</returns>
protected override FilterInfo GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
{
FilterInfo filterInfo = base.GetFilters(controllerContext, actionDescriptor);
this.filterInjector.Inject(filterInfo);
return filterInfo;
}
}
}

View File

@ -0,0 +1,43 @@
//
// Authors: Nate Kohari <nate@enkari.com>, Josh Close <narshe@gmail.com>
// 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;
/// <summary>
/// An <see cref="IActionInvoker"/> that injects filters with dependencies.
/// </summary>
public class NinjectAsyncActionInvoker : AsyncControllerActionInvoker
{
private readonly IFilterInjector filterInjector;
/// <summary>
/// Initializes a new instance of the <see cref="NinjectAsyncActionInvoker"/> class.
/// </summary>
/// <param name="filterInjector">The filter injector.</param>
public NinjectAsyncActionInvoker(IFilterInjector filterInjector)
{
this.filterInjector = filterInjector;
}
/// <summary>
/// Gets the filters for the specified request and action.
/// </summary>
/// <param name="controllerContext">The controller context.</param>
/// <param name="actionDescriptor">The action descriptor.</param>
/// <returns>The filters.</returns>
protected override FilterInfo GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
{
FilterInfo filterInfo = base.GetFilters(controllerContext, actionDescriptor);
this.filterInjector.Inject(filterInfo);
return filterInfo;
}
}
}

View File

@ -1,4 +1,3 @@
#region License
//
// Authors: Nate Kohari <nate@enkari.com>, Josh Close <narshe@gmail.com>
// 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;
/// <summary>
/// A controller factory that creates <see cref="IController"/>s via Ninject.
/// </summary>
public class NinjectControllerFactory : DefaultControllerFactory
{
/// <summary>
/// Gets the kernel that will be used to create controllers.
/// </summary>
public IKernel Kernel { get; private set; }
/// A controller factory that creates <see cref="IController"/>s via Ninject.
/// </summary>
public class NinjectControllerFactory : DefaultControllerFactory
{
/// <summary>
/// Gets the kernel that will be used to create controllers.
/// </summary>
public IKernel Kernel { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="NinjectControllerFactory"/> class.
/// </summary>
/// <param name="kernel">The kernel that should be used to create controllers.</param>
public NinjectControllerFactory(IKernel kernel)
{
Kernel = kernel;
}
/// <summary>
/// Initializes a new instance of the <see cref="NinjectControllerFactory"/> class.
/// </summary>
/// <param name="kernel">The kernel that should be used to create controllers.</param>
public NinjectControllerFactory(IKernel kernel)
{
Kernel = kernel;
}
/// <summary>
/// Gets a controller instance of type controllerType.
/// </summary>
/// <param name="requestContext">The request context.</param>
/// <param name="controllerType">Type of controller to create.</param>
/// <returns>The controller instance.</returns>
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
{
if (controllerType == null)
/// <summary>
/// Gets a controller instance of type controllerType.
/// </summary>
/// <param name="requestContext">The request context.</param>
/// <param name="controllerType">Type of controller to create.</param>
/// <returns>The controller instance.</returns>
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.TryGet(controllerType) as IController;
if (controller == null)
return base.GetControllerInstance(requestContext, controllerType);
/*
var asyncController = controller as AsyncController;
if (asyncController != null)
{
// let the base handle 404 errors with proper culture information
return base.GetControllerInstance(requestContext, controllerType);
asyncController.ActionInvoker = this.CreateAsyncActionInvoker();
}
else
{
var standardController = controller as Controller;
if (standardController != null)
standardController.ActionInvoker = CreateActionInvoker();
}*/
var controller = Kernel.GetService(controllerType) as IController;
return controller;
}
if (controller == null)
return base.GetControllerInstance(requestContext, controllerType);
var standardController = controller as Controller;
if (standardController != null)
standardController.ActionInvoker = CreateActionInvoker();
return controller;
}
/*
/// <summary>
/// Creates the action invoker.
/// </summary>
/// <returns>The action invoker.</returns>
protected virtual NinjectActionInvoker CreateActionInvoker()
{
return new NinjectActionInvoker(Kernel);
}
/// <summary>
/// Creates the action invoker.
/// </summary>
/// <returns>The action invoker.</returns>
protected virtual NinjectActionInvoker CreateActionInvoker()
protected virtual NinjectAsyncActionInvoker CreateAsyncActionInvoker()
{
return new NinjectActionInvoker(Kernel);
}
return new NinjectAsyncActionInvoker(Kernel);
}*/
}
}

View File

@ -16,7 +16,9 @@ using Ninject.Infrastructure;
namespace Ninject.Web.Mvc
{
/// <summary>
using Ninject.Planning.Bindings.Resolvers;
/// <summary>
/// Defines an <see cref="HttpApplication"/> that is controlled by a Ninject <see cref="IKernel"/>.
/// </summary>
public abstract class NinjectHttpApplication : HttpApplication, IHaveKernel
@ -40,9 +42,14 @@ namespace Ninject.Web.Mvc
{
_kernel = CreateKernel();
_kernel.Bind<RouteCollection>().ToConstant(RouteTable.Routes);
_kernel.Components.RemoveAll<IMissingBindingResolver>();
_kernel.Components.Add<IMissingBindingResolver, ControllerMissingBindingResolver>();
_kernel.Components.Add<IMissingBindingResolver, SelfBindingResolver>();
_kernel.Bind<RouteCollection>().ToConstant(RouteTable.Routes);
_kernel.Bind<HttpContext>().ToMethod(ctx => HttpContext.Current).InTransientScope();
_kernel.Bind<HttpContextBase>().ToMethod(ctx => new HttpContextWrapper(HttpContext.Current)).InTransientScope();
_kernel.Bind<IFilterInjector>().To<FilterInjector>().InSingletonScope();
ControllerBuilder.Current.SetControllerFactory(CreateControllerFactory());
@ -53,9 +60,9 @@ namespace Ninject.Web.Mvc
}
/// <summary>
/// Stops the application.
/// Releases the kernel on application end.
/// </summary>
public void Application_Stop()
public void Application_End()
{
lock (this)
{

View File

@ -36,10 +36,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Ninject, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\NzbDrone.Core\Libraries\Ninject.dll</HintPath>
</Reference>
<Reference Include="Ninject, Version=2.1.0.76, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL" />
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Data" />
@ -86,7 +83,11 @@
<Compile Include="Helpers\IsCurrentActionHelper.cs" />
<Compile Include="Models\AccountModels.cs" />
<Compile Include="Models\SettingsModels.cs" />
<Compile Include="Ninject.Web.Mvc\ControllerMissingBindingResolver.cs" />
<Compile Include="Ninject.Web.Mvc\FilterInjector.cs" />
<Compile Include="Ninject.Web.Mvc\IFilterInjector.cs" />
<Compile Include="Ninject.Web.Mvc\NinjectActionInvoker.cs" />
<Compile Include="Ninject.Web.Mvc\NinjectAsyncActionInvoker.cs" />
<Compile Include="Ninject.Web.Mvc\NinjectControllerFactory.cs" />
<Compile Include="Ninject.Web.Mvc\NinjectHttpApplication.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />