private Dictionary <string, HttpControllerDescriptor> InitializeControllerDictionary()
        {
            var dictionary = new Dictionary <string, HttpControllerDescriptor>(StringComparer.OrdinalIgnoreCase);

            IAssembliesResolver         assembliesResolver  = _configuration.Services.GetAssembliesResolver();
            IHttpControllerTypeResolver controllersResolver = _configuration.Services.GetHttpControllerTypeResolver();
            ICollection <Type>          controllerTypes     = controllersResolver.GetControllerTypes(assembliesResolver);

            foreach (Type t in controllerTypes)
            {
                AddController(t, t.Name.Remove(t.Name.Length - DefaultHttpControllerSelector.ControllerSuffix.Length), dictionary);
            }

            var genericEntityControllerTypes = GetType().Assembly.GetTypes().Where(t => t.IsDefined(typeof(EntityControllerAttribute))).ToArray();
            var entityTypes = typeof(WMSBusinessObject).Assembly.GetTypes().Where(t => !t.IsAbstract && typeof(WMSBusinessObject).IsAssignableFrom(t)).ToArray();

            foreach (var entityType in entityTypes)
            {
                foreach (var genControllerType in genericEntityControllerTypes)
                {
                    var t = genControllerType.MakeGenericType(entityType);
                    AddController(t, entityType.Name, dictionary);
                }
            }

            foreach (string s in _duplicates)
            {
                dictionary.Remove(s);
            }

            return(dictionary);
        }
        public ICollection <Type> GetControllerTypes(IAssembliesResolver assembliesResolver)
        {
            var baseTypes = _resolver.GetControllerTypes(assembliesResolver);
            var stubTypes = assembliesResolver.GetAssemblies().Where(a => a.IsDynamic).SelectMany(a => a.GetTypes().Where(IsControllerType));

            return(baseTypes.Concat(stubTypes).Distinct().ToList());
        }
    private Dictionary <string, HttpControllerDescriptor> InitializeControllerDictionary()
    {
        var dictionary = new Dictionary <string, HttpControllerDescriptor>(StringComparer.OrdinalIgnoreCase);
        // Create a lookup table where key is "namespace.controller". The value of "namespace" is the last
        // segment of the full namespace. For example:
        // MyApplication.Controllers.V1.ProductsController => "V1.Products"
        IAssembliesResolver         assembliesResolver  = _configuration.Services.GetAssembliesResolver();
        IHttpControllerTypeResolver controllersResolver = _configuration.Services.GetHttpControllerTypeResolver();
        ICollection <Type>          controllerTypes     = controllersResolver.GetControllerTypes(assembliesResolver);

        foreach (Type t in controllerTypes)
        {
            var segments = t.Namespace.Split(Type.Delimiter);
            // For the dictionary key, strip "Controller" from the end of the type name.
            // This matches the behavior of DefaultHttpControllerSelector.
            var controllerName = t.Name.Remove(t.Name.Length - DefaultHttpControllerSelector.ControllerSuffix.Length);
            var key            = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", segments[segments.Length - 1], controllerName);
            // Check for duplicate keys.
            if (dictionary.Keys.Contains(key))
            {
                _duplicates.Add(key);
            }
            else
            {
                dictionary[key] = new HttpControllerDescriptor(_configuration, t.Name, t);
            }
        }
        // Remove any duplicates from the dictionary, because these create ambiguous matches.
        // For example, "Foo.V1.ProductsController" and "Bar.V1.ProductsController" both map to "v1.products".
        foreach (string s in _duplicates)
        {
            dictionary.Remove(s);
        }
        return(dictionary);
    }
        private Dictionary <string, ILookup <string, Type> > InitializeCache()
        {
            IAssembliesResolver assembliesResolver =
                _configuration.Services.GetAssembliesResolver();
            IHttpControllerTypeResolver controllersResolver =
                _configuration.Services.GetHttpControllerTypeResolver();

            ICollection <Type> controllerTypes = controllersResolver.GetControllerTypes(
                assembliesResolver
                );
            var groupedByName = controllerTypes.GroupBy(
                t =>
                t.Name.Substring(
                    0,
                    t.Name.Length - DefaultHttpControllerSelector.ControllerSuffix.Length
                    ),
                StringComparer.OrdinalIgnoreCase
                );

            return(groupedByName.ToDictionary(
                       g => g.Key,
                       g => g.ToLookup(t => t.Namespace ?? String.Empty, StringComparer.OrdinalIgnoreCase),
                       StringComparer.OrdinalIgnoreCase
                       ));
        }
