コード例 #1
0
ファイル: JavaInvoker.cs プロジェクト: SantoshPothina/Dummy
        /// <summary>
        /// Sends a request to the java process with one of the invoke options.
        /// Receives the response from the java process and it encapsulates it in JavaObject.
        /// Throws an exception if the result state is not Successful.
        /// </summary>
        /// <param name="requestType"></param>
        /// <param name="ct"></param>
        /// <param name="className"></param>
        /// <param name="methodName"></param>
        /// <param name="fieldName"></param>
        /// <param name="javaObject"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        private async Task <JavaObject> SendJavaRequest(RequestType requestType, CancellationToken ct,
                                                        string className         = null, string methodName     = null,
                                                        string fieldName         = null, JavaObject javaObject = null,
                                                        List <object> parameters = null, List <Type> parametersTypes = null)
        {
            var request = new JavaRequest()
            {
                RequestType = requestType,
                MethodName  = methodName,
                ClassName   = className,
                FieldName   = fieldName,
                Instance    = javaObject?.Instance,
            };

            request.AddParametersToRequest(parameters);

            JavaResponse response = await _javaService.RequestAsync(request, ct);

            ct.ThrowIfCancellationRequested();
            response.ThrowExceptionIfNeeded();

            return(new JavaObject()
            {
                Instance = response.Result
            });
        }
コード例 #2
0
ファイル: JavaInvoker.cs プロジェクト: SantoshPothina/Dummy
        public async Task LoadJar(string jarPath, CancellationToken ct)
        {
            var request = new JavaRequest()
            {
                RequestType = RequestType.LoadJar, JarPath = jarPath
            };

            JavaResponse response = await _javaService.RequestAsync(request, ct);

            ct.ThrowIfCancellationRequested();
            response.ThrowExceptionIfNeeded();
        }