public void PopulateFeature(IEnumerable <ApplicationPart> parts, ControllerFeature feature) { var allowed = feature.Controllers.Where(ti => ti.Assembly == MainAssembly || (AllowedAreas.TryGetC(ti.Assembly)?.Any(ns => ti.Namespace.StartsWith(ns)) ?? false) || AllowedControllers.Contains(ti.AsType())); var toRemove = feature.Controllers.Where(ti => !allowed.Contains(ti)); feature.Controllers.RemoveAll(ti => toRemove.Contains(ti)); }
public override IDictionary <string, HttpControllerDescriptor> GetControllerMapping() { var dic = base.GetControllerMapping(); var result = dic.Where(a => a.Value.ControllerType.Assembly == MainAssembly || AllowedControllers.Contains(a.Value.ControllerType)).ToDictionary(); var removedControllers = dic.Keys.Except(result.Keys);//Just for debugging return(result); }