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


C# JniEnvironment.CreateLocalFrame方法代码示例

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


在下文中一共展示了JniEnvironment.CreateLocalFrame方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: RegisterCounterpart

 internal static void RegisterCounterpart(JniEnvironment environment, Type counterpartType)
 {
     JniLocalFrame frame = environment.CreateLocalFrame(1);
     try
     {
         JniClass peer = GetJavaPeer(environment, counterpartType);
         RegisterCounterpart(environment, peer, counterpartType);
     }
     finally
     {
         frame.SafePop();
     }
 }
开发者ID:tottty,项目名称:csjni,代码行数:13,代码来源:JavaNativeMethodRegistrar.cs

示例4: GetJavaPeer

 internal static JniClass GetJavaPeer(JniEnvironment environment, Type counterpartType)
 {
     string peerClassName = FindJavaPeerClassName(counterpartType);
     JniLocalFrame frame = environment.CreateLocalFrame(1);
     try
     {
         JniClass peer = JniClass.FindClass(environment, JniClass.ToJniClassName(peerClassName));
         return frame.Pop(peer) as JniClass;
     }
     finally
     {
         frame.SafePop();
     }
 }
开发者ID:tottty,项目名称:csjni,代码行数:14,代码来源:JavaNativeMethodRegistrar.cs

示例5: ExtractStringArray

 public static string[] ExtractStringArray(JniEnvironment environment, JniObjectArray objectArray)
 {
     VerifyEnvironment(environment);
     VerifyInputJniObject(objectArray);
     int length = objectArray.GetArrayLength(environment);
     string[] output = new string[length];
     JniLocalFrame frame = environment.CreateLocalFrame(length);
     try
     {
         for (int i = 0; i < length; i++)
         {
             JniObject o = objectArray.GetObjectArrayElement(environment, i);
             output[i] = (o == null) ? null : o.ExtractStringValue(environment);
         }
     }
     finally
     {
         frame.SafePop();
     }
     return output;
 }
开发者ID:tottty,项目名称:csjni,代码行数:21,代码来源:JniString.cs

示例6: RegisterCounterpartAndReturnPeer

 internal static JniClass RegisterCounterpartAndReturnPeer(JniEnvironment environment, Type counterpartType)
 {
     JniLocalFrame frame = environment.CreateLocalFrame(1);
     try
     {
         JniClass peer = GetJavaPeer(environment, counterpartType);
         RegisterCounterpart(environment, peer, counterpartType);
         return frame.Pop(peer) as JniClass;
     }
     finally
     {
         frame.SafePop();
     }
 }
开发者ID:tottty,项目名称:csjni,代码行数:14,代码来源:JavaNativeMethodRegistrar.cs

示例7: ExtractStackTrace

        internal static string ExtractStackTrace(JniEnvironment environment, JniThrowable throwableObj)
        {
            JniLocalFrame frame = environment.CreateLocalFrame(10);
            try
            {
                // construct ByteArrayOutputStream
                JniClass baosClazz = JniClass.FindClass(environment, "java/io/ByteArrayOutputStream");
                JniConstructor baosCtorMid = baosClazz.GetConstructorId(environment, "()V");
                JniMethod baosFlushMid = baosClazz.GetMethodId(environment, "flush", "()V");
                JniMethod baosToStringMid = baosClazz.GetMethodId(environment, "toString", "()Ljava/lang/String;");
                JniObject baosObj = baosCtorMid.NewObject(environment, null);

                // construct PrintStream
                JniClass psClazz = JniClass.FindClass(environment, "java/io/PrintStream");
                JniConstructor psCtorMid = psClazz.GetConstructorId(environment, "(Ljava/io/OutputStream;)V");
                JValue[] ps_paramArray = new JValue[1];
                ps_paramArray[0].AssignObjectValue(baosObj);
                JniObject psObj = psCtorMid.NewObject(environment, ps_paramArray);

                // call printStackTrace
                JniClass throwableClazz = throwableObj.GetObjectClass(environment);
                JniMethod throwablePSTMid = throwableClazz.GetMethodId(environment, "printStackTrace", "(Ljava/io/PrintStream;)V");
                JValue[] t_paramArray = new JValue[1];
                t_paramArray[0].AssignObjectValue(psObj);
                throwablePSTMid.CallVoidMethod(environment, throwableObj, t_paramArray);

                // flush ByteArrayOutputStream & get string
                baosFlushMid.CallVoidMethod(environment, baosObj, null);
                string stackTrace = baosToStringMid.CallStringMethod(environment, baosObj, null);

                return stackTrace;
            }
            finally
            {
                frame.SafePop();
            }
        }
开发者ID:tottty,项目名称:csjni,代码行数:37,代码来源:JniThrowable.cs

示例8: GetJavaPropertyNames

 private static string[] GetJavaPropertyNames(JniEnvironment environment, JniClass systemClazz)
 {
     JniLocalFrame frame = environment.CreateLocalFrame(6);
     try
     {
         JniMethod getPropsMid = systemClazz.GetStaticMethodId(environment, "getProperties", "()Ljava/util/Properties;");
         JniObject propsHandle = getPropsMid.CallStaticObjectMethod(environment, null);
         JniClass propsClazz = propsHandle.GetObjectClass(environment);
         JniMethod keySetId = propsClazz.GetMethodId(environment, "keySet", "()Ljava/util/Set;");
         JniObject setHandle = keySetId.CallObjectMethod(environment, propsHandle, null);
         JniClass setClazz = setHandle.GetObjectClass(environment);
         JniMethod toArrayId = setClazz.GetMethodId(environment, "toArray", "()[Ljava/lang/Object;");
         JniObjectArray arrayHandle = (JniObjectArray)toArrayId.CallObjectMethod(environment, setHandle, null);
         string[] keyNames = JniString.ExtractStringArray(environment, arrayHandle);
         return keyNames;
     }
     finally
     {
         frame.SafePop();
     }
 }
开发者ID:tottty,项目名称:csjni,代码行数:21,代码来源:JavaSystemPropertiesHelper.cs

示例9: PackStringArray

 public static JniObjectArray PackStringArray(JniEnvironment environment, string[] input)
 {
     VerifyEnvironment(environment);
     VerifyInputObject(input); // OK if array is empty
     FaultStatics(environment);
     JniObjectArray array = JniObjectArray.NewObjectArray(environment, input.Length, mStringClass, null);
     for (int i = 0; i < input.Length; i++)
     {
         JniLocalFrame frame = environment.CreateLocalFrame(2);
         try
         {
             string theString = input[i];
             JniString sh = (theString == null) ? null : JniString.NewString(environment, theString);
             array.SetObjectArrayElement(environment, i, sh);
         }
         finally
         {
             frame.SafePop();
         }
     }
     return array;
 }
开发者ID:tottty,项目名称:csjni,代码行数:22,代码来源:JniString.cs


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