Ejemplo n.º 1
0
        public override string GetJSONInput(IModFileSystem loadInfo)
        {
            foreach (var v in loadInfo.ModFiles)
            {
                if (Path.GetExtension(v) != ".dll")
                {
                    continue;
                }
                Assembly loadedAssembly = Assembly.LoadFrom(v);

                foreach (var resource in loadedAssembly.GetManifestResourceNames())
                {
                    if (!resource.EndsWith("modinfo.json"))
                    {
                        continue;
                    }
                    using (var reader = new StreamReader(loadedAssembly.GetManifestResourceStream(resource)))
                    {
                        var read = reader.ReadToEnd();
                        return(read);
                    }
                }
            }
            return(null);
        }
 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
 }
Ejemplo n.º 3
0
 public override string GetJSONInput(IModFileSystem loadInfo)
 {
     foreach (var v in loadInfo.ModFiles)
     {
         if (Path.GetFileName(v) == ("modinfo.json"))
         {
             return(File.ReadAllText(v));
         }
     }
     return(null);
 }
Ejemplo n.º 4
0
 public bool TryParse(IModFileSystem loadInfo, out IModInfo modInfo)
 {
     modInfo = null;
     foreach (var parser in Parsers)
     {
         if (parser.TryParse(loadInfo, out var info))
         {
             modInfo = info;
             return(true);
         }
     }
     return(false);
 }
 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);
 }
Ejemplo n.º 6
0
        public bool TryParse(IModFileSystem loadInfo, out IModInfo modInfo)
        {
            modInfo = null;
            var input = GetJSONInput(loadInfo);

            if (input == null || input.Length == 0)
            {
                return(false);
            }
            modInfo = ParseJSON(input);
            if (modInfo == null)
            {
                return(false);
            }
            return(true);
        }
            public bool TryParse(IModFileSystem loadInfo, out IModInfo modInfo)
            {
                modInfo = new FakeModInfo(loadInfo);

                return !loadInfo.ModFiles.Any(x => x == ""); // return false if one of the "files" is empty, in order to simulate a parsing failure (it being empty has no significance outside of signaling to the test to throw a false)
            }
 public FakeModInfo(IModFileSystem associatedSystem)
 {
     system = associatedSystem;
 }
Ejemplo n.º 9
0
 public abstract string GetJSONInput(IModFileSystem loadInfo);