コード例 #1
0
        /// <summary>
        /// Adds a single link to another work item
        /// </summary>
        /// <param name="adapter">Adapter used to look up more information about the referenced work items.</param>
        /// <param name="id">The id of the other work item.</param>
        /// <param name="link">Link type.</param>
        private void AddLink(IWorkItemSyncAdapter adapter, int id, IConfigurationLinkItem link)
        {
            var range = GetLinkRange(link);

            if (range == null)
            {
                return;
            }

            range.Collapse(WdCollapseDirection.wdCollapseEnd);
            var bookmarks = Table.Range.Document.Bookmarks;
            var workItem  = adapter.WorkItems.Find(id);

            // if we can look up the work item, format the output. Otherwise only display the work item id
            var linkTitle = workItem == null?id.ToString(CultureInfo.InvariantCulture) : link.Format(workItem);

            // insert hyper link to target work item bookmark
            range.Text = linkTitle;
            if (bookmarks.Exists(id))
            {
                range.Hyperlinks.Add(range, SubAddress: bookmarks.Item(id));
                range.SetRange(range.End + 1, range.End + 1);
            }

            range.Collapse(WdCollapseDirection.wdCollapseEnd);
        }
コード例 #2
0
ファイル: TfsWorkItemTests.cs プロジェクト: qanh96/WordToTFS
 private void RemoveExistingLinksOfGivenLinkTypeFromWorkItem(IConfigurationLinkItem linkConfiguration, IWorkItem workItem)
 {
     workItem.AddLinks(
         _adapter,
         new int[] { },
         linkConfiguration.LinkValueType,
         true);
     InvalidateTestIfNotEqual(0, GetIdsOfLinksOfGivenLinkTypeFromWorkItem(linkConfiguration, workItem).Length, "workItem.AddLinks() did not deleted all links successfully.");
 }
コード例 #3
0
        /// <summary>
        /// Wraps cached access to the ranges of link fields.
        /// </summary>
        private Range GetLinkRange(IConfigurationLinkItem linkConfiguration)
        {
            if (_linkRangeCache.ContainsKey(linkConfiguration) == false)
            {
                var range = WordSyncHelper.GetCellRange(Table, linkConfiguration.RowIndex, linkConfiguration.ColIndex);
                _linkRangeCache.Add(linkConfiguration, range);
            }

            return(_linkRangeCache[linkConfiguration]);
        }
コード例 #4
0
ファイル: TfsWorkItemTests.cs プロジェクト: qanh96/WordToTFS
 private int[] GetIdsOfLinksOfGivenLinkTypeFromWorkItem(IConfigurationLinkItem linkConfiguration, IWorkItem workItem)
 {
     return(workItem.Links.First(x => x.Key.LinkValueType == linkConfiguration.LinkValueType).Value);
 }