private static IDictionary<Type, ControllerTypesList> GetAttributesLookup(IEnumerable<Type> types, string namespaceName, Type controllerType) { var dictionary = new Dictionary<Type, ControllerTypesList>(); var controllers = types.Where(controllerType.IsAssignableFrom); if (!string.IsNullOrEmpty(namespaceName)) controllers = controllers.Where(x => x.Namespace == namespaceName); // O(n^2) foreach (var controller in controllers) { foreach (RestRoutingAttribute controllerCustomAttribute in controller.GetCustomAttributes(typeof (RestRoutingAttribute), false)) { var key = controllerCustomAttribute.GetType(); var value = new ControllerWithAttr(controllerCustomAttribute, controller); if (!dictionary.ContainsKey(key)) dictionary.Add(key, new ControllerTypesList(controllerCustomAttribute) {value}); else { dictionary[key].Add(value); } } } return dictionary; }
protected IEnumerable<RouteInfo> RegisterActionMethods(ControllerWithAttr record) { var methods = GetControllerTypeActionMethods(record.ControllerType); foreach (var methodInfo in methods) { } return new List<RouteInfo>(); }