示例#5
0
        private Dictionary <string, HttpControllerDescriptor> InitializeControllerDictionary()
        {
            IAssembliesResolver         assembliesResolver         = this._configuration.Services.GetAssembliesResolver();
            IHttpControllerTypeResolver httpControllerTypeResolver = this._configuration.Services.GetHttpControllerTypeResolver();
            ICollection <Type>          controllerTypes            = httpControllerTypeResolver.GetControllerTypes(assembliesResolver);
            //var types = controllerTypes.ToDictionary(m => m.Name.Substring(0, m.Name.Length - DefaultHttpControllerSelector.ControllerSuffix.Length), m => new HttpControllerDescriptor(this._configuration, m.Name.Substring(0, m.Name.Length - DefaultHttpControllerSelector.ControllerSuffix.Length), m));


            var dictionary = new Dictionary <string, HttpControllerDescriptor>(StringComparer.OrdinalIgnoreCase);
            var hashSet    = new HashSet <string>();

            foreach (var type in controllerTypes)
            {
                var assemblyName   = type.Assembly.GetName().Name;
                var controllerName = type.Name.Remove(type.Name.Length - ControllerSuffix.Length);
                var key            = string.Format("{0}.{1}", assemblyName, controllerName);

                if (dictionary.Keys.Contains(key))
                {
                    hashSet.Add(key);
                    continue;
                }
                dictionary.Add(key, new HttpControllerDescriptor(this._configuration, controllerName, type));
            }

            foreach (var item in hashSet)
            {
                dictionary.Remove(item);
            }
            return(dictionary);


            //return types;
        }
        private static List <Type> GetControllerTypesFromConfiguration(HttpConfiguration configuration,
                                                                       IAssembliesResolver assembliesResolver)
        {
            IHttpControllerTypeResolver typeResolver = GetHttpControllerTypeResolver(configuration);

            return(typeResolver.GetControllerTypes(assembliesResolver).ToList());
        }
        private Dictionary <string, HttpControllerDescriptor> InitializeControllerDictionary()
        {
            var dictionary = new Dictionary <string, HttpControllerDescriptor>(StringComparer.OrdinalIgnoreCase);
            IAssembliesResolver         assembliesResolver  = _configuration.Services.GetAssembliesResolver();
            IHttpControllerTypeResolver controllersResolver = _configuration.Services.GetHttpControllerTypeResolver();
            ICollection <Type>          controllerTypes     = controllersResolver.GetControllerTypes(assembliesResolver);

            foreach (Type t in controllerTypes)
            {
                var    segments       = t.Namespace.Split(Type.Delimiter);
                var    controllerName = t.Name.Remove(t.Name.Length - DefaultHttpControllerSelector.ControllerSuffix.Length);
                string version        = segments[segments.Length - 1];
                var    key            = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", version, controllerName);
                if (version == "Controllers")
                {
                    key = String.Format(CultureInfo.InvariantCulture, "{0}", controllerName);
                }
                if (dictionary.Keys.Contains(key))
                {
                    _duplicates.Add(key);
                }
                else
                {
                    dictionary[key] = new HttpControllerDescriptor(_configuration, t.Name, t);
                }
            }
            foreach (string s in _duplicates)
            {
                dictionary.Remove(s);
            }
            return(dictionary);
        }
        private Dictionary <string, HttpControllerDescriptor> InitializeControllerDictionary()
        {
            var dictionary = new Dictionary <string, HttpControllerDescriptor>(StringComparer.OrdinalIgnoreCase);
            IAssembliesResolver         assembliesResolver  = configuration.Services.GetAssembliesResolver();
            IHttpControllerTypeResolver controllersResolver = configuration.Services.GetHttpControllerTypeResolver();
            ICollection <Type>          controllerTypes     = controllersResolver.GetControllerTypes(assembliesResolver);

            foreach (Type controllerType in controllerTypes)
            {
                if (controllerType.Namespace != null)
                {
                    string[] segments       = controllerType.Namespace.Split(Type.Delimiter);
                    string   controllerName = controllerType.Name.Remove(controllerType.Name.Length -
                                                                         DefaultHttpControllerSelector.ControllerSuffix
                                                                         .Length);
                    string controllerKey = string.Format(
                        CultureInfo.InvariantCulture,
                        "{0}.{1}", segments[segments.Length - 1],
                        controllerName);
                    if (!dictionary.ContainsKey(controllerKey))
                    {
                        dictionary[controllerKey]
                            = new HttpControllerDescriptor(configuration, controllerType.Name, controllerType);
                    }
                }
            }

            return(dictionary);
        }
