当前位置: 首页>>代码示例>>C#>>正文


C# CsJni.JniEnvironment类代码示例

本文整理汇总了C#中CsJni.JniEnvironment的典型用法代码示例。如果您正苦于以下问题:C# JniEnvironment类的具体用法?C# JniEnvironment怎么用?C# JniEnvironment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JniEnvironment类属于CsJni命名空间,在下文中一共展示了JniEnvironment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RetrieveAll

        public static Dictionary<string, string> RetrieveAll(JniEnvironment environment)
        {
            Dictionary<string, string> properties = new Dictionary<string,string>();

            JniLocalFrame frame = environment.CreateLocalFrame(1);
            try
            {
                JniClass systemClazz = JniClass.FindClass(environment, "java/lang/System");
                string[] keyNames = GetJavaPropertyNames(environment, systemClazz);
                JniMethod getPropMid = systemClazz.GetStaticMethodId(environment, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;");

                foreach (string keyName in keyNames)
                {
                    JValue[] paramArray = new JValue[1];
                    paramArray[0].AssignStringValue(environment, keyName);
                    try
                    {
                        string val = getPropMid.CallStaticStringMethod(environment, paramArray);
                        properties.Add(keyName, val);
                    }
                    finally
                    {
                        paramArray[0].Free(environment);
                    }
                }
            }
            finally
            {
                frame.SafePop();
            }

            return properties;
        }
开发者ID:tottty,项目名称:csjni,代码行数:33,代码来源:JavaSystemPropertiesHelper.cs

示例2: CheckException

 public static void CheckException(JniEnvironment environment)
 {
     if (JniThrowable.ExceptionCheck(environment))
     {
         ThrowCurrentException(environment);
     }
 }
开发者ID:tottty,项目名称:csjni,代码行数:7,代码来源:JniThrowable.cs

示例3: Init

        internal static void Init(JniEnvironment environment)
        {
            if (JavaVM.IsLogTypeEnabled(JavaVMLogTypes.RedirectStdOut | JavaVMLogTypes.RedirectStdErr))
            {
                JniLocalFrame frame = environment.CreateLocalFrame(1);
                try
                {
                    JniClass peer = JavaNativeMethodRegistrar.RegisterCounterpartAndReturnPeer(environment,
                        typeof(JavaStdStreamRedirector));

                    if (JavaVM.IsLogTypeEnabled(JavaVMLogTypes.RedirectStdOut))
                    {
                        HookStream(environment, peer, JavaVMLogTypes.RedirectStdOut, "redirectStdOut");
                    }

                    if (JavaVM.IsLogTypeEnabled(JavaVMLogTypes.RedirectStdErr))
                    {
                        HookStream(environment, peer, JavaVMLogTypes.RedirectStdErr, "redirectStdErr");
                    }
                }
                finally
                {
                    frame.SafePop();
                }
            }
        }
开发者ID:tottty,项目名称:csjni,代码行数:26,代码来源:JavaStdStreamRedirector.cs

示例4: JniThreadMonitor

 internal JniThreadMonitor(JniEnvironment env, JniObject objectHandle)
 {
     JniObject.VerifyInputJniObject(objectHandle);
     mEnvironment = env;
     mObjectHandle = objectHandle;
     Enter();
 }
开发者ID:tottty,项目名称:csjni,代码行数:7,代码来源:JniThreadMonitor.cs

示例5: LogBannerProperties

        public static void LogBannerProperties(JniEnvironment environment)
        {
            Dictionary<string, string> properties = RetrieveAll(environment);

            JavaVM.Log("Current Java System Properties");

            string[] logPropNames = {
                "java.version",
                "java.vendor",
                "java.home",
                "java.vm.version",
                "java.vm.vendor",
                "java.vm.name",
                "java.class.version",
                "java.class.path",
                "java.library.path",
                "os.name",
                "os.arch",
                "os.version",
                "user.name",
                };

            foreach (string logPropName in logPropNames)
            {
                JavaVM.Log(logPropName + " = " + properties[logPropName]);
            }
        }
开发者ID:tottty,项目名称:csjni,代码行数:27,代码来源:JavaSystemPropertiesHelper.cs

示例6: ExtractStringFromHandle

 public static string ExtractStringFromHandle(JniEnvironment environment, IntPtr handle)
 {
     VerifyEnvironment(environment);
     unsafe
     {
         int length = GetStringLengthCore(environment, handle);
         char* p = JniEnvironment.Functions.GetStringCritical(environment.Handle, handle, null);
         if (p == null)
         {
             JniThrowable.ThrowCurrentException(environment);
         }
         try
         {
             // IMPORTANT - do not change code between GetStringCritical/ReleaseStringCritical.
             // See JNI documentation.
             return new String(p, 0, length);
         }
         finally
         {
             JniEnvironment.Functions.ReleaseStringCritical(environment.Handle, handle, p);
             // EXCEPTION CHECK: Do nothing, this method safe to call while exception is pending, does
             // not raise additional exceptions.
         }
     }
 }
开发者ID:tottty,项目名称:csjni,代码行数:25,代码来源:JniString.cs

示例7: ExceptionCheck

 public static bool ExceptionCheck(JniEnvironment environment)
 {
     byte result = JniEnvironment.Functions.ExceptionCheck(environment.Handle);
     // EXCEPTION CHECK: Do nothing, this method safe to call while exception is pending, does
     // not raise additional exceptions.
     return JBooleanConverter.From(result);
 }
开发者ID:tottty,项目名称:csjni,代码行数:7,代码来源:JniThrowable.cs

示例8: HookStream

 private static void HookStream(JniEnvironment environment, JniClass nativeClazz, 
     JavaVMLogTypes hook, string javaHookMethod)
 {
     JniMethod outMid = nativeClazz.GetStaticMethodId(environment, javaHookMethod, "(I)V");
     JValue[] paramArray = new JValue[1];
     paramArray[0].AssignIntValue((int)hook);
     outMid.CallStaticVoidMethod(environment, paramArray);
 }
开发者ID:tottty,项目名称:csjni,代码行数:8,代码来源:JavaStdStreamRedirector.cs

示例9: PackLongArray

 public static JniLongArray PackLongArray(JniEnvironment environment, long[] sourceArray)
 {
     VerifyEnvironment(environment);
     if (sourceArray == null) { return null; }
     JniLongArray arrayHandle = NewLongArray(environment, sourceArray.Length);
     if (sourceArray.Length > 0)
     {
         arrayHandle.PackPrimitiveArray<long>(environment, sourceArray);
     }
     return arrayHandle;
 }
开发者ID:tottty,项目名称:csjni,代码行数:11,代码来源:JniLongArray.cs

示例10: PackIntArray

 public static JniIntArray PackIntArray(JniEnvironment environment, int[] sourceArray)
 {
     VerifyEnvironment(environment);
     if (sourceArray == null) { return null; }
     JniIntArray arrayHandle = NewIntArray(environment, sourceArray.Length);
     if (sourceArray.Length > 0)
     {
         arrayHandle.PackPrimitiveArray<int>(environment, sourceArray);
     }
     return arrayHandle;
 }
开发者ID:tottty,项目名称:csjni,代码行数:11,代码来源:JniIntArray.cs

示例11: PackCharArray

 public static JniCharArray PackCharArray(JniEnvironment environment, char[] sourceArray)
 {
     VerifyEnvironment(environment);
     if (sourceArray == null) { return null; }
     JniCharArray arrayHandle = NewCharArray(environment, sourceArray.Length);
     if (sourceArray.Length > 0)
     {
         arrayHandle.PackPrimitiveArray<char>(environment, sourceArray);
     }
     return arrayHandle;
 }
开发者ID:tottty,项目名称:csjni,代码行数:11,代码来源:JniCharArray.cs

示例12: PackByteArray

 public static JniByteArray PackByteArray(JniEnvironment environment, byte[] sourceArray)
 {
     VerifyEnvironment(environment);
     if (sourceArray == null) { return null; }
     JniByteArray arrayHandle = NewByteArray(environment, sourceArray.Length);
     if (sourceArray.Length > 0)
     {
         arrayHandle.PackPrimitiveArray<byte>(environment, sourceArray);
     }
     return arrayHandle;
 }
开发者ID:tottty,项目名称:csjni,代码行数:11,代码来源:JniByteArray.cs

示例13: JniClass

 internal JniClass(JniEnvironment environment, IntPtr handle, JniObjectLifecycle lifecycle)
     : base(environment, handle, lifecycle)
 {
     // TODO - make this instance global???
     if (!mStaticsInitialized)
     {
         mStaticsInitialized = true;
         JniClass localClassClass = this.GetObjectClass(environment);
         // NOTE: no need to NewGlobalRef class handle for java.lang.Class, will not be unloaded
         mGetNameMid = localClassClass.GetMethodId(environment, "getName", "()Ljava/lang/String;");
     }
 }
开发者ID:tottty,项目名称:csjni,代码行数:12,代码来源:JniClass.cs

示例14: NewObjectCore

 public JniObject NewObjectCore(JniEnvironment environment, JValue[] arguments, JniConcreteObjectType concreteType)
 {
     VerifyEnvironment(environment);
     // NOTE: OK if "JValue[] arguments" is null
     IntPtr result = JniEnvironment.Functions.NewObjectA(environment.Handle, this.DeclaringClass.Handle, this.Handle, arguments);
     if (IntPtr.Zero == result)
     {
         JniThrowable.ThrowCurrentException(environment); // null result means an exception occurred
     }
     // EXCEPTION CHECK: Do nothing, already checked for exception above.
     return JniObject.CreateObjectOfType(environment, result, concreteType);
 }
开发者ID:tottty,项目名称:csjni,代码行数:12,代码来源:JniConstructor.cs

示例15: GetDoubleField

 public double GetDoubleField(
     JniEnvironment environment,
     JniObject jniObject)
 {
     VerifyReturnType(JniType.Double);
     VerifyEnvironment(environment);
     VerifyNotStatic();
     VerifyInputJniObject(jniObject);
     double result = JniEnvironment.Functions.GetDoubleField(environment.Handle, jniObject.Handle, this.Handle);
     JniThrowable.CheckException(environment);
     return result;
 }
开发者ID:tottty,项目名称:csjni,代码行数:12,代码来源:JniField.cs


注:本文中的CsJni.JniEnvironment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。