This project is read-only.

How To pass params to constructor

Jun 8, 2013 at 12:26 PM
Edited Jun 8, 2013 at 12:27 PM
Original code without bind:
InterceptorProvider.SetInterceptorProvider(
    new DefaultInterceptorProvider(
        new SoftDeleteChangeInterceptor(),
        new AuditableChangeInterceptor(System.Threading.Thread.CurrentPrincipal, new Clock())));
I can try bind follow constructor:
        public IsgReadonlyApiControllerBase(IInterceptorProvider interceptorProvider)
        {
            InterceptorProvider.SetInterceptorProvider(interceptorProvider);
        }
I'm use follow binds:
    public class OSMDefaultInterceptorProvider : DefaultInterceptorProvider, IInterceptorProvider
    {
        public OSMDefaultInterceptorProvider(SoftDeleteChangeInterceptor soft, AuditableChangeInterceptor audit) :
            base(soft, audit) { }
    }

    public class ControllerModule : NinjectModule
    {
        public override void Load()
        {
            this.Bind<IPrincipal>().ToMethod(ctx => HttpContext.Current.User).InRequestScope();
            this.Bind<AuditableChangeInterceptor>().ToSelf().InRequestScope().WithConstructorArgument("clock", new Clock());
            this.Bind<SoftDeleteChangeInterceptor>().ToSelf().InRequestScope();
            this.Bind<IInterceptorProvider>().To<OSMDefaultInterceptorProvider>().InRequestScope();
        }
    }
More info:
    public class AuditableChangeInterceptor : ChangeInterceptor<IAuditable>
    {
        public AuditableChangeInterceptor(IPrincipal principal, IClock clock);
    }

    public class SoftDeleteChangeInterceptor : ChangeInterceptor<ISoftDelete>
    {
        public SoftDeleteChangeInterceptor();
    }

    public class DefaultInterceptorProvider : IInterceptorProvider
    {
        public DefaultInterceptorProvider(params IInterceptor[] interceptors);

        public IEnumerable<IInterceptor> GetInterceptors();
    }

    public interface IInterceptorProvider
    {
        IEnumerable<IInterceptor> GetInterceptors();
    }
It's works fine.

But I what use it without my custom OSMDefaultInterceptorProvider.

How I can pass params IInterceptor[] interceptors into DefaultInterceptorProvider constructor?