示例#9
0
        private static ILookup <string, Type> GetControllerTypes()
        {
            IAssembliesResolver         assembliesResolver  = GlobalConfiguration.Configuration.Services.GetAssembliesResolver();
            IHttpControllerTypeResolver controllersResolver = GlobalConfiguration.Configuration.Services.GetHttpControllerTypeResolver();
            ICollection <Type>          controllerTypes     = controllersResolver.GetControllerTypes(assembliesResolver);

            return(controllerTypes.ToLookup(t => t.Namespace ?? String.Empty));
        }
示例#10
0
        /// <summary> Returns a list of controllers available for the application. </summary>
        /// <returns>An &lt;see cref="T:System.Collections.Generic.ICollection`1" /&gt; of controllers.</returns>
        /// <param name="assembliesResolver">The resolver for failed assemblies.</param>
        public ICollection <Type> GetControllerTypes(IAssembliesResolver assembliesResolver)
        {
            var controllers = ParentResolver.GetControllerTypes(assembliesResolver).ToList();

            controllers.AddRange(ServiceFactory.GetTypes());

            return(controllers);
        }
        private Dictionary <ControllerIdentification, ILookup <string, Type> > InitializeCache()
        {
            IAssembliesResolver         assembliesResolver  = this._configuration.Services.GetAssembliesResolver();
            IHttpControllerTypeResolver controllersResolver = this._configuration.Services.GetHttpControllerTypeResolver();

            ICollection <Type> controllerTypes = controllersResolver.GetControllerTypes(assembliesResolver);
            IEnumerable <IGrouping <ControllerIdentification, Type> > groupedByName = controllerTypes.GroupBy(
                GetControllerName, ControllerIdentification.Comparer);

            return(groupedByName.ToDictionary(g => g.Key, g => g.ToLookup(t => t.Namespace ?? String.Empty,
                                                                          StringComparer.OrdinalIgnoreCase), ControllerIdentification.Comparer));
        }
            private Dictionary <string, HttpControllerDescriptor> InitializeControllerDictionary()
            {
                var dictionary = new Dictionary <string, HttpControllerDescriptor>(StringComparer.OrdinalIgnoreCase);

                IAssembliesResolver         assembliesResolver  = configuration.Services.GetAssembliesResolver();
                IHttpControllerTypeResolver controllersResolver = configuration.Services.GetHttpControllerTypeResolver();

                ICollection <Type> controllerTypes = controllersResolver.GetControllerTypes(assembliesResolver);

                foreach (Type t in controllerTypes)
                {
                    dictionary[t.FullName] = new HttpControllerDescriptor(configuration, t.Name, t);
                }

                return(dictionary);
            }
        public override HttpControllerDescriptor SelectController(HttpRequestMessage request)
        {
            var controllerName     = GetControllerName(request);
            var controllerTypeName = $"{controllerName}Controller".ToUpper();

            var controllerType = controllerTypeResolver.GetControllerTypes(assembliesResolver).
                                 SingleOrDefault(t => t.Name.ToUpper() == controllerTypeName);

            if (controllerType == null)
            {
                throw new HttpResponseException(request.CreateErrorResponse(
                                                    HttpStatusCode.NotFound, $"Unknown controller '{controllerName}'"));
            }

            return(new HttpControllerDescriptor(configuration, controllerTypeName, controllerType));
        }
