private static void AddEntries(java.util.zip.ZipFile file, string rootDirectory, string[] newFiles, bool flattenHierarchy) { string destFileName = file.getName(); string tempFileName = Path.GetTempFileName(); ZipOutputStream destination = new ZipOutputStream(new FileOutputStream(tempFileName)); try { CopyEntries(file, destination); if (newFiles != null) { foreach (string str3 in newFiles) { string directoryName; if (flattenHierarchy) { directoryName = Path.GetDirectoryName(str3); } else if (rootDirectory == null) { directoryName = Path.GetPathRoot(str3); } else { directoryName = rootDirectory; } directoryName = directoryName + @"\"; ZipEntry ze = new ZipEntry(str3.Remove(0, directoryName.Length)); ze.setMethod(8); destination.putNextEntry(ze); try { FileInputStream source = new FileInputStream(str3); try { CopyStream(source, destination); } finally { source.close(); } } finally { destination.closeEntry(); } } } } finally { destination.close(); } file.close(); System.IO.File.Copy(tempFileName, destFileName, true); System.IO.File.Delete(tempFileName); }
public override java.lang.Class[] getClasses(java.lang.Class requiredInterface) { //Console.WriteLine("looking up " + requiredInterface.getName()); List<Class> returnClasses = new List<Class>(); Type requiredType = Type.GetType(requiredInterface.getName()+", liquibase-core"); if (requiredType == null) { Console.WriteLine("could not find required type for " + requiredInterface.getName()); return new java.lang.Class[0]; } Assembly assembly = Assembly.GetExecutingAssembly(); foreach (Type type in assembly.GetTypes()) { //if (type.AssemblyQualifiedName.Contains("LiquiBase")) { // Console.WriteLine("type: " + type); //} if (!type.IsInterface && !type.IsAbstract && requiredType.IsAssignableFrom(type)) { //Console.WriteLine("Adding class " + type.AssemblyQualifiedName); returnClasses.Add(Class.forName(type.AssemblyQualifiedName)); } } foreach (AssemblyName refAsm in assembly.GetReferencedAssemblies()) { foreach (Type type in Assembly.Load(refAsm).GetTypes()) { //if (type.AssemblyQualifiedName.Contains("LiquiBase")) { // Console.WriteLine("type: " + type); //} if (!type.IsInterface && !type.IsAbstract && requiredType.IsAssignableFrom(type)) { //Console.WriteLine("Adding class " + type.AssemblyQualifiedName); returnClasses.Add(Class.forName(type.AssemblyQualifiedName)); } } } return returnClasses.ToArray(); }
private static void AddZipEntry(java.util.zip.ZipFile zf, VfsDirectory root, java.util.zip.ZipEntry entry) { if (entry.isDirectory()) { return; } string[] path = entry.getName().Split('/'); VfsDirectory dir = root; for (int i = 0; i < path.Length - 1; i++) { VfsDirectory existing = dir.GetEntry(path[i]) as VfsDirectory; if (existing == null) { existing = dir.AddDirectory(path[i]); } dir = existing; } dir.Add(path[path.Length - 1], new VfsZipEntry(zf, entry)); }
public NetLineMetrics(java.awt.Font aFont, String aString) { mFont = aFont; mString = aString; fontFamily = J2C.CreateFontFamily(aFont.getName()); style = (FontStyle)mFont.getStyle(); factor = aFont.getSize2D() / fontFamily.GetEmHeight(style); }
internal static FieldWrapper FromField(java.lang.reflect.Field field) { #if FIRST_PASS return null; #else int slot = field._slot(); if (slot == -1) { // it's a Field created by Unsafe.objectFieldOffset(Class,String) so we must resolve based on the name foreach (FieldWrapper fw in TypeWrapper.FromClass(field.getDeclaringClass()).GetFields()) { if (fw.Name == field.getName()) { return fw; } } } return TypeWrapper.FromClass(field.getDeclaringClass()).GetFields()[slot]; #endif }
private void AddMembers(String p, Symbol s, java.lang.Class ci, List<object> exceptFor, int maxDepth) { Package pkg = CurrentPackage(); String ns = ci.getName(); if (!useClassname(ns)) return; WriteLine("; importing " + p + " as " + ns ); java.lang.reflect.Field[] fi = ci.getFields(); for (int i = 0; i < fi.Length; i++) { java.lang.reflect.Field f = fi[i]; f.setAccessible(true); String fname = ("" + p + "." + f.getName()).ToUpper(); Symbol old = pkg.findAccessibleSymbol(fname); if (old != null) { // fname = ("" + p + "%" + f.getName()).ToUpper() + ""; // old = pkg.findAccessibleSymbol(fname); } bool needsClear = false; if (old == null) { old = pkg.intern(new SimpleString(fname)); needsClear = true; // WriteLine(";;; skip field " + fname + " for " + f); // continue; } WriteLine(";;; field " + fname + " for " + f); Symbol sfm = Intern(fname, null, exceptFor, f.getType(), maxDepth-1);// IkvmSite.fieldToInstanceSymbol(fname, pkg, s, f); if (needsClear) sfm.setSymbolValue(null); if (maxDepth > 0) { exceptFor.Add(f); AddMembers(fname, sfm, f.getType(), exceptFor, maxDepth - 1); } else { if (false && !exceptFor.Contains(f)) { exceptFor.Add(f); AddMembers(fname, sfm, ikvm.runtime.Util.getInstanceTypeFromClass(f.getType()), exceptFor, maxDepth - 1); } } } java.lang.reflect.Method[] mi = ci.getDeclaredMethods(); if (false) for (int i = 0; i < mi.Length; i++) { java.lang.reflect.Method m = mi[i]; String fname = ("" + p + "." + m.getName()).ToUpper() + ""; Symbol old = pkg.findAccessibleSymbol(fname); if (old != null) { fname = ("" + p + "/" + m.getName()).ToUpper() + ""; old = pkg.findAccessibleSymbol(fname); } if (old != null) { fname = ("" + p + "//" + m.getName()).ToUpper() + ""; old = pkg.findAccessibleSymbol(fname); } if (old != null) { WriteLine(";;; skip method " + fname + " for " + m); continue; } WriteLine(";;; method " + p + " as " + fname + " to " + m); //LispObject sfm = IkvmSite.methodToInstanceSymbol(fname, pkg, s, m); } }
public Symbol Intern(string p, object globalcogbotTextForm, List<object> exceptFor, java.lang.Class ic, int depth) { Package pkg = CurrentPackage(); if (p == null) { p = ic.getName(); p = p.ToString(); } p = p.ToUpper(); Symbol s = Lisp.intern(p, pkg); LispObject sv = s.getSymbolValue(); if (sv is JavaObject) { if (sv.javaInstance() == globalcogbotTextForm) return s; } Symbol fun = pkg.findAccessibleSymbol("SYMBOL-JOBJECT"); String mask = String.Format("{0} {1}", p, ic.getName()); if (fun != null && !allExceptFor.Contains(mask)) { allExceptFor.Add(mask); LispObject vtemp = s.getSymbolValue(); s.setSymbolValue(s); var jclass = JavaObject.getInstance(ic); Lisp.eval(Lisp.list4(fun, new SimpleString(p),s,jclass)); s.setSymbolValue(vtemp); depth++; } if (globalcogbotTextForm != null) { LispObject jo = JavaObject.getInstance(globalcogbotTextForm); s.setSymbolValue(jo); if (exceptFor.Contains(globalcogbotTextForm)) return s; exceptFor.Add(globalcogbotTextForm); } if (true) return s; String ns = ic.getName(); if (!useClassname(ns)) return s; if (depth > 0) AddMembers(p, s, ic, exceptFor, depth-1); return s; }
private static void RemoveEntries(java.util.zip.ZipFile file, string[] items) { string destFileName = file.getName(); string tempFileName = Path.GetTempFileName(); ZipOutputStream destination = new ZipOutputStream(new FileOutputStream(tempFileName)); try { List<ZipEntry> zippedItems = GetZippedItems(file); List<string> list2 = new List<string>(); foreach (ZipEntry entry in zippedItems) { bool flag = false; foreach (string str3 in items) { if (str3 != entry.getName()) { flag = true; } } if (flag) { list2.Add(entry.getName()); } } CopyEntries(file, destination, list2.ToArray()); } finally { destination.close(); } file.close(); System.IO.File.Copy(tempFileName, destFileName, true); System.IO.File.Delete(tempFileName); }