/// <summary> /// Specify the dir containing your docx4j properties file /// </summary> /// <param name="dir"></param> public static void setDocx4jPropertiesDir(string dir) { ILog log = LogManager.GetCurrentClassLogger(); java.net.URL url = (new java.io.File(dir)).toURL(); //java.net.URL url = new java.net.URL("file:///C:/Users/jharrop/Documents/Visual%20Studio%202010/Projects/docx4j.NET/docx4j.NET/src/samples/resources/"); // also OK java.lang.ClassLoader contextCL = java.lang.Thread.currentThread().getContextClassLoader(); java.lang.ClassLoader urlCL = java.net.URLClassLoader.newInstance(new java.net.URL[] { url }, contextCL); java.lang.Thread.currentThread().setContextClassLoader(urlCL); //java.lang.Class clazz = typeof(org.docx4j.utils.ResourceUtils); //java.lang.ClassLoader contextCL = clazz.getClassLoader(); //log.Warn(contextCL.getClass().getName()); // ikvm.runtime.AssemblyClassLoader //ikvm.runtime.AssemblyClassLoader acl = contextCL as ikvm.runtime.AssemblyClassLoader; // you can delete the below if the properties file is being found if (urlCL.getResource("docx4j.properties") == null) { log.Warn(url.toString() + " dir does not appear to contain docx4j.properties!"); } else { log.Info(url.toString() + " dir contains docx4j.properties!"); } }
public static Object LoadFromUri(java.net.URL url, string baseUri, org.openrdf.rio.RDFFormat rdff) { Object obj; Uri u = new Uri(url.toString()); if (rdff == dotSesameFormats.RDFFormat.N3) { obj = new Graph(); if (baseUri != null) { ((IGraph)obj).BaseUri = new Uri(baseUri); } UriLoader.Load((IGraph)obj, u, new Notation3Parser()); } else if (rdff == dotSesameFormats.RDFFormat.NTRIPLES) { obj = new Graph(); if (baseUri != null) { ((IGraph)obj).BaseUri = new Uri(baseUri); } UriLoader.Load((IGraph)obj, u, new NTriplesParser()); } else if (rdff == dotSesameFormats.RDFFormat.RDFXML) { obj = new Graph(); if (baseUri != null) { ((IGraph)obj).BaseUri = new Uri(baseUri); } UriLoader.Load((IGraph)obj, u, new RdfXmlParser()); } else if (rdff == dotSesameFormats.RDFFormat.TRIG || rdff == dotSesameFormats.RDFFormat.TRIX) { obj = new TripleStore(); UriLoader.Load((ITripleStore)obj, u); } else if (rdff == dotSesameFormats.RDFFormat.TURTLE) { obj = new Graph(); if (baseUri != null) { ((IGraph)obj).BaseUri = new Uri(baseUri); } UriLoader.Load((IGraph)obj, u, new TurtleParser()); } else { throw new RdfParserSelectionException("The given Input Format is not supported by dotNetRDF"); } return(obj); }
/// <summary> /// Specify the dir containing your docx4j properties file /// </summary> /// <param name="dir"></param> public static void setDocx4jPropertiesDir(string dir) { ILog log = LogManager.GetCurrentClassLogger(); java.net.URL url = (new java.io.File(dir)).toURL(); //java.net.URL url = new java.net.URL("file:///C:/Users/jharrop/Documents/Visual%20Studio%202010/Projects/docx4j.NET/docx4j.NET/src/samples/resources/"); // also OK java.lang.ClassLoader contextCL = java.lang.Thread.currentThread().getContextClassLoader(); java.lang.ClassLoader urlCL = java.net.URLClassLoader.newInstance(new java.net.URL[] { url }, contextCL); java.lang.Thread.currentThread().setContextClassLoader(urlCL); // you can delete the below if the properties file is being found if (log.IsWarnEnabled && urlCL.getResource("docx4j.properties") == null) { log.Warn(url.toString() + " dir does not appear to contain docx4j.properties!"); } }