示例#14
0
        private ConcurrentDictionary <string, HttpControllerDescriptor> InitializeControllerInfoCache()
        {
            var result = new ConcurrentDictionary <string, HttpControllerDescriptor>(StringComparer.OrdinalIgnoreCase);
            var duplicateControllers = new HashSet <string>();
            IAssembliesResolver         assembliesResolver  = _configuration.Services.GetAssembliesResolver();
            IHttpControllerTypeResolver controllersResolver = _configuration.Services.GetHttpControllerTypeResolver();

            ICollection <Type> controllerTypes = controllersResolver.GetControllerTypes(assembliesResolver);
            var groupedByName = controllerTypes.GroupBy(
                t => t.Name.Substring(0, t.Name.Length - DefaultHttpControllerSelector.ControllerSuffix.Length),
                StringComparer.OrdinalIgnoreCase);

            var _controllerTypeCacheCache = groupedByName.ToDictionary(
                g => g.Key,
                g => g.ToLookup(t => t.Namespace ?? String.Empty, StringComparer.OrdinalIgnoreCase),
                StringComparer.OrdinalIgnoreCase);
            Dictionary <string, ILookup <string, Type> > controllerTypeGroups = _controllerTypeCacheCache;

            foreach (KeyValuePair <string, ILookup <string, Type> > controllerTypeGroup in controllerTypeGroups)
            {
                string controllerName = controllerTypeGroup.Key;

                foreach (IGrouping <string, Type> controllerTypesGroupedByNs in controllerTypeGroup.Value)
                {
                    foreach (Type controllerType in controllerTypesGroupedByNs)
                    {
                        if (result.Keys.Contains(controllerName))
                        {
                            duplicateControllers.Add(controllerName);
                            break;
                        }
                        else
                        {
                            result.TryAdd(controllerName, new HttpControllerDescriptor(_configuration, controllerName, controllerType));
                        }
                    }
                }
            }

            foreach (string duplicateController in duplicateControllers)
            {
                HttpControllerDescriptor descriptor;
                result.TryRemove(duplicateController, out descriptor);
            }

            return(result);
        }
示例#15
0
        private Dictionary <string, Dictionary <string, HttpControllerDescriptor> > InitializeCache()
        {
            IAssembliesResolver assembliesResolver = this._configuration.Services.GetAssembliesResolver();

            IHttpControllerTypeResolver httpControllerTypeResolver = this._configuration.Services.GetHttpControllerTypeResolver();

            ICollection <Type> controllerTypes = httpControllerTypeResolver.GetControllerTypes(assembliesResolver);

            IEnumerable <IGrouping <string, Type> > source = controllerTypes.GroupBy(t =>
                                                                                     t.Name.EndsWith(NamespaceControllerSelector.ControllerSuffix, StringComparison.OrdinalIgnoreCase) ?
                                                                                     t.Name.Substring(0, t.Name.Length - NamespaceControllerSelector.ControllerSuffix.Length)
                : t.Name, StringComparer.OrdinalIgnoreCase);

            return(source.ToDictionary(g => g.Key, g => g.ToDictionary(
                                           t => t.Namespace ?? string.Empty,
                                           t => new HttpControllerDescriptor(this._configuration, g.Key, t),
                                           StringComparer.OrdinalIgnoreCase), StringComparer.OrdinalIgnoreCase));
        }
        public override HttpControllerDescriptor SelectController(HttpRequestMessage request)
        {
            var controllerName = base.GetControllerName(request);

            if (controllerName.Contains("_"))
            {
                IAssembliesResolver         assembliesResolver         = _configuration.Services.GetAssembliesResolver();
                IHttpControllerTypeResolver httpControllerTypeResolver = this._configuration.Services.GetHttpControllerTypeResolver();
                ICollection <Type>          controllerTypes            = httpControllerTypeResolver.GetControllerTypes(assembliesResolver);
                controllerName = controllerName.Replace("_", "");
                var matchedController =
                    controllerTypes.FirstOrDefault(i => i.Name.ToLower() == controllerName.ToLower() + "controller");

                return(new HttpControllerDescriptor(_configuration, controllerName, matchedController));
            }

            return(base.SelectController(request));
        }
