public void LoadComponentData(IEnumerable <Assembly> assemblies) { if (_loadedData) { return; } // Iterate through all loaded assemblies searching for NQ components Dictionary <Assembly, ComponentInfo> componentAssemblies = new Dictionary <Assembly, ComponentInfo>(); Dictionary <string, List <Assembly> > componentPartAssemblies = new Dictionary <string, List <Assembly> >(); foreach (Assembly a in assemblies) { if (AttributeComponentInfo.IsComponent(a)) { // Create component info and save it AttributeComponentInfo componentInfo = new AttributeComponentInfo(a); if (!componentInfo.IsComponentPart) { // Add component definition to internal list if (!_componentInfos.ContainsKey(componentInfo.Name)) { _componentInfos.Add(componentInfo.Name, componentInfo); } else { // Component is already known _logger.Write(LogType.Error, "Multiple definition of component " + componentInfo.Name + "."); throw new ComponentDefinitionException(ErrorReason.ComponentMultiplyDefined, "Multiple definition of component " + componentInfo.Name + "."); } } else { // Add assembly to temporary parts list if (!componentPartAssemblies.ContainsKey(componentInfo.Name)) { componentPartAssemblies.Add(componentInfo.Name, new List <Assembly>()); } componentPartAssemblies[componentInfo.Name].Add(a); } // Save assembly and ComponentInfo reference in hashtable for later iteration componentAssemblies.Add(a, componentInfo); } } // Convert part assembly lists to arrays foreach (KeyValuePair <string, List <Assembly> > partList in componentPartAssemblies) { ((ComponentInfo)ComponentInfos[partList.Key]).PartAssemblies = partList.Value; } // Now iterate through all well-defined NQ components and search for services inside foreach (KeyValuePair <Assembly, ComponentInfo> nqAssembly in componentAssemblies) { ComponentInfo compInfo = nqAssembly.Value; Type[] classes = nqAssembly.Key.GetTypes(); if (classes != null) { foreach (Type comptype in classes) { if (AttributeServiceInfo.IsValidServiceClass(comptype)) { // Firstly create a NQServiceInfo, we'll get all other information from it later AttributeServiceInfo serviceInfo = new AttributeServiceInfo(comptype, compInfo.Name); if (!ServiceInfos.ContainsKey(serviceInfo.ServiceInterface)) { ServiceInfos.Add(serviceInfo.ServiceInterface, serviceInfo); } else { throw new ServiceDefinitionException(ErrorReason.ServiceMultiplyDefined, "Service \"" + serviceInfo.ServiceInterface + "\" is multiply defined."); } } } } } _loadedData = true; }