Exemple #1
0
        public static void runScript(java.lang.Class clazz)
        {
            java.lang.reflect.Method runMethod = clazz.getMethod("run", new java.lang.Class[] { });
            Object obj = clazz.newInstance();

            runMethod.invoke(obj, new object[] {});
        }
Exemple #2
0
        static public bool cliJavaToString(PlTerm paramIn, PlTerm valueOut)
        {
            if (!valueOut.IsVar)
            {
                var plvar = PlTerm.PlVar();
                return(cliJavaToString(paramIn, plvar) && SpecialUnify(valueOut, plvar));
            }
            object getInstance = GetInstance(paramIn);

            if (getInstance == null)
            {
                return(valueOut.Unify(PlTerm.PlString("null")));
            }
#if USE_IKVM
            object val = getInstance as java.lang.Object;
            if (val == null)
            {
                Class  c = ikvm.runtime.Util.getClassFromObject(getInstance);
                string s = (string)c.getMethod("toString", new Class[0]).invoke(getInstance, ZERO_OBJECTS);
                return(valueOut.Unify(PlTerm.PlString(s)));
            }
            return(valueOut.Unify(PlTerm.PlString(val.toString())));
#else
            object val = getInstance;
            return(valueOut.Unify(PlTerm.PlString(val.ToString())));
#endif
        }
        void ChangeToSSLSocket()
        {
#if TARGET_JVM
            java.lang.Class          c = vmw.common.TypeUtils.ToClass(smtp.Stream);
            java.lang.reflect.Method m = c.getMethod("ChangeToSSLSocket", null);
            m.invoke(smtp.Stream, new object[] {});
#else
            // Load Mono.Security.dll
            Assembly a;
            try
            {
                a = Assembly.Load(Consts.AssemblyMono_Security);
            }
            catch (System.IO.FileNotFoundException)
            {
                throw new SmtpException("Cannot load Mono.Security.dll");
            }
            Type     tSslClientStream = a.GetType("Mono.Security.Protocol.Tls.SslClientStream");
            object[] consArgs         = new object[4];
            consArgs[0] = smtp.Stream;
            consArgs[1] = server;
            consArgs[2] = true;
            Type tSecurityProtocolType = a.GetType("Mono.Security.Protocol.Tls.SecurityProtocolType");
            int  nSsl3Val = (int)Enum.Parse(tSecurityProtocolType, "Ssl3");
            int  nTlsVal  = (int)Enum.Parse(tSecurityProtocolType, "Tls");
            consArgs[3] = Enum.ToObject(tSecurityProtocolType, nSsl3Val | nTlsVal);

            object objSslClientStream = Activator.CreateInstance(tSslClientStream, consArgs);

            if (objSslClientStream != null)
            {
                smtp = new SmtpStream((Stream)objSslClientStream);
            }
#endif
        }