示例#17
0
        private ConcurrentDictionary <string, HttpControllerDescriptor> InitTypeCache()
        {
            IAssembliesResolver         assembliesResolver  = _configuration.Services.GetAssembliesResolver();
            IHttpControllerTypeResolver controllersResolver = _configuration.Services.GetHttpControllerTypeResolver();

            ICollection <Type> controllerTypes = controllersResolver.GetControllerTypes(assembliesResolver);

            var dict = new ConcurrentDictionary <string, HttpControllerDescriptor>();

            foreach (Type type in controllerTypes)
            {
                if (type.FullName != null)
                {
                    string controllerName = type.Name.Substring(0, type.Name.Length - ControllerSuffix.Length);
                    dict.TryAdd(type.FullName.ToLowerInvariant(), new HttpControllerDescriptor(_configuration, controllerName, type));
                }
            }

            return(dict);
        }
        private Dictionary <ControllerIdentification, ILookup <string, Type> > InitializeCache()
        {
            IAssembliesResolver         assembliesResolver  = this._configuration.Services.GetAssembliesResolver();
            IHttpControllerTypeResolver controllersResolver =
                this._configuration.Services.GetHttpControllerTypeResolver();
            IControllerIdentificationDetector controllerIdentificationDetector =
                this._configuration.DependencyResolver.GetControllerIdentificationDetector();

            // group controllers by name
            ICollection <Type> controllerTypes = controllersResolver.GetControllerTypes(assembliesResolver);
            IEnumerable <IGrouping <ControllerIdentification, Type> > groupedByName =
                controllerTypes.Select(
                    x => new { ClrType = x, Id = controllerIdentificationDetector.GetIdentification(x) })
                .GroupBy(x => x.Id, x => x.ClrType);

            return(groupedByName.ToDictionary(
                       g => g.Key,
                       g => g.ToLookup(t => t.Namespace ?? String.Empty, StringComparer.OrdinalIgnoreCase),
                       ControllerIdentification.Comparer));
        }
示例#19
0
        internal static HashSet <string> GetMobileAppControllerNames(this HttpConfiguration config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            IAssembliesResolver         assemblyResolver       = config.Services.GetAssembliesResolver();
            IHttpControllerTypeResolver controllerTypeResolver = config.Services.GetHttpControllerTypeResolver();

            Type[] controllerTypes = controllerTypeResolver.GetControllerTypes(assemblyResolver).ToArray();

            // Add controllers that have the MobileAppController attribute
            IEnumerable <string> matches = controllerTypes
                                           .Where(t => t.GetCustomAttributes(typeof(MobileAppControllerAttribute), true).Any())
                                           .Select(t => t.Name.Substring(0, t.Name.Length - DefaultHttpControllerSelector.ControllerSuffix.Length));

            HashSet <string> result = new HashSet <string>(matches, StringComparer.OrdinalIgnoreCase);

            return(result);
        }
示例#20
0
        /// <summary>
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static HashSet <string> GetTableControllerNames(this HttpConfiguration config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            IAssembliesResolver         assemblyResolver       = config.Services.GetAssembliesResolver();
            IHttpControllerTypeResolver controllerTypeResolver = config.Services.GetHttpControllerTypeResolver();

            Type[] controllerTypes = controllerTypeResolver.GetControllerTypes(assemblyResolver).ToArray();

            // Add controllers deriving from TableController
            IEnumerable <string> matches = controllerTypes
                                           .Where(t => typeof(TableController).IsAssignableFrom(t))
                                           .Select(t => t.Name.Substring(0, t.Name.Length - DefaultHttpControllerSelector.ControllerSuffix.Length));

            HashSet <string> result = new HashSet <string>(matches, StringComparer.OrdinalIgnoreCase);

            return(result);
        }
        public CustomControllerSelector(string suffix)
        {
            Suffix = suffix;
            HttpConfiguration config = GlobalConfiguration.Configuration;

            IHttpControllerTypeResolver typeFinder =
                config.Services.GetHttpControllerTypeResolver();
            IAssembliesResolver assemblyFinder = config.Services.GetAssembliesResolver();

            IEnumerable <HttpControllerDescriptor> descriptors
                = typeFinder.GetControllerTypes(assemblyFinder)
                  .Select(type => new HttpControllerDescriptor {
                Configuration  = GlobalConfiguration.Configuration,
                ControllerName = type.Name.Substring(0,
                                                     type.Name.Length - Suffix.Length),
                ControllerType = type
            });

            mappings = descriptors.ToLookup(descriptor =>
                                            descriptor.ControllerName, StringComparer.OrdinalIgnoreCase);

            dictionary = descriptors.ToDictionary(d => d.ControllerName, d => d);
        }
