public void Init(IModuleController host, AssemblyLoadContext alc, string assemblyDllPath) { _name = Path.GetFileNameWithoutExtension(assemblyDllPath); _pluginAssembly = alc.LoadFromAssemblyName(new AssemblyName(Path.GetFileNameWithoutExtension(assemblyDllPath))); Type[] types; try { types = _pluginAssembly.GetTypes(); } catch (ReflectionTypeLoadException e) { types = e.Types.Where(t => t != null).ToArray(); } var type = types.FirstOrDefault(t => t.GetInterface("ICoreModule") != null); if (type != null && _instance == null) { _instance = (ICoreModule)Activator.CreateInstance(type, null, null); // propagate reference to controller futher _instance.Init(host); } //var stream = _pluginAssembly.GetManifestResourceStream(_pluginAssembly.GetName().Name + ".g.resources"); //var resourceReader = new ResourceReader(stream); //foreach (DictionaryEntry resource in resourceReader) //{ // if (new FileInfo(resource.Key.ToString()).Extension.Equals(".baml")) // { // Uri uri = new Uri("/" + _pluginAssembly.GetName().Name + ";component/" + resource.Key.ToString().Replace(".baml", ".xaml"), UriKind.Relative); // Debug.WriteLine(resourceReader.ToString()); // UserControl currentUserControl = Application.LoadComponent(uri) as UserControl; // currentUserControl.DataContext = _instance; // View = currentUserControl; // break; // } //} }
public CoreModuleDescriptor(Type moduleType, ICoreModule instance) { ModuleType = moduleType ?? throw new ArgumentNullException(nameof(moduleType)); Instance = instance ?? throw new ArgumentNullException(nameof(instance)); _dependencies = new List <ICoreModuleDescriptor>(); }
public MainBarViewModel(IModuleController host, ICoreModule coreMod) { _host = host; }