public bool TryLoad(IModInfo info, IModFileSystem modfiles, IModLoadingDomain loadingdomain, out IMod mod) { mod = new Mock<IMod>().Object; // really doesn't matter what we return Assert.AreEqual((info as FakeModInfo).system, modfiles); // make sure the proper system is being passed along with each mod Assert.NotNull(loadingdomain); // make sure the domain is a thing return !modfiles.ModFiles.Any(x => x == "fail"); // if a "file" is named fail, thats the test signaling to us that we want to simulate a failed mod load }
public bool TryLoad(IModInfo info, IModFileSystem modfiles, IModLoadingDomain loadingdomain, out IMod mod) { mod = null; foreach (var file in modfiles.ModFiles.Where(x => Path.GetExtension(x) == ".dll")) { var assembly = Assembly.LoadFrom(file); var entryType = assembly.GetTypes().FirstOrDefault(x => (typeof(IModEntryPoint).IsAssignableFrom(x))); if (entryType == null) { continue; } mod = new EntryPointMod(info, (IModEntryPoint)Activator.CreateInstance(entryType)); return(true); } return(false); }
public IDisposable Initialize(IModLoadingDomain domain) { this.domain = domain; AppDomain.CurrentDomain.AssemblyResolve += Resolve; return(this); }