示例#22
0
        private ConcurrentDictionary <string, HttpControllerDescriptor> InitializeControllerInfoCache()
        {
            IAssembliesResolver                     assembliesResolver         = this._configuration.Services.GetAssembliesResolver();
            IHttpControllerTypeResolver             httpControllerTypeResolver = this._configuration.Services.GetHttpControllerTypeResolver();
            ICollection <Type>                      controllerTypes            = httpControllerTypeResolver.GetControllerTypes(assembliesResolver);
            IEnumerable <IGrouping <string, Type> > source = controllerTypes.GroupBy((Type t) => t.Name.Substring(0, t.Name.Length - DefaultHttpControllerSelector.ControllerSuffix.Length), StringComparer.OrdinalIgnoreCase);


            ConcurrentDictionary <string, HttpControllerDescriptor> concurrentDictionary = new ConcurrentDictionary <string, HttpControllerDescriptor>(StringComparer.OrdinalIgnoreCase);
            HashSet <string> hashSet = new HashSet <string>();
            Dictionary <string, ILookup <string, Type> > cache = source.ToDictionary((IGrouping <string, Type> g) => g.Key, (IGrouping <string, Type> g) => g.ToLookup((Type t) => t.Namespace ?? string.Empty, StringComparer.OrdinalIgnoreCase), StringComparer.OrdinalIgnoreCase);

            foreach (KeyValuePair <string, ILookup <string, Type> > current in cache)
            {
                string key = current.Key;
                foreach (IGrouping <string, Type> current2 in current.Value)
                {
                    foreach (Type current3 in current2)
                    {
                        if (concurrentDictionary.Keys.Contains(key))
                        {
                            hashSet.Add(key);
                            break;
                        }
                        concurrentDictionary.TryAdd(key, new HttpControllerDescriptor(this._configuration, key, current3));
                    }
                }
            }

            foreach (string current4 in hashSet)
            {
                HttpControllerDescriptor httpControllerDescriptor;
                concurrentDictionary.TryRemove(current4, out httpControllerDescriptor);
            }
            return(concurrentDictionary);
        }
示例#23
0
    private Dictionary <string, HttpControllerDescriptor> InitializeControllerDictionary()
    {
        var controllers = new Dictionary <string, HttpControllerDescriptor>(StringComparer.OrdinalIgnoreCase);

        IAssembliesResolver         assembliesResolver  = _configuration.Services.GetAssembliesResolver();
        IHttpControllerTypeResolver controllersResolver = _configuration.Services.GetHttpControllerTypeResolver();
        ICollection <Type>          controllerTypes     = controllersResolver.GetControllerTypes(assembliesResolver);

        foreach (Type t in controllerTypes)
        {
            var controllerName = t.Name.Remove(t.Name.Length - DefaultHttpControllerSelector.ControllerSuffix.Length);

            //Remove Core API Controller and add the Plugin API controller.
            if (controllers.Keys.Contains(controllerName) && t.Namespace.Contains("Plugin"))
            {
                controllers.Remove(controllerName);
            }
            if (!controllers.Keys.Contains(controllerName))
            {
                controllers[controllerName] = new HttpControllerDescriptor(_configuration, t.Nam ` enter code here ` e, t);
            }
        }
        return(controllers);
    }
示例#24
0
        private Dictionary <string, HttpControllerDescriptor> InitializeControllerDictionary()
        {
            var dictionary = new Dictionary <string, HttpControllerDescriptor>(StringComparer.OrdinalIgnoreCase);

            // Create a lookup table where key is "namespace.controller". The value of "namespace" is the
            // full namespace where the controller resides.
            // EdFi.Ods.Api.Services.Controllers.AcademicHonorCategoryTypes.AcademicHonorCategoryTypes
            IAssembliesResolver         assembliesResolver  = _configuration.Services.GetAssembliesResolver();
            IHttpControllerTypeResolver controllersResolver = _configuration.Services.GetHttpControllerTypeResolver();

            ICollection <Type> controllerTypes = controllersResolver.GetControllerTypes(assembliesResolver);

            foreach (Type t in controllerTypes)
            {
                var key = FullyQualifiedControllerNamespace(t.Namespace, t.Name);

                // Check for duplicate keys.
                if (dictionary.Keys.Contains(key))
                {
                    _duplicates.Add(key);
                }
                else
                {
                    dictionary[key] = new HttpControllerDescriptor(_configuration, t.Name, t);
                }
            }

            // Remove any duplicates from the dictionary, because these create ambiguous matches.
            // For example, "Foo.V1.ProductsController" and "Bar.V1.ProductsController" both map to "v1.products".
            foreach (string s in _duplicates)
            {
                dictionary.Remove(s);
            }

            return(dictionary);
        }