/// <summary> /// Adds a new part to the repository. /// </summary> /// <param name="part">The part definition.</param> /// <param name="pluginFileInfo">The file info of the assembly which owns the part.</param> public void AddPart(PartDefinition part, PluginFileInfo pluginFileInfo) { m_Repository.AddPart(part, pluginFileInfo); }
private void ScanAssembly(Assembly assembly) { try { m_Logger.Log( LevelToLog.Trace, string.Format( CultureInfo.InvariantCulture, Resources.RemoteAssemblyScanner_LogMessage_ScanningAssembly_WithName, assembly.FullName)); var file = new FileInfo(assembly.LocalFilePath()); var fileInfo = new PluginFileInfo(file.FullName, file.LastWriteTimeUtc); var createTypeIdentity = TypeIdentityBuilder.IdentityFactory(m_Repository, new Dictionary <Type, TypeIdentity>()); var mefParts = ExtractImportsAndExports(assembly, createTypeIdentity); var parts = mefParts.Select(p => ExtractActionsAndConditions(p.Item1, p.Item2, createTypeIdentity)); foreach (var part in parts) { m_Logger.Log( LevelToLog.Trace, string.Format( CultureInfo.InvariantCulture, Resources.RemoteAssemblyScanner_LogMessage_AddingPartToRepository_WithPartInformation, part.Identity)); m_Repository.AddPart(part, fileInfo); } var groupExporters = assembly.GetTypes().Where(t => typeof(IExportGroupDefinitions).IsAssignableFrom(t)); foreach (var t in groupExporters) { try { m_Logger.Log( LevelToLog.Trace, string.Format( CultureInfo.InvariantCulture, Resources.RemoteAssemblyScanner_LogMessage_RegisteringGroupsViaExporter_WithExporterType, t.AssemblyQualifiedName)); var builder = new GroupDefinitionBuilder( m_Repository, m_ImportEngine, createTypeIdentity, m_ScheduleBuilder, fileInfo); var exporter = Activator.CreateInstance(t) as IExportGroupDefinitions; exporter.RegisterGroups(builder); } catch (Exception e) { m_Logger.Log(LevelToLog.Warn, e.ToString()); } } } catch (Exception e) { m_Logger.Log( LevelToLog.Error, string.Format( CultureInfo.InvariantCulture, Resources.Plugins_LogMessage_Scanner_TypeScanFailed_WithAssemblyAndException, assembly.GetName().FullName, e)); } }