This project is read-only.

Why class DefaultOrchardShell can use IRouteProvider in the way of ioc

Topics: Core, General
May 22, 2013 at 7:04 AM
public class DefaultOrchardShell : IOrchardShell {
        private readonly Func<Owned<IOrchardShellEvents>> _eventsFactory;
        __private readonly IEnumerable<IRouteProvider> _routeProviders;__
        private readonly IEnumerable<IHttpRouteProvider> _httpRouteProviders;
        private readonly IRoutePublisher _routePublisher;
        private readonly IEnumerable<IModelBinderProvider> _modelBinderProviders;
        private readonly IModelBinderPublisher _modelBinderPublisher;
        private readonly ISweepGenerator _sweepGenerator;

        public DefaultOrchardShell(
            Func<Owned<IOrchardShellEvents>> eventsFactory,
            __IEnumerable<IRouteProvider> routeProviders,__
            IEnumerable<IHttpRouteProvider> httpRouteProviders,
            IRoutePublisher routePublisher,
            IEnumerable<IModelBinderProvider> modelBinderProviders,
            IModelBinderPublisher modelBinderPublisher,
            ISweepGenerator sweepGenerator) {
            _eventsFactory = eventsFactory;
            _routeProviders = routeProviders;
            _httpRouteProviders = httpRouteProviders;
            _routePublisher = routePublisher;
            _modelBinderProviders = modelBinderProviders;
            _modelBinderPublisher = modelBinderPublisher;
            _sweepGenerator = sweepGenerator;

            Logger = NullLogger.Instance;
May 22, 2013 at 10:52 AM
Could you please be more specific? DefaultOrchardShell and instances of IRouteProvider are both instantiated in the same lifetime scope, ie. per-tenant (singleton dependency) - this is why.
May 23, 2013 at 8:55 AM
Edited May 23, 2013 at 8:59 AM
Thank you,
I can`t find code like "builder.RegisterType<X>().As<IRoutePublisher >();" in the method of OrchardStarter.CreateHostContainer. I want to know , when did the injection happens. I`am very confused, please tell me why.
May 23, 2013 at 2:27 PM
IRouteProvider is and IDependency. Interfaces deriving from IDependency are automatically registered in Autofac, without an explicit registration as with IRoutePublisher.
May 23, 2013 at 2:45 PM
Thank you,
namespace Orchard {
    /// <summary>
    /// Base interface for services that are instantiated per unit of work (i.e. web request).
    /// </summary>
    public interface IDependency {
IDependency was defineded in Orchard, and looks like has no relationship with Autofac, where is the code make it different.

Thanks a lot!