Beispiel #1
0
        static PatchManager()
        {
            FullPath        = Path.GetFullPath(SettingsManager.XmlData.ModsPath);
            ManifestCreator = new ManifestCreator();

            Logger = LogManager.CreateLogger("PatchManager");
        }
Beispiel #2
0
        private static void PatchTest()
        {
            var targetPath = @"..\..\..\Patchwork.Tests.Target\bin\debug\Patchwork.Tests.Target.dll";;

            var dir = Path.GetDirectoryName(targetPath);
            var fn = Path.GetFileNameWithoutExtension(targetPath);
            var ext = Path.GetExtension(targetPath);
            var newFileName = string.Format("{0}.patched{1}", fn, ext);
            var newTarget = Path.Combine(dir, newFileName);
            File.Copy(targetPath, newTarget, true);
            var patcher = new AssemblyPatcher(newTarget, log: Log);
            var patchPath = typeof(Patchwork.Tests.Patch.TestClass).Assembly.Location;
            var maker = new ManifestCreator();
            var manifest = maker.CreateManifest(patchPath);
            patcher.PatchManifest(manifest, null);

            patcher.WriteTo(newTarget);
            Log.Information("Loading assembly into memory...");
            var loaded = Assembly.LoadFrom(newTarget);
            Log.Information("Invoking method");
            var module = loaded.GetModules()[0];
            var types = module.FindTypes((typ, o) => typ.Name.Contains("EntryPoint"), null);
            var foundType = types.Single();
            var method = foundType.GetMethod("StandardTests");
            try
            {
                var ret = method.Invoke(null, null);
                Log.Information("Result: {@Result}", ret);
            }
            catch (TargetInvocationException ex)
            {
                throw ex.InnerException;
            }
            Console.ReadKey();
        }
Beispiel #3
0
        /// <exception cref="T:Patchwork.Engine.PatchDeclerationException">The patch did not have a PatchInfo class.</exception>
        public static PatchingManifest TryGetManifest(string assemblyPath)
        {
            PatchingManifest patchingManifest = ManifestCreator.CreateManifest(assemblyPath);

            if (patchingManifest.PatchInfo == null)
            {
                throw new PatchDeclerationException("The patch did not have a PatchInfo class.");
            }

            return(patchingManifest);
        }
Beispiel #4
0
        private static void PatchTest()
        {
            var targetPath = @"..\..\..\Patchwork.Tests.Target\bin\debug\Patchwork.Tests.Target.dll";;

            var dir         = Path.GetDirectoryName(targetPath);
            var fn          = Path.GetFileNameWithoutExtension(targetPath);
            var ext         = Path.GetExtension(targetPath);
            var newFileName = string.Format("{0}.patched{1}", fn, ext);
            var newTarget   = Path.Combine(dir, newFileName);

            File.Copy(targetPath, newTarget, true);
            var patcher   = new AssemblyPatcher(newTarget, log: Log);
            var patchPath = typeof(Patchwork.Tests.Patch.TestClass).Assembly.Location;
            var maker     = new ManifestCreator();
            var manifest  = maker.CreateManifest(patchPath);

            patcher.PatchManifest(manifest, null);



            patcher.WriteTo(newTarget);
            Log.Information("Loading assembly into memory...");
            var loaded = Assembly.LoadFrom(newTarget);

            Log.Information("Invoking method");
            var module    = loaded.GetModules()[0];
            var types     = module.FindTypes((typ, o) => typ.Name.Contains("EntryPoint"), null);
            var foundType = types.Single();
            var method    = foundType.GetMethod("StandardTests");

            try
            {
                var ret = method.Invoke(null, null);
                Log.Information("Result: {@Result}", ret);
            }
            catch (TargetInvocationException ex)
            {
                throw ex.InnerException;
            }
            Console.ReadKey();
        }