private System.Reflection.Assembly GetAssemblyFromJarFile(string jarFile, string assemblyName)
        {
            IJarFileFactory jarFileFactory = new JarFileFactory();

            using (var reader = jarFileFactory.GetJarFileReader(jarFile))
            {
                var jarFileItem = reader.GetNextFile();

                WriteLog("Getting :" + assemblyName + Environment.NewLine);

                while (jarFileItem != null)
                {
                    if (jarFileItem.Headers.ContainsKey("FileName"))
                    {
                        if (jarFileItem.Headers["FileName"] == assemblyName + ".dll" ||
                            jarFileItem.Headers["FileName"] == assemblyName + ".exe")
                        {
                            return(Assembly.Load(jarFileItem.Containt));
                        }
                    }

                    jarFileItem = reader.GetNextFile();
                }

                WriteLog("Not Found :  " + assemblyName + Environment.NewLine);
            }

            return(null);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var dir         = Path.Combine(RuntimeHelper.ExecutionLocation, "Jar");
            var jarFilePath = Path.Combine(dir, "Include.jar");

            JarFileFactory jarFactory = new JarFileFactory();

            var files = Directory.GetFiles(dir);
            Dictionary <string, string> header = new Dictionary <string, string>();

            using (var jarFileReader = jarFactory.GetJarFileReader(jarFilePath))
            {
                foreach (var file in files)
                {
                    header["FileName"] = Path.GetFileName(file);
                    var fvi = FileVersionInfo.GetVersionInfo(file);
                    header["version"] = fvi.FileVersion;

                    var jarFileItem = jarFileReader.GetNextFile();
                }
            }
        }