public void Array_Integer() { var l = DS.Array(1, 2, 3); Assert.AreEqual(1, l[0]); Assert.AreEqual(2, l[1]); Assert.AreEqual(3, l[2]); }
private bool LoadPowerShellIntellisense() { try { var powerShellCommandDefs = DS.Resources.GetTextResource(new System.Text.RegularExpressions.Regex("PS1.GenerateIntellisense.Txt..*gzip$", RegexOptions.IgnoreCase), Assembly.GetExecutingAssembly(), true, DS.TextResourceEncoding.Unicode); foreach (var e in powerShellCommandDefs) { var parts = e.Key.Split('.'); var commandName = parts[parts.Length - 3].ToLower(); var helpLines = powerShellCommandDefs[e.Key].Split(DS.Array(Environment.NewLine), StringSplitOptions.None).ToList(); for (var i = 0; i < helpLines.Count; i++) { var line = helpLines[i]; if (line == "PARAMETERS") { i++; var parametersDefIndex = i; PowerShellDefinitions.Add(commandName, new IntellisenseDefinitionItems()); while (i < helpLines.Count) { var line2 = helpLines[i]; if (line2.Contains(POWERSHELL_HELP_END_OF_PARAMETER_SECTION)) { break; } else if (line2.StartsWith(POWERSHELL_HELP_DETECT_NEW_DASH_PARAMETER_DEFINITION)) { var intellisenseKeyWord = line2.Trim().Split(' ')[0]; if (intellisenseKeyWord.StartsWith("-")) { intellisenseKeyWord = intellisenseKeyWord.Substring(1); } var helpDescription = this.ExtractDashParameterHelp(intellisenseKeyWord, helpLines, parametersDefIndex); PowerShellDefinitions[commandName].Add(new IntellisenseDefinitionItem(intellisenseKeyWord.ToLower(), intellisenseKeyWord, helpDescription)); } i++; } break; } } } return(true); } catch (System.Exception ex) { #if DEBUG System.Diagnostics.Debugger.Break(); #endif return(false); } }
string GetWordAtTheBeginningOfLine(List <string> powerShellParameters) { SnapshotPoint caret = TextView.Caret.Position.BufferPosition; ITextSnapshot snapshot = caret.Snapshot; ICompletionSession session = null; powerShellParameters.Clear(); try { if (!Broker.IsCompletionActive(TextView)) { session = Broker.CreateCompletionSession(TextView, snapshot.CreateTrackingPoint(caret, PointTrackingMode.Positive), true); } else { session = Broker.GetSessions(TextView)[0]; } var triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot); if (triggerPoint != null) { var lineSnapshot = triggerPoint.GetContainingLine(); var allText = lineSnapshot.Snapshot.GetText(); var t1 = allText.Substring(0, caret.Position).Trim(); var pipePos = t1.LastIndexOf('|'); if (pipePos != -1) { t1 = t1.Substring(pipePos + 1).Trim(); } var parts = t1.Split(DS.Array(Environment.NewLine), StringSplitOptions.None); var theLine = parts[parts.Length - 1]; var parts2 = theLine.Split(' '); powerShellParameters.AddRange(GetListOfDashParameter(theLine)); return(parts2[0]); } } catch { // Swallo exception to avoid disrupting Visual Studio } finally{ session.Dismiss(); } return(null); }