diff --git a/lib/autofac/Autofac.Configuration.dll b/lib/autofac/Autofac.Configuration.dll index a1b27ccc9..dee943ea2 100644 Binary files a/lib/autofac/Autofac.Configuration.dll and b/lib/autofac/Autofac.Configuration.dll differ diff --git a/lib/autofac/Autofac.Integration.Wcf.dll b/lib/autofac/Autofac.Integration.Wcf.dll index ee12bf501..81cb2c81a 100644 Binary files a/lib/autofac/Autofac.Integration.Wcf.dll and b/lib/autofac/Autofac.Integration.Wcf.dll differ diff --git a/lib/autofac/Autofac.Integration.Web.Mvc.dll b/lib/autofac/Autofac.Integration.Web.Mvc.dll index dd24d79b1..9090fe5c7 100644 Binary files a/lib/autofac/Autofac.Integration.Web.Mvc.dll and b/lib/autofac/Autofac.Integration.Web.Mvc.dll differ diff --git a/lib/autofac/Autofac.Integration.Web.dll b/lib/autofac/Autofac.Integration.Web.dll index 075a0c76b..ad6e90d6e 100644 Binary files a/lib/autofac/Autofac.Integration.Web.dll and b/lib/autofac/Autofac.Integration.Web.dll differ diff --git a/lib/autofac/Autofac.XML b/lib/autofac/Autofac.XML index 9c0b82b7c..bb8822940 100644 --- a/lib/autofac/Autofac.XML +++ b/lib/autofac/Autofac.XML @@ -4,6 +4,75 @@ Autofac + + + Support the + type automatically whenever type T is registered with the container. + When a dependency of a lazy type is used, the instantiation of the underlying + component will be delayed until the Value property is first accessed. + + + + + Allows registrations to be made on-the-fly when unregistered + services are requested (lazy registrations.) + + + + + 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. + + + + Gets whether the registrations provided by this source are 1:1 adapters on top + of other components (I.e. like Meta, Func or Owned.) + + + + + Support the + types automatically whenever type T is registered with the container. + Metadata values come from the component registration's metadata. + When a dependency of a lazy type is used, the instantiation of the underlying + component will be delayed until the Value property is first accessed. + + + + + Provides a value along with metadata describing the value. + + The type of the value. + An interface to which metadata values can be bound. + + + + Create a new instance. + + The value described by the instance. + The metadata describing the value. + + + + The value described by . + + + + + Metadata describing the value. + + + + + Support the + types automatically whenever type T is registered with the container. + Metadata values come from the component registration's metadata. + + Reflection activator data for concrete types. @@ -295,8 +364,11 @@ To create an for a specific type, use: - var rb = IRegistrationBuilder.ForType(t).Named("foo").ExternallyOwned(); - var cr = IRegistrationBuilder.CreateRegistration(rb); + var cr = RegistrationBuilder.ForType(t).CreateRegistration(); + + The full builder syntax is supported: + + var cr = RegistrationBuilder.ForType(t).Named("foo").ExternallyOwned().CreateRegistration(); @@ -343,7 +415,7 @@ - var registration = IRegistrationBuilder.ForType<Foo>().CreateRegistration(); + var registration = RegistrationBuilder.ForType<Foo>().CreateRegistration(); @@ -795,6 +867,116 @@ The description. + + + Wraps a component registration, switching its lifetime. + + + + + Base class for disposable objects. + + + + + Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + + + + + Releases unmanaged and - optionally - managed resources + + true to release both managed and unmanaged resources; false to release only unmanaged resources. + + + + Describes a logical component within the container. + + + + + Called by the container when an instance is required. + + The context in which the instance will be activated. + Parameters for activation. These may be modified by the event handler. + + + + Called by the container once an instance has been constructed. + + The context in which the instance was activated. + The parameters supplied to the activator. + The instance. + + + + Called by the container once an instance has been fully constructed, including + any requested objects that depend on the instance. + + The context in which the instance was activated. + The parameters supplied to the activator. + The instance. + + + + A unique identifier for this component (shared in all sub-contexts.) + This value also appears in Services. + + + + + The activator used to create instances. + + + + + The lifetime associated with the component. + + + + + Whether the component instances are shared or not. + + + + + Whether the instances of the component should be disposed by the container. + + + + + The services provided by the component. + + + + + Additional data associated with the component. + + + + + The component registration upon which this registration is based. + + + + + Fired when a new instance is required. The instance can be + provided in order to skip the regular activator, by setting the Instance property in + the provided event arguments. + + + + + Fired when a new instance is being activated. The instance can be + wrapped or switched at this time by setting the Instance property in + the provided event arguments. + + + + + Fired when the activation process for a new instance is complete. + + A strongly-typed resource class, for looking up localized strings, etc. @@ -823,21 +1005,6 @@ collection registrations. - - - Allows registrations to be made on-the-fly when unregistered - services are requested (lazy registrations.) - - - - - 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. - Create an external registry source that draws components from @@ -854,6 +1021,257 @@ A function that will return existing registrations for a service. Registrations providing the service. + + + In this case because the components that are adapted do not come from the same + logical scope, we must return false to avoid duplicating them. + + + + + Switches components with a RootScopeLifetime (singletons) with + decorators exposing MatchingScopeLifetime targeting the specified scope. + + + + + Maps services onto the components that provide them. + + + The component registry provides services directly from components, + and also uses to generate components + on-the-fly or as adapters for other components. A component registry + is normally used through a , and not + directly by application code. + + + + + Provides component registrations according to the services they provide. + + + + + Attempts to find a default registration for the specified service. + + The service to look up. + The default registration for the service. + True if a registration exists. + + + + Determines whether the specified service is registered. + + The service to test. + True if the service is registered. + + + + Register a component. + + The component registration. + + + + Register a component. + + The component registration. + If true, existing defaults for the services provided by the + component will not be changed. + + + + Selects from the available registrations after ensuring that any + dynamic registration sources that may provide + have been invoked. + + The service for which registrations are sought. + Registrations supporting . + + + + Add a registration source that will provide registrations on-the-fly. + + The source to register. + + + + Enumerate the registered components. + + + + + Fired whenever a component is registered - either explicitly or via a + . + + + + + Gets the registration sources that are used by the registry. + + + + + Protects instance variables from concurrent access. + + + + + External registration sources. + + + + + All registrations. + + + + + Keeps track of the status of registered services. + + + + + Releases unmanaged and - optionally - managed resources + + true to release both managed and unmanaged resources; false to release only unmanaged resources. + + + + Attempts to find a default registration for the specified service. + + The service to look up. + The default registration for the service. + True if a registration exists. + + + + Determines whether the specified service is registered. + + The service to test. + True if the service is registered. + + + + Register a component. + + The component registration. + + + + Register a component. + + The component registration. + If true, existing defaults for the services provided by the + component will not be changed. + + + + Selects from the available registrations after ensuring that any + dynamic registration sources that may provide + have been invoked. + + The service for which registrations are sought. + Registrations supporting . + + + + Add a registration source that will provide registrations on-the-fly. + + The source to register. + + + + Enumerate the registered components. + + + + + Fired whenever a component is registered - either explicitly or via a + . + + + + + Gets the registration sources that are used by the registry. + + + + + Tracks the services known to the registry. + + + + + Used for bookkeeping so that the same source is not queried twice (may be null.) + + + + + Initializes a new instance of the class. + + The tracked service. + + + + The first time a service is requested, initialization (e.g. reading from sources) + happens. This value will then be set to true. Calling many methods on this type before + initialisation is an error. + + + + + The known implementations. + + + + + True if any implementations are known. + + + + + Describes the basic requirements for generating a lightweight adapter. + + + + + Create an instance of . + + The service that will be adapted from. + The adapter function. + + + + The adapter function. + + + + + The service to be adapted from. + + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + + Returns the cached ResourceManager instance used by this class. + + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + + Looks up a localized string similar to The service {0} cannot be both the adapter's from and to parameters - these must differ.. + + Internal implementation of the RegisterCollection/MemberOf-style collection feature. @@ -889,24 +1307,6 @@ Activator data that can provide an IInstanceActivator instance. - - - Generates activators in an IRegistrationSource. - - Data associated with the specific kind of activator. - - - - Given a requested service and registration data, attempt to generate an - activator for the service. - - Service that was requested. - Services associated with the activator generator. - Data specific to this kind of activator. - Resulting activator. - Services provided by the activator. - True if an activator could be generated. - Hides standard Object members to make fluent interfaces @@ -1033,6 +1433,27 @@ Metadata describing the value. + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + + Returns the cached ResourceManager instance used by this class. + + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + + Looks up a localized string similar to The type {0} is not an open generic type definition.. + + Provides registrations on-the-fly for any concrete type not already registered with @@ -1059,6 +1480,12 @@ A function that will return existing registrations for a service. Registrations providing the service. + + + Gets whether the registrations provided by this source are 1:1 adapters on top + of other components (I.e. like Meta, Func or Owned.) + + Activation data for types located by scanning assemblies. @@ -1079,6 +1506,11 @@ Additional actions to be performed on the concrete type registrations. + + + Actions to be called once the scanning operation is complete. + + Fired when the activation process for a new instance is complete. @@ -1167,22 +1599,6 @@ Base class for instance activators. - - - Base class for disposable objects. - - - - - Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - - - - - Releases unmanaged and - optionally - managed resources - - true to release both managed and unmanaged resources; false to release only unmanaged resources. - Create an instance activator that will return instances compatible @@ -1896,155 +2312,6 @@ The most nested visible scope. The scope for the component. - - - Describes a logical component within the container. - - - - - Called by the container when an instance is required. - - The context in which the instance will be activated. - Parameters for activation. These may be modified by the event handler. - - - - Called by the container once an instance has been constructed. - - The context in which the instance was activated. - The parameters supplied to the activator. - The instance. - - - - Called by the container once an instance has been fully constructed, including - any requested objects that depend on the instance. - - The context in which the instance was activated. - The parameters supplied to the activator. - The instance. - - - - A unique identifier for this component (shared in all sub-contexts.) - This value also appears in Services. - - - - - The activator used to create instances. - - - - - The lifetime associated with the component. - - - - - Whether the component instances are shared or not. - - - - - Whether the instances of the component should be disposed by the container. - - - - - The services provided by the component. - - - - - Additional data associated with the component. - - - - - The component registration upon which this registration is based. - - - - - Fired when a new instance is required. The instance can be - provided in order to skip the regular activator, by setting the Instance property in - the provided event arguments. - - - - - Fired when a new instance is being activated. The instance can be - wrapped or switched at this time by setting the Instance property in - the provided event arguments. - - - - - Fired when the activation process for a new instance is complete. - - - - - Provides component registrations according to the services they provide. - - - - - Attempts to find a default registration for the specified service. - - The service to look up. - The default registration for the service. - True if a registration exists. - - - - Determines whether the specified service is registered. - - The service to test. - True if the service is registered. - - - - Register a component. - - The component registration. - - - - Register a component. - - The component registration. - If true, existing defaults for the services provided by the - component will not be changed. - - - - Selects from the available registrations after ensuring that any - dynamic registration sources that may provide - have been invoked. - - The service for which registrations are sought. - Registrations supporting . - - - - Add a registration source that will provide registrations on-the-fly. - - - - - - Enumerate the registered components. - - - - - Fired whenever a component is registered - either explicitly or via a - . - - Represents a set of components and related functionality @@ -2134,11 +2401,6 @@ Protects instance variables from concurrent access. - - - The tag applied by default to nested scopes when no other tag is specified. - - The tag applied to root scopes when no other tag is specified. @@ -2646,125 +2908,6 @@ Fired when the activation process for a new instance is complete. - - - Provides component registrations according to the services they provide. - - - - - Protects instance variables from concurrent access. - - - - - External registration sources. - - - - - All registrations. - - - - - Keeps track of the status of registered services. - - - - - Releases unmanaged and - optionally - managed resources - - true to release both managed and unmanaged resources; false to release only unmanaged resources. - - - - Attempts to find a default registration for the specified service. - - The service to look up. - The default registration for the service. - True if a registration exists. - - - - Determines whether the specified service is registered. - - The service to test. - True if the service is registered. - - - - Register a component. - - The component registration. - - - - Register a component. - - The component registration. - If true, existing defaults for the services provided by the - component will not be changed. - - - - Selects from the available registrations after ensuring that any - dynamic registration sources that may provide - have been invoked. - - The service for which registrations are sought. - Registrations supporting . - - - - Add a registration source that will provide registrations on-the-fly. - - - - - - Enumerate the registered components. - - - - - Fired whenever a component is registered - either explicitly or via a - . - - - - - Tracks the services known to the registry. - - - - - Initializes a new instance of the class. - - The tracked service. - - - - The first time a service is requested, initialization (e.g. reading from sources) - happens. This value will then be set to true. Calling many methods on this type before - initialisation is an error. - - - - - The known implementations. - - - - - True if any implementations are known. - - - - - Used for bookkeeping so that the same source is not queried twice (may be null.) - - Catch circular dependencies that are triggered by post-resolve processing (e.g. 'OnActivated') @@ -2964,23 +3107,11 @@ Parameters provided to the resolve call for the factory itself. A factory delegate that will work within the context. - + Generates activators for open generic types. - - - Given a requested service and registration data, attempt to generate an - activator for the service. - - Service that was requested. - Services associated with the activator generator. - Data specific to this kind of activator. - Resulting activator. - Services provided by the activator. - True if an activator could be generated. - Represents a dependency that can be released by the dependent component. @@ -3178,22 +3309,6 @@ The component registry. The registration to attach functionality to. - - - Data structure used to construct registrations. - - The most specific type to which instances of the registration - can be cast. - Activator builder type. - Registration style type. - - - - Create a IRegistrationBuilder. - - Activator builder. - Registration style. - Configure the component so that instances are never disposed by the container. @@ -3396,23 +3511,45 @@ and dynamic (IRegistrationSource.) - + - Copies from. + Construct a RegistrationData instance. + + The default service that will be used if no others + are added. + + + + Add multiple services for the registration, overriding the default. + + The services to add. + If an empty collection is specified, this will still + clear the default service. + + + + Add a service to the registration, overriding the default. + + The service to add. + + + + Copies the contents of another RegistrationData object into this one. + + The data to copy. + When true, the default service + will be changed to that of the other. + + + + Empties the configured services. - The that. The services explicitly assigned to the component. - - - If set to true, the "default" service for this registration will not - be applied. - - The instance ownership assigned to the component. @@ -3841,6 +3978,16 @@ The concrete type to exclude. Registration builder allowing the registration to be configured. + + + Filters the scanned types to exclude the provided type, providing specific configuration for + the excluded type. + + Registration to filter types from. + Registration for the excepted type. + The concrete type to exclude. + Registration builder allowing the registration to be configured. + Filters the scanned types to include only those in the namespace of the provided type @@ -3862,6 +4009,45 @@ The namespace from which types will be selected. Registration builder allowing the registration to be configured. + + + Adapt all components implementing service + to provide using the provided + function. + + Service type to adapt from. + Service type to adapt to. Must not be the + same as . + Container builder. + Function adapting to + service , given the context and parameters. + + + + Adapt all components implementing service + to provide using the provided + function. + + Service type to adapt from. + Service type to adapt to. Must not be the + same as . + Container builder. + Function adapting to + service , given the context. + + + + Adapt all components implementing service + to provide using the provided + function. + + Service type to adapt from. + Service type to adapt to. Must not be the + same as . + Container builder. + Function adapting to + service . + A strongly-typed resource class, for looking up localized strings, etc. @@ -3888,31 +4074,6 @@ Looks up a localized string similar to No matching constructor exists on type '{0}'.. - - - Registration source based on a registration builder. - - LimitType for the registration. - Type of activator data. - Registration style. - - - - Try to generate registrations using the provided activator generator, with - the data from the provided registration. - - Registration data. - Activator generator. - - - - 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. - An activator builder with no parameters. @@ -3934,13 +4095,6 @@ Registration style for individual components. - - - Create a new SingleRegistrationStyle. - - The type that will be used as the default service if - no other services are configured. - The id used for the registration. @@ -3962,12 +4116,6 @@ The component upon which this registration is based. - - - The type that will be used as the default service if - no other services are configured. - - Used to build an from component registrations. @@ -4005,25 +4153,33 @@ Build can only be called once per - this prevents ownership issues for provided instances. + Build enables support for the relationship types that come with Autofac (e.g. + Func, Owned, Meta, Lazy, IEnumerable.) To exclude support for these types, + first create the container, then call Update() on the builder. A new container with the configured component registrations. - + - Configure an existing component registry with the component registrations + Configure an existing container with the component registrations that have been made. - Build can only be called once per + Update can only be called once per - this prevents ownership issues for provided instances. - An existing component registry to make the registrations in. + An existing container to make the registrations in. - + - If set to true, standard container functionality like resolve-all, auto-generated - factories and owned-instances will not be registered by this builder. + Configure an existing registry with the component registrations + that have been made. + + Update can only be called once per + - this prevents ownership issues for provided instances. + + An existing registry to make the registrations in. @@ -4259,6 +4415,47 @@ + + + Retrieve a service from the context. + + The type to which the result will be cast. + The context from which to resolve the service. + Key of the service. + + The component instance that provides the service. + + + + + + + Retrieve a service from the context. + + The type to which the result will be cast. + The context from which to resolve the service. + Key of the service. + The parameters. + + The component instance that provides the service. + + + + + + + Retrieve a service from the context. + + The type to which the result will be cast. + The context from which to resolve the service. + Key of the service. + The parameters. + + The component instance that provides the service. + + + + Retrieve a service from the context. @@ -4646,6 +4843,18 @@ + + + Try to retrieve a service from the context. + + The service type to resolve. + The context from which to resolve the service. + The resulting component instance providing the service, or default(T). + + True if a component providing the service is available. + + + Try to retrieve a service from the context. @@ -4659,6 +4868,19 @@ + + + Try to retrieve a service from the context. + + The context from which to resolve the service. + The key of the service to resolve. + The type of the service to resolve. + The resulting component instance providing the service, or null. + + True if a component providing the service is available. + + + Flexible parameter type allows arbitrary values to be retrieved diff --git a/lib/autofac/Autofac.dll b/lib/autofac/Autofac.dll index b361e781f..03b5a9dd5 100644 Binary files a/lib/autofac/Autofac.dll and b/lib/autofac/Autofac.dll differ diff --git a/src/Orchard.Tests/Utility/ContainerExtensions.cs b/src/Orchard.Tests/Utility/ContainerExtensions.cs index 43070eb6d..d95bcef2a 100644 --- a/src/Orchard.Tests/Utility/ContainerExtensions.cs +++ b/src/Orchard.Tests/Utility/ContainerExtensions.cs @@ -30,6 +30,10 @@ namespace Orchard.Tests.Utility { public AutoMockSource(MockBehavior behavior) { _behavior = behavior; } + + public bool IsAdapterForIndividualComponents { + get { return false; } + } IEnumerable IRegistrationSource.RegistrationsFor( Service service, diff --git a/src/Orchard/Events/EventsRegistrationSource.cs b/src/Orchard/Events/EventsRegistrationSource.cs index 3a09cc77b..1ca053e9c 100644 --- a/src/Orchard/Events/EventsRegistrationSource.cs +++ b/src/Orchard/Events/EventsRegistrationSource.cs @@ -14,6 +14,10 @@ namespace Orchard.Events { _proxyBuilder = new DefaultProxyBuilder(); } + public bool IsAdapterForIndividualComponents { + get { return false; } + } + public IEnumerable RegistrationsFor(Service service, Func> registrationAccessor) { var serviceWithType = service as IServiceWithType; if (serviceWithType == null) @@ -40,4 +44,4 @@ namespace Orchard.Events { yield return rb.CreateRegistration(); } } -} \ No newline at end of file +} \ No newline at end of file diff --git a/src/Orchard/Mvc/OrchardControllerIdentificationStrategy.cs b/src/Orchard/Mvc/OrchardControllerIdentificationStrategy.cs deleted file mode 100644 index 160cb6e85..000000000 --- a/src/Orchard/Mvc/OrchardControllerIdentificationStrategy.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web.Mvc; -using Autofac.Core; -using Autofac.Integration.Web.Mvc; -using Orchard.Environment.Extensions; - -namespace Orchard.Mvc { - public class OrchardControllerIdentificationStrategy : IControllerIdentificationStrategy { - private readonly IEnumerable _extensions; - - public OrchardControllerIdentificationStrategy(IEnumerable extensions) { - _extensions = extensions; - } - - public Service ServiceForControllerName(string controllerName) { - // the OrchardControllerFactory class does not call on the strategy, because the controller name - // alone is insufficient to identify the service - throw new NotImplementedException(); - } - - public Service ServiceForControllerType(Type controllerType) { - var controllerNamespace = controllerType.Namespace; - var extension = _extensions.FirstOrDefault(x => x.Assembly == controllerType.Assembly); - var assemblySimpleName = controllerType.Assembly.GetName().Name; - string areaName; - if (assemblySimpleName == "Orchard.Core" && - controllerNamespace.StartsWith("Orchard.Core.")) { - - areaName = controllerNamespace.Split('.').Skip(2).FirstOrDefault(); - } - else if (assemblySimpleName == "Orchard.Web" && - controllerNamespace.StartsWith("Orchard.Web.Areas.")) { - - areaName = controllerNamespace.Split('.').Skip(3).FirstOrDefault(); - } - else if (extension != null) { - areaName = extension.Descriptor.Name; - } - else { - areaName = assemblySimpleName; - } - var controllerName = controllerType.Name.Replace("Controller", ""); - return new NamedService(("controller." + areaName + "." + controllerName).ToLowerInvariant(), typeof(IController)); - } - } -} \ No newline at end of file diff --git a/src/Orchard/Orchard.Framework.csproj b/src/Orchard/Orchard.Framework.csproj index 372a9cd79..424da0136 100644 --- a/src/Orchard/Orchard.Framework.csproj +++ b/src/Orchard/Orchard.Framework.csproj @@ -717,7 +717,6 @@ -