public static string GetTaskTokenList(IVsCommentTaskInfo tokenInfo) { int tokenCount; if (Succeeded(tokenInfo.TokenCount(out tokenCount)) && tokenCount > 0) { var tokens = new IVsCommentTaskToken[tokenCount]; var tokensEnum = default(IVsEnumCommentTaskTokens); if (Succeeded(tokenInfo.EnumTokens(out tokensEnum))) { uint count; if (Succeeded(tokensEnum.Next((uint)tokenCount, tokens, out count))) { Contract.Requires(tokenCount == count); string text; var priority = new VSTASKPRIORITY[1]; var result = new List<string>(); foreach (var token in tokens) { if (Succeeded(token.Text(out text)) && Succeeded(token.Priority(priority)) && !string.IsNullOrWhiteSpace(text)) { result.Add(string.Format("{0}:{1}", text, (int)priority[0])); } } return string.Join("|", result); } } } return string.Empty; }
public static string GetTaskTokenList(IVsCommentTaskInfo tokenInfo) { int tokenCount; if (Succeeded(tokenInfo.TokenCount(out tokenCount)) && tokenCount > 0) { var tokens = new IVsCommentTaskToken[tokenCount]; var tokensEnum = default(IVsEnumCommentTaskTokens); if (Succeeded(tokenInfo.EnumTokens(out tokensEnum))) { uint count; if (Succeeded(tokensEnum.Next((uint)tokenCount, tokens, out count))) { Contract.Requires(tokenCount == count); string text; var priority = new VSTASKPRIORITY[1]; var result = new List <string>(); foreach (var token in tokens) { if (Succeeded(token.Text(out text)) && Succeeded(token.Priority(priority)) && !string.IsNullOrWhiteSpace(text)) { result.Add(string.Format("{0}:{1}", text, (int)priority[0])); } } return(string.Join("|", result)); } } } return(string.Empty); }
// called when OnCommentTaskInfoChanged is called. public void Refresh() { //Get token enumerator and allocate memory Guid guid = typeof(IVsCommentTaskInfo).GUID; IVsCommentTaskInfo commentTaskInfo = null; try { commentTaskInfo = (IVsCommentTaskInfo)this.site.QueryService(guid, typeof(IVsCommentTaskInfo)); if (commentTaskInfo == null) { return; } int count; commentTaskInfo.TokenCount(out count); IVsEnumCommentTaskTokens commentTaskTokens = null; commentTaskInfo.EnumTokens(out commentTaskTokens); Hashtable newTokens = new Hashtable(); //Get all tokens int index = 0; for (index = 0; index < count; index++) { uint fetched; IVsCommentTaskToken[] commentTaskToken = new IVsCommentTaskToken[1]; commentTaskTokens.Next(1, commentTaskToken, out fetched); if (fetched == 1) { string token = null; VSTASKPRIORITY[] priority = new VSTASKPRIORITY[1] { VSTASKPRIORITY.TP_NORMAL }; commentTaskToken[0].Text(out token); commentTaskToken[0].Priority(priority); if (token != null) { newTokens[token] = priority[0]; } } } //update the token information this.taskTokens = newTokens; } catch (Exception) { return; } }