in ErrorList/C#/SpellingErrorsSnapshot.cs [69:161]
public override bool TryGetValue(int index, string columnName, out object content)
{
if ((index >= 0) && (index < this.Errors.Count))
{
if (columnName == StandardTableKeyNames.DocumentName)
{
// We return the full file path here. The UI handles displaying only the Path.GetFileName().
content = _filePath;
return true;
}
else if (columnName == StandardTableKeyNames.ErrorCategory)
{
content = "Documentation";
return true;
}
else if (columnName == StandardTableKeyNames.ErrorSource)
{
content = "Spelling";
return true;
}
else if (columnName == StandardTableKeyNames.Line)
{
// Line and column numbers are 0-based (the UI that displays the line/column number will add one to the value returned here).
content = this.Errors[index].Span.Start.GetContainingLine().LineNumber;
return true;
}
else if (columnName == StandardTableKeyNames.Column)
{
var position = this.Errors[index].Span.Start;
var line = position.GetContainingLine();
content = position.Position - line.Start.Position;
return true;
}
else if (columnName == StandardTableKeyNames.Text)
{
content = string.Format(CultureInfo.InvariantCulture, "Spelling: {0}", this.Errors[index].Span.GetText());
return true;
}
else if (columnName == StandardTableKeyNames2.TextInlines)
{
var inlines = new List<Inline>();
inlines.Add(new Run("Spelling: "));
inlines.Add(new Run(this.Errors[index].Span.GetText())
{
FontWeight = FontWeights.ExtraBold
});
content = inlines;
return true;
}
else if (columnName == StandardTableKeyNames.ErrorSeverity)
{
content = __VSERRORCATEGORY.EC_MESSAGE;
return true;
}
else if (columnName == StandardTableKeyNames.ErrorSource)
{
content = ErrorSource.Other;
return true;
}
else if (columnName == StandardTableKeyNames.BuildTool)
{
content = "SpellChecker";
return true;
}
else if (columnName == StandardTableKeyNames.ErrorCode)
{
content = this.Errors[index].Span.GetText();
return true;
}
else if ((columnName == StandardTableKeyNames.ErrorCodeToolTip) || (columnName == StandardTableKeyNames.HelpLink))
{
content = string.Format(CultureInfo.InvariantCulture, "http://www.bing.com/search?q={0}", this.Errors[index].Span.GetText());
return true;
}
// We should also be providing values for StandardTableKeyNames.Project & StandardTableKeyNames.ProjectName but that is
// beyond the scope of this sample.
}
content = null;
return false;
}