示例#1
0
 /// <summary>
 /// Fetches help on the function from R asynchronously.
 /// When function data is obtained, parsed and the function
 /// index is updated, method invokes <see cref="infoReadyCallback"/>
 /// callback passing the specified parameter. Callback method can now
 /// fetch function information from the index.
 /// </summary>
 private void GetFunctionInfoFromEngineAsync(string functionName, string packageName, Action <object> infoReadyCallback = null, object parameter = null)
 {
     _functionRdDataProvider.GetFunctionRdDataAsync(functionName, packageName,
                                                    rdData => {
         UpdateIndex(functionName, rdData);
         if (infoReadyCallback != null)
         {
             _coreShell.DispatchOnUIThread(() => {
                 infoReadyCallback(parameter);
             });
         }
     });
 }
示例#2
0
        /// <summary>
        /// Fetches help on the function from R asynchronously.
        /// </summary>
        private async Task <IFunctionInfo> GetFunctionInfoFromEngineAsync(string functionName, string packageName)
        {
            if (!IsValidFunctionName(functionName))
            {
                return(null);
            }

            TryGetCachedFunctionInfo(functionName, ref packageName);

            packageName = packageName ?? await _host.GetFunctionPackageNameAsync(functionName);

            if (string.IsNullOrEmpty(packageName))
            {
                return(null);
            }

            var rdData = await _functionRdDataProvider.GetFunctionRdDataAsync(functionName, packageName);

            if (!string.IsNullOrEmpty(rdData))
            {
                // If package is found update data in the index
                UpdateIndex(functionName, packageName, rdData);
                return(TryGetCachedFunctionInfo(functionName, ref packageName));
            }
            return(null);
        }
示例#3
0
        /// <summary>
        /// Fetches help on the function from R asynchronously.
        /// When function data is obtained, parsed and the function
        /// index is updated, method invokes <see cref="infoReadyCallback"/>
        /// callback passing the specified parameter. Callback method can now
        /// fetch function information from the index.
        /// </summary>
        private async Task <string> GetFunctionInfoFromEngineAsync(string functionName, string packageName, Action <object, string> infoReadyCallback = null, object parameter = null)
        {
            packageName = packageName ?? await _host.GetFunctionPackageNameAsync(functionName);

            if (string.IsNullOrEmpty(packageName))
            {
                // Even if nothing is found, still notify the callback
                if (infoReadyCallback != null)
                {
                    _coreShell.DispatchOnUIThread(() => {
                        infoReadyCallback(null, null);
                    });
                }
                return(packageName);
            }

            if (infoReadyCallback == null)
            {
                // regular async call
                var rdData = await _functionRdDataProvider.GetFunctionRdDataAsync(functionName, packageName);

                if (!string.IsNullOrEmpty(rdData))
                {
                    // If package is found update data in the index
                    UpdateIndex(functionName, packageName, rdData);
                }
                return(packageName);
            }

            _functionRdDataProvider.GetFunctionRdDataAsync(functionName, packageName,
                                                           rdData => {
                if (!string.IsNullOrEmpty(packageName) && !string.IsNullOrEmpty(rdData))
                {
                    // If package is found update data in the index
                    UpdateIndex(functionName, packageName, rdData);
                }
                _coreShell.DispatchOnUIThread(() => infoReadyCallback(parameter, packageName));
            });
            return(packageName);
        }