diff --git a/Autofac.Integration.Mvc/Autofac.Integration.Mvc.csproj b/Autofac.Integration.Mvc/Autofac.Integration.Mvc.csproj deleted file mode 100644 index d3b39d592..000000000 --- a/Autofac.Integration.Mvc/Autofac.Integration.Mvc.csproj +++ /dev/null @@ -1,118 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {DD874E64-C7EC-464D-925F-CF4A709EDEEF} - Library - Properties - Autofac.Integration.Mvc - Autofac.Integration.Mvc - v4.0 - 512 - ..\..\..\ - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - ..\..\..\Build\Full.ruleset - false - bin\Debug\Autofac.Integration.Mvc.xml - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - ..\..\..\Build\Full.ruleset - false - bin\Release\Autofac.Integration.Mvc.xml - false - - - false - - - ..\..\..\Build\SharedKey.snk - - - - ..\packages\Autofac.3.0.1\lib\net40\Autofac.dll - - - False - ..\Libraries\MVC3\Microsoft.Web.Infrastructure.dll - - - - - - False - ..\Libraries\MVC3\System.Web.Mvc.dll - - - False - ..\Libraries\MVC3\System.Web.WebPages.dll - - - - - - - - - - True - True - RegistrationExtensionsResources.resx - - - - - - - - - - - True - True - RequestLifetimeScopeProviderResources.resx - - - - - - ResXFileCodeGenerator - RegistrationExtensionsResources.Designer.cs - - - ResXFileCodeGenerator - RequestLifetimeScopeProviderResources.Designer.cs - Designer - - - - - - - - - \ No newline at end of file diff --git a/Autofac.Integration.Mvc/AutofacDependencyResolver.cs b/Autofac.Integration.Mvc/AutofacDependencyResolver.cs deleted file mode 100644 index e46a2c2a1..000000000 --- a/Autofac.Integration.Mvc/AutofacDependencyResolver.cs +++ /dev/null @@ -1,164 +0,0 @@ -// This software is part of the Autofac IoC container -// Copyright © 2011 Autofac Contributors -// http://autofac.org -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; -using System.Collections.Generic; -using System.Web.Mvc; - -namespace Autofac.Integration.Mvc -{ - /// - /// Autofac implementation of the interface. - /// - public class AutofacDependencyResolver : IDependencyResolver - { - readonly ILifetimeScope _container; - readonly Action _configurationAction; - ILifetimeScopeProvider _lifetimeScopeProvider; - - /// - /// Initializes a new instance of the class. - /// - /// The container that nested lifetime scopes will be create from. - public AutofacDependencyResolver(ILifetimeScope container) - { - if (container == null) throw new ArgumentNullException("container"); - _container = container; - } - - /// - /// Initializes a new instance of the class. - /// - /// The container that nested lifetime scopes will be create from. - /// Action on a - /// that adds component registations visible only in nested lifetime scopes. - public AutofacDependencyResolver(ILifetimeScope container, Action configurationAction) - : this(container) - { - if (configurationAction == null) throw new ArgumentNullException("configurationAction"); - _configurationAction = configurationAction; - } - - /// - /// Initializes a new instance of the class. - /// - /// The container that nested lifetime scopes will be create from. - /// A implementation for - /// creating new lifetime scopes. - public AutofacDependencyResolver(ILifetimeScope container, ILifetimeScopeProvider lifetimeScopeProvider) : - this(container) - { - if (lifetimeScopeProvider == null) throw new ArgumentNullException("lifetimeScopeProvider"); - _lifetimeScopeProvider = lifetimeScopeProvider; - } - - /// - /// Initializes a new instance of the class. - /// - /// The container that nested lifetime scopes will be create from. - /// A implementation for - /// creating new lifetime scopes. - /// Action on a - /// that adds component registations visible only in nested lifetime scopes. - public AutofacDependencyResolver(ILifetimeScope container, ILifetimeScopeProvider lifetimeScopeProvider, Action configurationAction) - : this(container, lifetimeScopeProvider) - { - if (configurationAction == null) throw new ArgumentNullException("configurationAction"); - _configurationAction = configurationAction; - } - - /// - /// Gets the Autofac implementation of the dependency resolver. - /// - public static AutofacDependencyResolver Current - { - get - { - // Issue 351: We can't necessarily cast the current dependency resolver - // to AutofacDependencyResolver because diagnostic systems like Glimpse - // will wrap/proxy the resolver. Instead we need to register the resolver - // on the fly with the request lifetime scope and resolve it accordingly. - return DependencyResolver.Current.GetService(); - } - } - - /// - /// The lifetime containing components for processing the current HTTP request. - /// - public ILifetimeScope RequestLifetimeScope - { - get - { - // Issue 351: Register the AutofacDependencyResolver with - // the request lifetime scope so the current resolver can - // be retrieved without having to cast it directly to - // this specific type. - Action composite = builder => - { - if (this._configurationAction != null) - { - this._configurationAction(builder); - } - builder.RegisterInstance(this).As(); - }; - if (_lifetimeScopeProvider == null) - { - _lifetimeScopeProvider = new RequestLifetimeScopeProvider(_container); - } - return _lifetimeScopeProvider.GetLifetimeScope(composite); - } - } - - /// - /// Gets the application container that was provided to the constructor. - /// - public ILifetimeScope ApplicationContainer - { - get { return _container; } - } - - /// - /// Get a single instance of a service. - /// - /// Type of the service. - /// The single instance if resolved; otherwise, null. - public object GetService(Type serviceType) - { - return RequestLifetimeScope.ResolveOptional(serviceType); - } - - /// - /// Gets all available instances of a services. - /// - /// Type of the service. - /// The list of instances if any were resolved; otherwise, an empty list. - public IEnumerable GetServices(Type serviceType) - { - var enumerableServiceType = typeof(IEnumerable<>).MakeGenericType(serviceType); - var instance = RequestLifetimeScope.Resolve(enumerableServiceType); - return (IEnumerable)instance; - } - } -} diff --git a/Autofac.Integration.Mvc/AutofacFilterProvider.cs b/Autofac.Integration.Mvc/AutofacFilterProvider.cs deleted file mode 100644 index c6ad44cae..000000000 --- a/Autofac.Integration.Mvc/AutofacFilterProvider.cs +++ /dev/null @@ -1,171 +0,0 @@ -// This software is part of the Autofac IoC container -// Copyright © 2012 Autofac Contributors -// http://autofac.org -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Web.Mvc; -using System.Web.Mvc.Async; -using Autofac.Features.Metadata; - -namespace Autofac.Integration.Mvc -{ - /// - /// Defines a filter provider for filter attributes that performs property injection. - /// - public class AutofacFilterProvider : FilterAttributeFilterProvider - { - class FilterContext - { - public ActionDescriptor ActionDescriptor { get; set; } - public ILifetimeScope LifetimeScope { get; set; } - public Type ControllerType { get; set; } - public List Filters { get; set; } - } - - internal static string ActionFilterMetadataKey = "AutofacMvcActionFilter"; - - internal static string AuthorizationFilterMetadataKey = "AutofacMvcAuthorizationFilter"; - - internal static string ExceptionFilterMetadataKey = "AutofacMvcExceptionFilter"; - - internal static string ResultFilterMetadataKey = "AutofacMvcResultFilter"; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The false constructor parameter passed to base here ensures that attribute instances are not cached. - /// - public AutofacFilterProvider() : base(false) - { - } - - /// - /// Aggregates the filters from all of the filter providers into one collection. - /// - /// The controller context. - /// The action descriptor. - /// - /// The collection filters from all of the filter providers with properties injected. - /// - /// - /// Thrown if is . - /// - public override IEnumerable GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor) - { - if (controllerContext == null) - { - throw new ArgumentNullException("controllerContext"); - } - var filters = base.GetFilters(controllerContext, actionDescriptor).ToList(); - var lifetimeScope = AutofacDependencyResolver.Current.RequestLifetimeScope; - - if (lifetimeScope != null) - { - foreach (var filter in filters) - lifetimeScope.InjectProperties(filter.Instance); - - var controllerType = controllerContext.Controller.GetType(); - - var filterContext = new FilterContext - { - ActionDescriptor = actionDescriptor, - LifetimeScope = lifetimeScope, - ControllerType = controllerType, - Filters = filters - }; - - ResolveControllerScopedFilters(filterContext); - - ResolveActionScopedFilters(filterContext, d => d.MethodInfo); - ResolveActionScopedFilters(filterContext, d => d.AsyncMethodInfo); - } - - return filters.ToArray(); - } - - static void ResolveControllerScopedFilters(FilterContext filterContext) - { - ResolveControllerScopedFilter(filterContext, ActionFilterMetadataKey); - ResolveControllerScopedFilter(filterContext, AuthorizationFilterMetadataKey); - ResolveControllerScopedFilter(filterContext, ExceptionFilterMetadataKey); - ResolveControllerScopedFilter(filterContext, ResultFilterMetadataKey); - } - - static void ResolveControllerScopedFilter(FilterContext filterContext, string metadataKey) - where TFilter : class - { - var actionFilters = filterContext.LifetimeScope.Resolve>>>(); - - foreach (var actionFilter in actionFilters.Where(a => a.Metadata.ContainsKey(metadataKey) && a.Metadata[metadataKey] is FilterMetadata)) - { - var metadata = (FilterMetadata)actionFilter.Metadata[metadataKey]; - if (metadata.ControllerType != null - && metadata.ControllerType.IsAssignableFrom(filterContext.ControllerType) - && metadata.FilterScope == FilterScope.Controller - && metadata.MethodInfo == null) - { - var filter = new Filter(actionFilter.Value.Value, FilterScope.Controller, metadata.Order); - filterContext.Filters.Add(filter); - } - } - } - - static void ResolveActionScopedFilters(FilterContext filterContext, Func methodSelector) - where T : ActionDescriptor - { - var actionDescriptor = filterContext.ActionDescriptor as T; - if (actionDescriptor == null) return; - - var methodInfo = methodSelector(actionDescriptor); - - ResolveActionScopedFilter(filterContext, methodInfo, ActionFilterMetadataKey); - ResolveActionScopedFilter(filterContext, methodInfo, AuthorizationFilterMetadataKey); - ResolveActionScopedFilter(filterContext, methodInfo, ExceptionFilterMetadataKey); - ResolveActionScopedFilter(filterContext, methodInfo, ResultFilterMetadataKey); - } - - static void ResolveActionScopedFilter(FilterContext filterContext, MethodInfo methodInfo, string metadataKey) - where TFilter : class - { - var actionFilters = filterContext.LifetimeScope.Resolve>>>(); - - foreach (var actionFilter in actionFilters.Where(a => a.Metadata.ContainsKey(metadataKey) && a.Metadata[metadataKey] is FilterMetadata)) - { - var metadata = (FilterMetadata)actionFilter.Metadata[metadataKey]; - if (metadata.ControllerType != null - && metadata.ControllerType.IsAssignableFrom(filterContext.ControllerType) - && metadata.FilterScope == FilterScope.Action - && metadata.MethodInfo.GetBaseDefinition() == methodInfo.GetBaseDefinition()) - { - var filter = new Filter(actionFilter.Value.Value, FilterScope.Action, metadata.Order); - filterContext.Filters.Add(filter); - } - } - } - } -} diff --git a/Autofac.Integration.Mvc/AutofacModelBinderProvider.cs b/Autofac.Integration.Mvc/AutofacModelBinderProvider.cs deleted file mode 100644 index 3323ee4f4..000000000 --- a/Autofac.Integration.Mvc/AutofacModelBinderProvider.cs +++ /dev/null @@ -1,59 +0,0 @@ -// This software is part of the Autofac IoC container -// Copyright © 2011 Autofac Contributors -// http://autofac.org -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web.Mvc; -using Autofac.Features.Metadata; - -namespace Autofac.Integration.Mvc -{ - /// - /// Autofac implementation of the interface. - /// - public class AutofacModelBinderProvider : IModelBinderProvider - { - /// - /// Metadata key for the supported model types. - /// - internal static readonly string MetadataKey = "SupportedModelTypes"; - - /// - /// Gets the model binder associated with the provided model type. - /// - /// Type of the model. - /// An instance if found; otherwise, null. - public IModelBinder GetBinder(Type modelType) - { - var modelBinders = DependencyResolver.Current.GetServices>>(); - - var modelBinder = modelBinders - .Where(binder => binder.Metadata.ContainsKey(MetadataKey)) - .FirstOrDefault(binder => ((List)binder.Metadata[MetadataKey]).Contains(modelType)); - return (modelBinder != null) ? modelBinder.Value.Value : null; - } - } -} \ No newline at end of file diff --git a/Autofac.Integration.Mvc/AutofacWebTypesModule.cs b/Autofac.Integration.Mvc/AutofacWebTypesModule.cs deleted file mode 100644 index b362b0564..000000000 --- a/Autofac.Integration.Mvc/AutofacWebTypesModule.cs +++ /dev/null @@ -1,178 +0,0 @@ -// This software is part of the Autofac IoC container -// Copyright © 2011 Autofac Contributors -// http://autofac.org -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System.Web; -using System.Web.Hosting; -using System.Web.Mvc; -using System.Web.Routing; - -namespace Autofac.Integration.Mvc -{ - /// - /// Dependency injection module that registers abstractions for common - /// web application properties. - /// - /// - /// - /// This is primarily used during - /// application startup (in Global.asax) to register - /// mappings from commonly referenced contextual application properties - /// to their corresponding abstraction. - /// - /// - /// The following mappings are made: - /// - /// - /// - /// Common Construct - /// Abstraction - /// - /// - /// HttpContext.Current - /// - /// - /// - /// HttpContext.Current.Application - /// - /// - /// - /// HttpContext.Current.Request - /// - /// - /// - /// HttpContext.Current.Request.Browser - /// - /// - /// - /// HttpContext.Current.Request.Files - /// - /// - /// - /// HttpContext.Current.Request.RequestContext - /// - /// - /// - /// HttpContext.Current.Response - /// - /// - /// - /// HttpContext.Current.Response.Cache - /// - /// - /// - /// HttpContext.Current.Server - /// - /// - /// - /// HttpContext.Current.Session - /// - /// - /// - /// HostingEnvironment.VirtualPathProvider - /// - /// - /// - /// - /// In addition, the type is registered - /// for construction based on the current . - /// - /// - /// The lifetime for each of these items is one web request. - /// - /// - public class AutofacWebTypesModule : Module - { - /// - /// Registers web abstractions with dependency injection. - /// - /// - /// The in which registration - /// should take place. - /// - /// - /// - /// This method registers mappings between common current context-related - /// web constructs and their associated abstract counterparts. See - /// for the complete - /// list of mappings that get registered. - /// - /// - protected override void Load(ContainerBuilder builder) - { - builder.Register(c => new HttpContextWrapper(HttpContext.Current)) - .As() - .InstancePerHttpRequest(); - - // HttpContext properties - builder.Register(c => c.Resolve().Request) - .As() - .InstancePerHttpRequest(); - - builder.Register(c => c.Resolve().Response) - .As() - .InstancePerHttpRequest(); - - builder.Register(c => c.Resolve().Server) - .As() - .InstancePerHttpRequest(); - - builder.Register(c => c.Resolve().Session) - .As() - .InstancePerHttpRequest(); - - builder.Register(c => c.Resolve().Application) - .As() - .InstancePerHttpRequest(); - - // HttpRequest properties - builder.Register(c => c.Resolve().Browser) - .As() - .InstancePerHttpRequest(); - - builder.Register(c => c.Resolve().Files) - .As() - .InstancePerHttpRequest(); - - builder.Register(c => c.Resolve().RequestContext) - .As() - .InstancePerHttpRequest(); - - // HttpResponse properties - builder.Register(c => c.Resolve().Cache) - .As() - .InstancePerHttpRequest(); - - // HostingEnvironment properties - builder.Register(c => HostingEnvironment.VirtualPathProvider) - .As() - .InstancePerHttpRequest(); - - // MVC types - builder.Register(c => new UrlHelper(c.Resolve())) - .As() - .InstancePerHttpRequest(); - } - } -} diff --git a/Autofac.Integration.Mvc/ExtensibleActionInvoker.cs b/Autofac.Integration.Mvc/ExtensibleActionInvoker.cs deleted file mode 100644 index 179d72f3a..000000000 --- a/Autofac.Integration.Mvc/ExtensibleActionInvoker.cs +++ /dev/null @@ -1,87 +0,0 @@ -// This software is part of the Autofac IoC container -// Copyright © 2011 Autofac Contributors -// http://autofac.org -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; -using System.Web.Mvc; - -namespace Autofac.Integration.Mvc -{ - /// - /// Injects services from the container into the ASP.NET MVC invocation pipeline. - /// This is a Async Controller Action Invoker which can be used for both async and non-async scenarios - /// - /// - /// - /// Action methods can include parameters that will be resolved from the - /// container, along with regular parameters. - /// - /// - public class ExtensibleActionInvoker : System.Web.Mvc.Async.AsyncControllerActionInvoker - { - /// - /// Gets the parameter value. - /// - /// The controller context.The parameter descriptor. - /// - /// The parameter value. - /// - /// - /// Thrown if is . - /// - protected override object GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) - { - if (parameterDescriptor == null) - { - throw new ArgumentNullException("parameterDescriptor"); - } - - // Only resolve parameter values if injection is enabled. - var context = AutofacDependencyResolver.Current.RequestLifetimeScope; - var value = context.ResolveOptional(parameterDescriptor.ParameterType); - - if (value == null) - { - // Issue #368 - // If injection is enabled and the value can't be resolved, fall back to - // the default behavior. Or if injection isn't enabled, fall back. - // Unfortunately we can't do much to pre-determine if model binding will succeed - // because model binding "knows" about a lot of stuff like arrays, certain generic - // collection types, type converters, and other stuff that may or may not fail. - try - { - value = base.GetParameterValue(controllerContext, parameterDescriptor); - } - catch (MissingMethodException) - { - // Don't do anything - this means the default model binder couldn't - // activate a new instance or figure out some other way to model - // bind it. - } - } - - return value; - } - } -} \ No newline at end of file diff --git a/Autofac.Integration.Mvc/FilterMetadata.cs b/Autofac.Integration.Mvc/FilterMetadata.cs deleted file mode 100644 index e7bda5bfb..000000000 --- a/Autofac.Integration.Mvc/FilterMetadata.cs +++ /dev/null @@ -1,62 +0,0 @@ -// This software is part of the Autofac IoC container -// Copyright © 2012 Autofac Contributors -// http://autofac.org -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; -using System.ComponentModel; -using System.Reflection; -using System.Web.Mvc; - -namespace Autofac.Integration.Mvc -{ - /// - /// Metadata interface for filter registrations. - /// - internal class FilterMetadata - { - /// - /// Gets the type of the controller. - /// - [DefaultValue(null)] - public Type ControllerType { get; set; } - - /// - /// Gets the filter scope. - /// - [DefaultValue(FilterScope.First)] - public FilterScope FilterScope { get; set; } - - /// - /// Gets the method info. - /// - [DefaultValue(null)] - public MethodInfo MethodInfo { get; set; } - - /// - /// Gets the order in which the filter is applied. - /// - [DefaultValue(-1)] - public int Order { get; set; } - } -} \ No newline at end of file diff --git a/Autofac.Integration.Mvc/ILifetimeScopeProvider.cs b/Autofac.Integration.Mvc/ILifetimeScopeProvider.cs deleted file mode 100644 index b55174d17..000000000 --- a/Autofac.Integration.Mvc/ILifetimeScopeProvider.cs +++ /dev/null @@ -1,56 +0,0 @@ -// This software is part of the Autofac IoC container -// Copyright © 2011 Autofac Contributors -// http://autofac.org -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; -using System.Diagnostics.CodeAnalysis; - -namespace Autofac.Integration.Mvc -{ - /// - /// Implementors are able to control the creation of nested lifetime scopes. - /// - public interface ILifetimeScopeProvider - { - /// - /// Gets a nested lifetime scope that services can be resolved from. - /// - /// - /// A configuration action that will execute during lifetime scope creation. - /// - /// A new or existing nested lifetime scope. - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] - ILifetimeScope GetLifetimeScope(Action configurationAction); - - /// - /// Ends the current lifetime scope. - /// - void EndLifetimeScope(); - - /// - /// Gets the global, application-wide container. - /// - ILifetimeScope ApplicationContainer { get; } - } -} \ No newline at end of file diff --git a/Autofac.Integration.Mvc/ModelBinderTypeAttribute.cs b/Autofac.Integration.Mvc/ModelBinderTypeAttribute.cs deleted file mode 100644 index cd2537ae7..000000000 --- a/Autofac.Integration.Mvc/ModelBinderTypeAttribute.cs +++ /dev/null @@ -1,64 +0,0 @@ -// This software is part of the Autofac IoC container -// Copyright © 2011 Autofac Contributors -// http://autofac.org -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; - -namespace Autofac.Integration.Mvc -{ - /// - /// Indicates what types a model binder supports. - /// - [SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments")] - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)] - public sealed class ModelBinderTypeAttribute : Attribute - { - /// - /// Gets the target types. - /// - public IEnumerable TargetTypes { get; private set; } - - /// - /// Initializes a new instance of the class. - /// - /// The target types. - public ModelBinderTypeAttribute(params Type[] targetTypes) - { - if (targetTypes == null) throw new ArgumentNullException("targetTypes"); - TargetTypes = targetTypes; - } - - /// - /// Initializes a new instance of the class. - /// - /// The target type. - public ModelBinderTypeAttribute(Type targetType) - { - if (targetType == null) throw new ArgumentNullException("targetType"); - TargetTypes = new Type[] { targetType }; - } - } -} diff --git a/Autofac.Integration.Mvc/PreApplicationStartCode.cs b/Autofac.Integration.Mvc/PreApplicationStartCode.cs deleted file mode 100644 index cc196b096..000000000 --- a/Autofac.Integration.Mvc/PreApplicationStartCode.cs +++ /dev/null @@ -1,51 +0,0 @@ -// This software is part of the Autofac IoC container -// Copyright © 2011 Autofac Contributors -// http://autofac.org -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System.ComponentModel; -using Microsoft.Web.Infrastructure.DynamicModuleHelper; - -namespace Autofac.Integration.Mvc -{ - /// - /// Container class for the ASP.NET application startup method. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static class PreApplicationStartCode - { - private static bool _startWasCalled; - - /// - /// Performs ASP.NET application startup logic early in the pipeline. - /// - public static void Start() - { - // Guard against multiple calls. All Start calls are made on the same thread, so no lock needed here. - if (_startWasCalled) return; - - _startWasCalled = true; - DynamicModuleUtility.RegisterModule(typeof(RequestLifetimeHttpModule)); - } - } -} diff --git a/Autofac.Integration.Mvc/Properties/AssemblyInfo.cs b/Autofac.Integration.Mvc/Properties/AssemblyInfo.cs deleted file mode 100644 index 4ba3cc441..000000000 --- a/Autofac.Integration.Mvc/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Web; -using Autofac.Integration.Mvc; - -[assembly: AssemblyTitle("Autofac.Integration.Mvc")] -[assembly: AssemblyDescription("Autofac ASP.NET MVC 4 Integration")] -[assembly: InternalsVisibleTo("Autofac.Tests.Integration.Mvc, PublicKey=00240000048000009400000006020000002400005253413100040000010001008728425885ef385e049261b18878327dfaaf0d666dea3bd2b0e4f18b33929ad4e5fbc9087e7eda3c1291d2de579206d9b4292456abffbe8be6c7060b36da0c33b883e3878eaf7c89fddf29e6e27d24588e81e86f3a22dd7b1a296b5f06fbfb500bbd7410faa7213ef4e2ce7622aefc03169b0324bcd30ccfe9ac8204e4960be6")] -[assembly: PreApplicationStartMethod(typeof(PreApplicationStartCode), "Start")] -[assembly: ComVisible(false)] diff --git a/Autofac.Integration.Mvc/RegistrationExtensions.cs b/Autofac.Integration.Mvc/RegistrationExtensions.cs deleted file mode 100644 index f1f5c4cd1..000000000 --- a/Autofac.Integration.Mvc/RegistrationExtensions.cs +++ /dev/null @@ -1,510 +0,0 @@ -// This software is part of the Autofac IoC container -// Copyright © 2011 Autofac Contributors -// http://autofac.org -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.Linq; -using System.Linq.Expressions; -using System.Reflection; -using System.Web; -using System.Web.Mvc; -using Autofac.Builder; -using Autofac.Core; -using Autofac.Features.Scanning; - -namespace Autofac.Integration.Mvc -{ - /// - /// Extends with methods to support ASP.NET MVC. - /// - public static class RegistrationExtensions - { - /// - /// Share one instance of the component within the context of a single - /// HTTP request. - /// - /// Registration limit type. - /// Registration style. - /// Activator data type. - /// The registration to configure. - /// A registration builder allowing further configuration of the component. - public static IRegistrationBuilder - InstancePerHttpRequest( - this IRegistrationBuilder registration) - { - if (registration == null) throw new ArgumentNullException("registration"); - - return registration.InstancePerMatchingLifetimeScope(RequestLifetimeScopeProvider.HttpRequestTag); - } - - /// - /// Register types that implement IController in the provided assemblies. - /// - /// The container builder. - /// Assemblies to scan for controllers. - /// Registration builder allowing the controller components to be customised. - public static IRegistrationBuilder - RegisterControllers( - this ContainerBuilder builder, - params Assembly[] controllerAssemblies) - { - return builder.RegisterAssemblyTypes(controllerAssemblies) - .Where(t => typeof(IController).IsAssignableFrom(t) && - t.Name.EndsWith("Controller", StringComparison.Ordinal)); - } - - /// - /// Inject an IActionInvoker into the controller's ActionInvoker property. - /// - /// Limit type. - /// Activator data. - /// Registration style. - /// The registration builder. - /// A registration builder. - public static IRegistrationBuilder - InjectActionInvoker( - this IRegistrationBuilder registrationBuilder) - { - return registrationBuilder.InjectActionInvoker(new TypedService(typeof(IActionInvoker))); - } - - /// - /// Inject an IActionInvoker into the controller's ActionInvoker property. - /// - /// Limit type. - /// Activator data. - /// Registration style. - /// The registration builder. - /// Service used to resolve the action invoker. - /// A registration builder. - public static IRegistrationBuilder - InjectActionInvoker( - this IRegistrationBuilder registrationBuilder, - Service actionInvokerService) - { - if (registrationBuilder == null) throw new ArgumentNullException("registrationBuilder"); - if (actionInvokerService == null) throw new ArgumentNullException("actionInvokerService"); - - return registrationBuilder.OnActivating(e => - { - var controller = e.Instance as Controller; - if (controller != null) - controller.ActionInvoker = (IActionInvoker)e.Context.ResolveService(actionInvokerService); - }); - } - - /// - /// Registers the . - /// - /// The container builder. - public static void RegisterModelBinderProvider(this ContainerBuilder builder) - { - if (builder == null) throw new ArgumentNullException("builder"); - - builder.RegisterType() - .As() - .SingleInstance(); - } - - /// - /// Sets a provided registration to act as an - /// for the specified list of types. - /// - /// - /// The registration for the type or object instance that will act as - /// the model binder. - /// - /// - /// The list of model for which the - /// should be a model binder. - /// - /// - /// Registration limit type. - /// - /// - /// Activator data type. - /// - /// - /// Registration style. - /// - /// - /// An Autofac registration that can be modified as needed. - /// - /// - /// Thrown if or is . - /// - /// - /// Thrown if is empty or contains all - /// values. - /// - /// - /// - /// The declarative mechanism of registering model binders with Autofac - /// is through use of - /// and the . - /// This method is an imperative alternative. - /// - /// - /// The two mechanisms are mutually exclusive. If you register a model - /// binder using - /// and register the same model binder with this method, the results - /// are not automatically merged together - standard dependency - /// registration/resolution rules will be used to manage the conflict. - /// - /// - /// Any values provided in - /// will be removed prior to registration. - /// - /// - public static IRegistrationBuilder AsModelBinderForTypes(this IRegistrationBuilder registration, params Type[] types) - where TActivatorData : IConcreteActivatorData - where TRegistrationStyle : SingleRegistrationStyle - { - if (registration == null) - { - throw new ArgumentNullException("registration"); - } - if (types == null) - { - throw new ArgumentNullException("types"); - } - var typeList = types.Where(type => type != null).ToList(); - if (typeList.Count == 0) - { - throw new ArgumentException(RegistrationExtensionsResources.InvalidModelBinderType, "types"); - } - - return registration.As().WithMetadata(AutofacModelBinderProvider.MetadataKey, typeList); - } - - /// - /// Register types that implement in the provided assemblies - /// and have a . - /// - /// The container builder. - /// Assemblies to scan for model binders. - /// A registration builder. - /// - /// Thrown if or is . - /// - /// - /// - /// The declarative mechanism of registering model binders with Autofac - /// is through use of this method and the - /// . - /// If you would like more imperative control over registration for your - /// model binders, see the - /// method. - /// - /// - /// The two mechanisms are mutually exclusive. If you register a model - /// binder using - /// and register the same model binder with this method, the results - /// are not automatically merged together - standard dependency - /// registration/resolution rules will be used to manage the conflict. - /// - /// - /// This method only registers types that implement - /// and are marked with the . - /// The model binder must have the attribute because the - /// uses - /// the associated metadata - from the attribute(s) - to resolve the - /// binder based on model type. If there aren't any attributes, there - /// won't be any metadata, so the model binder will be technically - /// registered but will never actually be resolved. - /// - /// - /// If your model is not marked with the attribute, or if you don't want - /// to use attributes, use the - /// - /// extension instead. - /// - /// - public static IRegistrationBuilder - RegisterModelBinders(this ContainerBuilder builder, params Assembly[] modelBinderAssemblies) - { - if (builder == null) throw new ArgumentNullException("builder"); - if (modelBinderAssemblies == null) throw new ArgumentNullException("modelBinderAssemblies"); - - return builder.RegisterAssemblyTypes(modelBinderAssemblies) - .Where(type => typeof(IModelBinder).IsAssignableFrom(type) && type.GetCustomAttributes(typeof(ModelBinderTypeAttribute), true).Length > 0) - .As() - .InstancePerHttpRequest() - .WithMetadata(AutofacModelBinderProvider.MetadataKey, type => - (from ModelBinderTypeAttribute attribute in type.GetCustomAttributes(typeof(ModelBinderTypeAttribute), true) - from targetType in attribute.TargetTypes - select targetType).ToList()); - } - - /// - /// Registers the . - /// - /// The container builder. - public static void RegisterFilterProvider(this ContainerBuilder builder) - { - if (builder == null) throw new ArgumentNullException("builder"); - - foreach (var provider in FilterProviders.Providers.OfType().ToArray()) - FilterProviders.Providers.Remove(provider); - - builder.RegisterType() - .As() - .SingleInstance(); - } - - /// - /// Cache instances in the web session. This implies external ownership (disposal is not - /// available.) All dependencies must also have external ownership. - /// - /// - /// It is strongly recommended that components cached per-session do not take dependencies on - /// other services. - /// - /// Registration limit type. - /// Registration style. - /// Activator data type. - /// The registration to configure. - /// A registration builder allowing further configuration of the component. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "It is the responsibility of the registry to dispose of registrations.")] - public static IRegistrationBuilder - CacheInSession( - this IRegistrationBuilder registration) - where TActivatorData : IConcreteActivatorData - where TSingleRegistrationStyle : SingleRegistrationStyle - { - if (registration == null) throw new ArgumentNullException("registration"); - - var services = registration.RegistrationData.Services.ToArray(); - registration.RegistrationData.ClearServices(); - - return registration - .ExternallyOwned() - .OnRegistered(e => e.ComponentRegistry.Register(RegistrationBuilder - .ForDelegate((c, p) => - { - var session = HttpContext.Current.Session; - object result; - lock (session.SyncRoot) - { - result = session[e.ComponentRegistration.Id.ToString()]; - if (result == null) - { - result = c.ResolveComponent(e.ComponentRegistration, p); - session[e.ComponentRegistration.Id.ToString()] = result; - } - } - return result; - }) - .As(services) - .InstancePerLifetimeScope() - .ExternallyOwned() - .CreateRegistration())); - } - - /// - /// Sets the provided registration to act as an for the specified controller action. - /// - /// The type of the controller. - /// The registration. - /// The action selector. - /// The order in which the filter is applied. - /// A registration builder allowing further configuration of the component. - public static IRegistrationBuilder - AsActionFilterFor(this IRegistrationBuilder registration, - Expression> actionSelector, int order = Filter.DefaultOrder) - where TController : IController - { - return AsFilterFor(registration, AutofacFilterProvider.ActionFilterMetadataKey, actionSelector, order); - } - - /// - /// Sets the provided registration to act as an for the specified controller. - /// - /// The type of the controller. - /// The registration. - /// The order in which the filter is applied. - /// A registration builder allowing further configuration of the component. - public static IRegistrationBuilder - AsActionFilterFor(this IRegistrationBuilder registration, int order = Filter.DefaultOrder) - where TController : IController - { - return AsFilterFor(registration, AutofacFilterProvider.ActionFilterMetadataKey, order); - } - - /// - /// Sets the provided registration to act as an for the specified controller action. - /// - /// The type of the controller. - /// The registration. - /// The action selector. - /// The order in which the filter is applied. - /// A registration builder allowing further configuration of the component. - public static IRegistrationBuilder - AsAuthorizationFilterFor(this IRegistrationBuilder registration, - Expression> actionSelector, int order = Filter.DefaultOrder) - where TController : IController - { - return AsFilterFor(registration, AutofacFilterProvider.AuthorizationFilterMetadataKey, actionSelector, order); - } - - /// - /// Sets the provided registration to act as an for the specified controller. - /// - /// The type of the controller. - /// The registration. - /// The order in which the filter is applied. - /// A registration builder allowing further configuration of the component. - public static IRegistrationBuilder - AsAuthorizationFilterFor(this IRegistrationBuilder registration, int order = Filter.DefaultOrder) - where TController : IController - { - return AsFilterFor(registration, AutofacFilterProvider.AuthorizationFilterMetadataKey, order); - } - - /// - /// Sets the provided registration to act as an for the specified controller action. - /// - /// The type of the controller. - /// The registration. - /// The action selector. - /// The order in which the filter is applied. - /// A registration builder allowing further configuration of the component. - public static IRegistrationBuilder - AsExceptionFilterFor(this IRegistrationBuilder registration, - Expression> actionSelector, int order = Filter.DefaultOrder) - where TController : IController - { - return AsFilterFor(registration, AutofacFilterProvider.ExceptionFilterMetadataKey, actionSelector, order); - } - - /// - /// Sets the provided registration to act as an for the specified controller. - /// - /// The type of the controller. - /// The registration. - /// The order in which the filter is applied. - /// A registration builder allowing further configuration of the component. - public static IRegistrationBuilder - AsExceptionFilterFor(this IRegistrationBuilder registration, int order = Filter.DefaultOrder) - where TController : IController - { - return AsFilterFor(registration, AutofacFilterProvider.ExceptionFilterMetadataKey, order); - } - - /// - /// Sets the provided registration to act as an for the specified controller action. - /// - /// The type of the controller. - /// The registration. - /// The action selector. - /// The order in which the filter is applied. - /// A registration builder allowing further configuration of the component. - public static IRegistrationBuilder - AsResultFilterFor(this IRegistrationBuilder registration, - Expression> actionSelector, int order = Filter.DefaultOrder) - where TController : IController - { - return AsFilterFor(registration, AutofacFilterProvider.ResultFilterMetadataKey, actionSelector, order); - } - - /// - /// Sets the provided registration to act as an for the specified controller. - /// - /// The type of the controller. - /// The registration. - /// The order in which the filter is applied. - /// A registration builder allowing further configuration of the component. - public static IRegistrationBuilder - AsResultFilterFor(this IRegistrationBuilder registration, int order = Filter.DefaultOrder) - where TController : IController - { - return AsFilterFor(registration, AutofacFilterProvider.ResultFilterMetadataKey, order); - } - - static IRegistrationBuilder - AsFilterFor(IRegistrationBuilder registration, string metadataKey, Expression> actionSelector, int order) - where TController : IController - { - if (registration == null) throw new ArgumentNullException("registration"); - if (actionSelector == null) throw new ArgumentNullException("actionSelector"); - - var limitType = registration.ActivatorData.Activator.LimitType; - - if (!limitType.IsAssignableTo()) - { - var message = string.Format(CultureInfo.CurrentCulture, RegistrationExtensionsResources.MustBeAssignableToFilterType, - limitType.FullName, typeof(TFilter).FullName); - throw new ArgumentException(message, "registration"); - } - - var metadata = new FilterMetadata - { - ControllerType = typeof(TController), - FilterScope = FilterScope.Action, - MethodInfo = GetMethodInfo(actionSelector), - Order = order - }; - - return registration.As().WithMetadata(metadataKey, metadata); - } - - static IRegistrationBuilder - AsFilterFor(IRegistrationBuilder registration, string metadataKey, int order) - where TController : IController - { - if (registration == null) throw new ArgumentNullException("registration"); - - var limitType = registration.ActivatorData.Activator.LimitType; - - if (!limitType.IsAssignableTo()) - { - var message = string.Format(CultureInfo.CurrentCulture, RegistrationExtensionsResources.MustBeAssignableToFilterType, - limitType.FullName, typeof(TFilter).FullName); - throw new ArgumentException(message, "registration"); - } - - var metadata = new FilterMetadata - { - ControllerType = typeof(TController), - FilterScope = FilterScope.Controller, - MethodInfo = null, - Order = order - }; - - return registration.As().WithMetadata(metadataKey, metadata); - } - - static MethodInfo GetMethodInfo(LambdaExpression expression) - { - var outermostExpression = expression.Body as MethodCallExpression; - - if (outermostExpression == null) - throw new ArgumentException(RegistrationExtensionsResources.InvalidActionExpress); - - return outermostExpression.Method; - } - } -} diff --git a/Autofac.Integration.Mvc/RegistrationExtensionsResources.Designer.cs b/Autofac.Integration.Mvc/RegistrationExtensionsResources.Designer.cs deleted file mode 100644 index 175afcea9..000000000 --- a/Autofac.Integration.Mvc/RegistrationExtensionsResources.Designer.cs +++ /dev/null @@ -1,90 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.18010 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Autofac.Integration.Mvc { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class RegistrationExtensionsResources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal RegistrationExtensionsResources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Autofac.Integration.Mvc.RegistrationExtensionsResources", typeof(RegistrationExtensionsResources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to The action method Expression is invalid. It should consist only of a Method call to a controller action method.. - /// - internal static string InvalidActionExpress { - get { - return ResourceManager.GetString("InvalidActionExpress", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type list may not be empty or contain all null values.. - /// - internal static string InvalidModelBinderType { - get { - return ResourceManager.GetString("InvalidModelBinderType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The type '{0}' must be assignable to the filter type '{1}'.. - /// - internal static string MustBeAssignableToFilterType { - get { - return ResourceManager.GetString("MustBeAssignableToFilterType", resourceCulture); - } - } - } -} diff --git a/Autofac.Integration.Mvc/RegistrationExtensionsResources.resx b/Autofac.Integration.Mvc/RegistrationExtensionsResources.resx deleted file mode 100644 index d1be6ef19..000000000 --- a/Autofac.Integration.Mvc/RegistrationExtensionsResources.resx +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - The action method Expression is invalid. It should consist only of a Method call to a controller action method. - - - Type list may not be empty or contain all null values. - - - The type '{0}' must be assignable to the filter type '{1}'. - - \ No newline at end of file diff --git a/Autofac.Integration.Mvc/RequestLifetimeHttpModule.cs b/Autofac.Integration.Mvc/RequestLifetimeHttpModule.cs deleted file mode 100644 index cf9441a92..000000000 --- a/Autofac.Integration.Mvc/RequestLifetimeHttpModule.cs +++ /dev/null @@ -1,79 +0,0 @@ -// This software is part of the Autofac IoC container -// Copyright © 2011 Autofac Contributors -// http://autofac.org -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; -using System.Web; - -namespace Autofac.Integration.Mvc -{ - /// - /// An and implementation - /// that creates a nested lifetime scope for each HTTP request. - /// - internal class RequestLifetimeHttpModule : IHttpModule - { - /// - /// Gets the lifetime scope provider that should be notified when a HTTP request ends. - /// - internal static ILifetimeScopeProvider LifetimeScopeProvider { get; private set; } - - /// - /// Initializes a module and prepares it to handle requests. - /// - /// An that provides access to the - /// methods, properties, and events common to all application objects within an ASP.NET application - /// - /// Thrown if is . - /// - public void Init(HttpApplication context) - { - if (context == null) - { - throw new ArgumentNullException("context"); - } - context.EndRequest += OnEndRequest; - } - - /// - /// Disposes of the resources (other than memory) used by the module that implements . - /// - public void Dispose() - { - } - - public static void SetLifetimeScopeProvider(ILifetimeScopeProvider lifetimeScopeProvider) - { - if (lifetimeScopeProvider == null) throw new ArgumentNullException("lifetimeScopeProvider"); - - LifetimeScopeProvider = lifetimeScopeProvider; - } - - static void OnEndRequest(object sender, EventArgs e) - { - if (LifetimeScopeProvider != null) - LifetimeScopeProvider.EndLifetimeScope(); - } - } -} \ No newline at end of file diff --git a/Autofac.Integration.Mvc/RequestLifetimeScopeProvider.cs b/Autofac.Integration.Mvc/RequestLifetimeScopeProvider.cs deleted file mode 100644 index 55eee6638..000000000 --- a/Autofac.Integration.Mvc/RequestLifetimeScopeProvider.cs +++ /dev/null @@ -1,122 +0,0 @@ -// This software is part of the Autofac IoC container -// Copyright (c) 2011 Autofac Contributors -// http://autofac.org -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.Web; - -namespace Autofac.Integration.Mvc -{ - /// - /// Creates and disposes HTTP request based lifetime scopes. - /// - /// - /// The provider is notified when a HTTP request ends by the . - /// - public class RequestLifetimeScopeProvider : ILifetimeScopeProvider - { - readonly ILifetimeScope _container; - - /// - /// Tag used to identify registrations that are scoped to the HTTP request level. - /// - internal static readonly object HttpRequestTag = "AutofacWebRequest"; - - /// - /// Initializes a new instance of the class. - /// - /// The parent container, usually the application container. - public RequestLifetimeScopeProvider(ILifetimeScope container) - { - if (container == null) throw new ArgumentNullException("container"); - _container = container; - RequestLifetimeHttpModule.SetLifetimeScopeProvider(this); - } - - /// - /// Gets the global, application-wide container. - /// - public ILifetimeScope ApplicationContainer - { - get { return _container; } - } - - static ILifetimeScope LifetimeScope - { - get { return (ILifetimeScope)HttpContext.Current.Items[typeof(ILifetimeScope)]; } - set { HttpContext.Current.Items[typeof(ILifetimeScope)] = value; } - } - - /// - /// Gets a nested lifetime scope that services can be resolved from. - /// - /// - /// A configuration action that will execute during lifetime scope creation. - /// - /// A new or existing nested lifetime scope. - public ILifetimeScope GetLifetimeScope(Action configurationAction) - { - if (HttpContext.Current == null) - { - throw new InvalidOperationException(RequestLifetimeScopeProviderResources.HttpContextNotAvailable); - } - - if (LifetimeScope == null) - { - if ((LifetimeScope = GetLifetimeScopeCore(configurationAction)) == null) - throw new InvalidOperationException( - string.Format(CultureInfo.CurrentCulture, RequestLifetimeScopeProviderResources.NullLifetimeScopeReturned, GetType().FullName)); - } - return LifetimeScope; - } - - /// - /// Ends the current HTTP request lifetime scope. - /// - public void EndLifetimeScope() - { - var lifetimeScope = LifetimeScope; - if (lifetimeScope != null) - lifetimeScope.Dispose(); - } - - /// - /// Gets a lifetime scope for the current HTTP request. This method can be overridden - /// to alter the way that the life time scope is constructed. - /// - /// - /// A configuration action that will execute during lifetime scope creation. - /// - /// A new lifetime scope for the current HTTP request. - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] - protected virtual ILifetimeScope GetLifetimeScopeCore(Action configurationAction) - { - return (configurationAction == null) - ? ApplicationContainer.BeginLifetimeScope(HttpRequestTag) - : ApplicationContainer.BeginLifetimeScope(HttpRequestTag, configurationAction); - } - } -} diff --git a/Autofac.Integration.Mvc/RequestLifetimeScopeProviderResources.Designer.cs b/Autofac.Integration.Mvc/RequestLifetimeScopeProviderResources.Designer.cs deleted file mode 100644 index eb79ea366..000000000 --- a/Autofac.Integration.Mvc/RequestLifetimeScopeProviderResources.Designer.cs +++ /dev/null @@ -1,81 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.1 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Autofac.Integration.Mvc { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class RequestLifetimeScopeProviderResources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal RequestLifetimeScopeProviderResources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Autofac.Integration.Mvc.RequestLifetimeScopeProviderResources", typeof(RequestLifetimeScopeProviderResources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to The request lifetime scope cannot be created because the HttpContext is not available.. - /// - internal static string HttpContextNotAvailable { - get { - return ResourceManager.GetString("HttpContextNotAvailable", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The 'GetLifetimeScopeCore' method implementation on '{0}' returned a null ILifetimeScope instance. When overridden this method must return a valid ILifetimeScope instance for the current HTTP request.. - /// - internal static string NullLifetimeScopeReturned { - get { - return ResourceManager.GetString("NullLifetimeScopeReturned", resourceCulture); - } - } - } -} diff --git a/Autofac.Integration.Mvc/RequestLifetimeScopeProviderResources.resx b/Autofac.Integration.Mvc/RequestLifetimeScopeProviderResources.resx deleted file mode 100644 index 22507abed..000000000 --- a/Autofac.Integration.Mvc/RequestLifetimeScopeProviderResources.resx +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - The request lifetime scope cannot be created because the HttpContext is not available. - - - The 'GetLifetimeScopeCore' method implementation on '{0}' returned a null ILifetimeScope instance. When overridden this method must return a valid ILifetimeScope instance for the current HTTP request. - - \ No newline at end of file diff --git a/Autofac.Integration.Mvc/ViewRegistrationSource.cs b/Autofac.Integration.Mvc/ViewRegistrationSource.cs deleted file mode 100644 index 60f167df5..000000000 --- a/Autofac.Integration.Mvc/ViewRegistrationSource.cs +++ /dev/null @@ -1,78 +0,0 @@ -// This software is part of the Autofac IoC container -// Copyright © 2011 Autofac Contributors -// http://autofac.org -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; -using System.Collections.Generic; -using System.Web.Mvc; -using Autofac.Builder; -using Autofac.Core; - -namespace Autofac.Integration.Mvc -{ - /// - /// A registration source for building view registrations. - /// - /// - /// Supports view registrations for , , - /// and derived types. - /// - public class ViewRegistrationSource : IRegistrationSource - { - /// - /// Retrieve registrations for an unregistered service, to be used - /// by the container. - /// - /// The service that was requested. - /// A function that will return existing registrations for a service. - /// Registrations providing the service. - public IEnumerable RegistrationsFor(Service service, Func> registrationAccessor) - { - var typedService = service as IServiceWithType; - - if (typedService != null && IsSupportedView(typedService.ServiceType)) - yield return RegistrationBuilder.ForType(typedService.ServiceType) - .PropertiesAutowired() - .InstancePerDependency() - .CreateRegistration(); - } - - /// - /// Gets whether the registrations provided by this source are 1:1 adapters on top - /// of other components (I.e. like Meta, Func or Owned.) - /// - public bool IsAdapterForIndividualComponents - { - get { return false; } - } - - static bool IsSupportedView(Type serviceType) - { - return serviceType.IsAssignableTo() - || serviceType.IsAssignableTo() - || serviceType.IsAssignableTo() - || serviceType.IsAssignableTo(); - } - } -} diff --git a/Autofac.Integration.Mvc/packages.config b/Autofac.Integration.Mvc/packages.config deleted file mode 100644 index acd79060a..000000000 --- a/Autofac.Integration.Mvc/packages.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Libraries/CTT/ctt.exe b/Libraries/CTT/ctt.exe deleted file mode 100644 index 3652dfc7b..000000000 Binary files a/Libraries/CTT/ctt.exe and /dev/null differ diff --git a/Libraries/CTT/ctt.exe.config b/Libraries/CTT/ctt.exe.config deleted file mode 100644 index 06809064e..000000000 --- a/Libraries/CTT/ctt.exe.config +++ /dev/null @@ -1,53 +0,0 @@ - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-