private WorkItemLinkTypeEnd ParseLinkEnd(WiLink link, WorkItem wi)
        {
            var props    = link.WiType?.Split('-');
            var linkType = wi.Project.Store.WorkItemLinkTypes.SingleOrDefault(lt => lt.ReferenceName == props?[0]);

            if (linkType == null)
            {
                Logger.Log(LogLevel.Error, $"'{link.ToString()}' - link type ({props?[0]}) does not exist in project");
                return(null);
            }

            WorkItemLinkTypeEnd linkEnd = null;

            if (linkType.IsDirectional)
            {
                if (props?.Length > 1)
                {
                    linkEnd = props[1] == "Forward" ? linkType.ForwardEnd : linkType.ReverseEnd;
                }
                else
                {
                    Logger.Log(LogLevel.Error, $"'{link.ToString()}' - link direction not provided for '{wi.Id}'.");
                }
            }
            else
            {
                linkEnd = linkType.ForwardEnd;
            }

            return(linkEnd);
        }
        private bool RemoveLink(WiLink link, WorkItem wi)
        {
            var linkToRemove = wi.Links.OfType <RelatedLink>().SingleOrDefault(rl => rl.LinkTypeEnd.ImmutableName == link.WiType && rl.RelatedWorkItemId == link.TargetWiId);

            if (linkToRemove == null)
            {
                Logger.Log(LogLevel.Warning, $"{link.ToString()} - cannot identify link to remove for '{wi.Id}'.");
                return(false);
            }
            wi.Links.Remove(linkToRemove);
            return(true);
        }