public IEnumerable <Assembly> GetAssemblies() { if (_loadedData) { // Trying to load data twice!? throw new InvalidOperationException("Trying to load component assemblies twice."); } List <Assembly> loadedAssemblies = new List <Assembly>(); // Get directory with component definition files string[] cddParam = _callParameterHandler["cdd"]; if ((cddParam != null) && (cddParam.Length > 0)) { // Use given directory _definitionPath = cddParam[0]; } else { // Use "components" as default subdirectory _definitionPath = Path.Combine(Environment.CurrentDirectory, "components"); } // Iterate through all XML component files and try to deserialize them string fileMask = "*.xml"; string[] fileMaskCmd = _callParameterHandler["cdfm"]; if ((fileMaskCmd != null) && (fileMaskCmd.Length > 0)) { fileMask = fileMaskCmd[0]; } foreach (string xmlFile in Directory.GetFiles(_definitionPath, fileMask)) { using (FileStream fileStream = new FileStream(xmlFile, FileMode.Open)) { IComponentInfo deserializedCompInfo; IServiceInfo[] deserializedServInfos; _serializer.ReadComponentInfo(fileStream, out deserializedCompInfo, out deserializedServInfos); // Add component and services to internal list ComponentInfos.Add(deserializedCompInfo.Name, deserializedCompInfo); if (deserializedServInfos != null) { foreach (var serviceInfo in deserializedServInfos) { ServiceInfos[serviceInfo.ServiceType] = serviceInfo; } } } } loadedAssemblies.AddRange(LoadComponentAssemblies()); _loadedData = true; return(loadedAssemblies); }
public void Add(IComponentIdWithDisplayMetadata <TId, TComponentMetaData> componentInfo) { ComponentInfos.Add(componentInfo); }