public bool Equals(ExtenderDefinition other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.ParentType, ParentType) && Equals(other.ExtenderType, ExtenderType));
 }
        public static void RegisterExtender(ControllerBase controllerToExtend, Type controllerExtender, params object[] additionalParameters)
        {
            var t = new ExtenderDefinition(controllerToExtend.GetType(), controllerExtender);

            if (Registrations.ContainsKey(t))
            {
                return;
            }

            if (controllerExtender.IsAssignableFrom(controllerToExtend.GetType()))
            {
                throw new InvalidOperationException("Cannot extend a controller by it's same type");
            }

            //if one is already there, then replace it
            Func <ControllerBase> e = () => (ControllerBase)DependencyResolver.Current.GetService(controllerExtender);

            Registrations.AddOrUpdate(t,
                                      new ExtenderData(e, additionalParameters),
                                      (key, orig) => new ExtenderData(e, additionalParameters));
        }
        public static void RegisterExtender <TController, TExtender>(params object[] additionalParameters)
            where TController : ControllerBase
            where TExtender : ControllerBase
        {
            var t = new ExtenderDefinition(typeof(TController), typeof(TExtender));

            if (Registrations.ContainsKey(t))
            {
                return;
            }

            if (typeof(TExtender).IsAssignableFrom(typeof(TController)))
            {
                throw new InvalidOperationException("Cannot extend a controller by it's same type");
            }

            //if one is already there, then replace it
            Func <ControllerBase> e = () => DependencyResolver.Current.GetService <TExtender>();

            Registrations.AddOrUpdate(t,
                                      new ExtenderData(e, additionalParameters),
                                      (key, orig) => new ExtenderData(e, additionalParameters));
        }
        public static void RegisterExtender <T>(ControllerBase controllerToExtend, Expression <Func <T> > extender, params object[] additionalParameters)
            where T : ControllerBase
        {
            var extenderType = typeof(T);
            var t            = new ExtenderDefinition(controllerToExtend.GetType(), extenderType);

            if (Registrations.ContainsKey(t))
            {
                return;
            }

            if (extender.GetType().IsAssignableFrom(controllerToExtend.GetType()))
            {
                throw new InvalidOperationException("Cannot extend a controller by it's same type");
            }

            //if one is already there, then replace it
            Func <ControllerBase> e = extender.Compile();

            Registrations.AddOrUpdate(t,
                                      new ExtenderData(e, additionalParameters),
                                      (key, orig) => new ExtenderData(e, additionalParameters));
        }