ExpandHelpTopic() static private method

static private ExpandHelpTopic ( string path, string helpTopic ) : string
path string
helpTopic string
return string
Exemplo n.º 1
0
 // Called in a macro context
 public void Refresh()
 {
     if (_intelliSense != null)
     {
         return; // Already done
     }
     try
     {
         // Parse first
         var xml = _xmlIntelliSense;
         if (xml == null)
         {
             xml = File.ReadAllText(_fileName);
         }
         _intelliSense = XmlIntelliSense.Parse(xml, _fileName);
         if (_intelliSense?.XmlFunctionInfo?.FunctionsList != null)
         {
             // Fix up SourcePath (is this used?) and HelpTopic
             foreach (var func in _intelliSense.XmlFunctionInfo.FunctionsList)
             {
                 func.SourcePath = _fileName;
                 func.Name       = func.Name.Trim();
                 func.HelpTopic  = FunctionInfo.ExpandHelpTopic(_path, func.HelpTopic);
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Provider.Warn($"XmlIntelliSenseProvider - Loading IntelliSense from file {_fileName} failed:\r\n\t{ex.Message}");
         _intelliSense = XmlIntelliSense.Empty;
     }
 }
            // Not in macro context - don't call Excel, could be any thread.
            public IEnumerable <FunctionInfo> GetFunctionInfos()
            {
                // to avoid worries about locking and this being updated from another thread, we take a copy of the _regInfo reference
                var regInfo = _regInfo;

                if (regInfo == null)
                {
                    yield break;
                }

                int numRows = regInfo.GetLength(0);
                int numCols = regInfo.GetLength(1);

                if (numRows < 1 || numCols < 1)
                {
                    yield break;
                }

                var idCheck = regInfo[1, 1] as string;

                if (!functionInfoId.Equals(idCheck, StringComparison.OrdinalIgnoreCase))
                {
                    Logger.Provider.Warn($"WorkbookIntelliSenseProvider - Invalid FunctionInfo Identifier: ({idCheck})");
                    yield break;
                }

                // regInfo is 1-based: object[1..x, 1..y].
                for (int i = 2; i <= numRows; i++)
                {
                    string functionName = regInfo[i, 1] as string;
                    string description  = regInfo[i, 2] as string;
                    string helpTopic    = regInfo[i, 3] as string;

                    if (string.IsNullOrEmpty(functionName))
                    {
                        continue;
                    }

                    List <FunctionInfo.ArgumentInfo> argumentInfos = new List <FunctionInfo.ArgumentInfo>();
                    for (int j = 4; j <= numCols - 1; j += 2)
                    {
                        var arg     = regInfo[i, j] as string;
                        var argDesc = regInfo[i, j + 1] as string;
                        if (!string.IsNullOrEmpty(arg))
                        {
                            argumentInfos.Add(new FunctionInfo.ArgumentInfo
                            {
                                Name        = arg,
                                Description = argDesc
                            });
                        }
                    }

                    // Some cleanup and normalization
                    functionName = functionName.Trim();
                    helpTopic    = FunctionInfo.ExpandHelpTopic(_path, helpTopic);

                    yield return(new FunctionInfo
                    {
                        Name = functionName,
                        Description = description,
                        HelpTopic = helpTopic,
                        ArgumentList = argumentInfos,
                        SourcePath = _name
                    });
                }
            }