示例#1
0
        internal RelatedLink(int related, [CanBeNull] IWorkItemLinkTypeEnd linkTypeEnd = null, [CanBeNull] string comment = null)
            : base(comment, BaseLinkType.RelatedLink)
        {
            RelatedWorkItemId = related;

            LinkTypeEnd = linkTypeEnd;
        }
示例#2
0
 internal void SetForwardEnd(IWorkItemLinkTypeEnd value)
 {
     if (_forward != null)
     {
         throw new InvalidOperationException($"{nameof(ForwardEnd)} already contains a value.".ToString(CultureInfo.InvariantCulture));
     }
     _forward = value ?? throw new ArgumentNullException(nameof(value));
 }
示例#3
0
 public MockRelatedLink(IWorkItemLinkTypeEnd linkTypeEnd, int sourceId, int targetId)
     : base(targetId, linkTypeEnd)
 {
     if (sourceId == targetId)
     {
         throw new ArgumentException($"Parameter {nameof(sourceId)} cannot be the same as {nameof(targetId)}.");
     }
     LinkInfo = new WorkItemLinkInfo(sourceId, targetId, linkTypeEnd);
 }
示例#4
0
 /// <summary>
 /// Safes the write identifier.
 /// </summary>
 /// <param name="workItemLinkTypeEnd">The work item link type end.</param>
 /// <returns>String.</returns>
 private static String SafeWriteId(IWorkItemLinkTypeEnd workItemLinkTypeEnd)
 {
     try
     {
         return(String.Format("{0}", workItemLinkTypeEnd.Id));
     }
     catch (Exception ex)
     {
         return(String.Format("{0}:{1}", ex.GetType().Name, ex.Message));
     }
 }
示例#5
0
        internal WorkItemLinkType([NotNull] string referenceName, [NotNull] IWorkItemLinkTypeEnd forward, [NotNull] IWorkItemLinkTypeEnd reverse)
            : this(referenceName)
        {
            Contract.Requires(!string.IsNullOrEmpty(referenceName));
            Contract.Requires(forward != null);
            Contract.Requires(reverse != null);

            _forward    = forward ?? throw new ArgumentNullException(nameof(forward));
            _reverse    = reverse ?? throw new ArgumentNullException(nameof(reverse));
            _forwardFac = null;
            _reverseFac = null;
        }
示例#6
0
        public override IRelatedLink CreateRelatedLink(int id, IWorkItemLinkTypeEnd linkTypeEnd = null)
        {
            if (IsNew)
            {
                throw new InvalidOperationException("Save first");
            }
            if (id != 0 &&
                linkTypeEnd == null)
            {
                throw new ArgumentException($"Value cannot be zero when no {nameof(IWorkItemLinkTypeEnd)} specified.", nameof(id));
            }

            if (id == 0 && linkTypeEnd == null)
            {
                return(new MockRelatedLink(null, Id));
            }

            return(new MockRelatedLink(linkTypeEnd, Id, id));
        }
        /// <summary>
        /// Gets the Id from the specified <paramref name="item"/>.
        /// </summary>
        /// <param name="item">An instance of <see cref="IWorkItemLinkTypeEnd"/>.</param>
        /// <returns>
        /// 0 if <paramref name="item"/> is null or the <see cref="M:IWorkItemLinkTypeEnd.LinkType"/> is null; otherwise the link type id.
        /// </returns>
        /// <remarks>
        /// A true Id is only returned for SOAP instances of <paramref name="item"/>
        /// </remarks>
        public static int LinkTypeId(this IWorkItemLinkTypeEnd item)
        {
            // No link type. In SOAP this is equivilent to SELF and has a constant id of 0
            if (item == null)
            {
                return(0);
            }

            // In SOAP, the IWorkItemLinkTypeEnd is IIdentifiable<int>. Try to cast and return the Id
            if (item is IIdentifiable <int> i)
            {
                return(i.Id);
            }

            // Same as initial case--no link type.
            if (item.LinkType == null)
            {
                return(0);
            }

            // Hack for REST: If there is an immutable name, get a case-insensitive hash
            if (!string.IsNullOrEmpty(item.ImmutableName))
            {
                var hash = Math.Abs(StringComparer.OrdinalIgnoreCase.GetHashCode(item.ImmutableName));
                // Forward links are ALWAYS a positive value
                if (item.IsForwardLink)
                {
                    return(hash);
                }

                // Reverse links are ALWAYS a negative value
                return(hash * -1);
            }

            return(0);
        }
 partial void ReverseEnd_SetCondition(ref IWorkItemLinkType instance, ref IWorkItemLinkTypeEnd setValue);
 partial void ForwardEnd_SetCondition(ref IWorkItemLinkType instance, ref IWorkItemLinkTypeEnd setValue);
示例#10
0
 public IRelatedLink CreateRelatedLink(IWorkItemLinkTypeEnd linkTypeEnd, IWorkItem relatedWorkItem)
 {
     throw new NotImplementedException();
 }
示例#11
0
 internal WorkItemLinkInfo(int sourceId, int targetId, [CanBeNull] IWorkItemLinkTypeEnd linkTypeEnd)
 {
     SourceId     = sourceId;
     TargetId     = targetId;
     _linkTypeEnd = linkTypeEnd;
 }
示例#12
0
        public static WorkItemLinkTypeEnd Map(WorkItemStore store, IWorkItemLinkTypeEnd end)
        {
            var linkType = store.WorkItemLinkTypes.Single(type => type.ReferenceName == end.LinkType.ReferenceName);

            return(end.IsForwardLink ? linkType.ForwardEnd : linkType.ReverseEnd);
        }
示例#13
0
 partial void IsForwardLink_SetCondition(ref IWorkItemLinkTypeEnd instance, ref Boolean setValue);
示例#14
0
 private IWorkItemLinkTypeEnd CoerceForwardValue()
 {
     return(_forward ?? (_forward = _forwardFac.Value));
 }
示例#15
0
 /// <inheritdoc />
 internal WorkItemLinkInfo(int sourceId, int targetId, int linkTypeId, [CanBeNull] IWorkItemLinkTypeEnd linkTypeEnd)
     : base(sourceId, targetId, linkTypeEnd)
 {
     Id = linkTypeId;
 }
示例#16
0
 public MockRelatedLink(IWorkItemLinkTypeEnd linkTypeEnd)
     : base(0, linkTypeEnd)
 {
     LinkInfo = new WorkItemLinkInfo(0, 0, linkTypeEnd);
 }
示例#17
0
 /// <summary>
 ///     Tries the name of the get by.
 /// </summary>
 /// <param name="linkTypeEndName">End name of the link type.</param>
 /// <param name="linkTypeEnd">The link type end.</param>
 /// <returns>Boolean.</returns>
 /// <exception cref="DynCon.OSI.Core.Helpers.ToBeImplementedException"></exception>
 Boolean IWorkItemLinkTypeEndCollection.TryGetByName(String linkTypeEndName, out IWorkItemLinkTypeEnd linkTypeEnd)
 {
     throw new ToBeImplementedException();
 }
示例#18
0
 /// <summary>
 ///     Tries the get by identifier.
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <param name="linkTypeEnd">The link type end.</param>
 /// <returns>Boolean.</returns>
 /// <exception cref="DynCon.OSI.Core.Helpers.ToBeImplementedException"></exception>
 Boolean IWorkItemLinkTypeEndCollection.TryGetById(Int32 id, out IWorkItemLinkTypeEnd linkTypeEnd)
 {
     throw new ToBeImplementedException();
 }
示例#19
0
        public IRelatedLink CreateRelatedLink(IWorkItemLinkTypeEnd linkTypeEnd, IWorkItem relatedWorkItem)
        {
            var rawLinkTypeEnd = LinkTypeEndMapper.Map(_item.Store, linkTypeEnd);

            return(ExceptionHandlingDynamicProxyFactory.Create <IRelatedLink>(new RelatedLinkProxy(new Tfs.RelatedLink(rawLinkTypeEnd, relatedWorkItem.Id))));
        }
 partial void LinkTypeEnd_SetCondition(ref IRelatedLink instance, ref IWorkItemLinkTypeEnd setValue);
示例#21
0
 partial void OppositeEnd_SetCondition(ref IWorkItemLinkTypeEnd instance, ref IWorkItemLinkTypeEnd setValue);
示例#22
0
 partial void ImmutableName_SetCondition(ref IWorkItemLinkTypeEnd instance, ref String setValue);
示例#23
0
 private IWorkItemLinkTypeEnd CoerceReverseValue()
 {
     return(_reverse ?? (_reverse = _reverseFac.Value));
 }
示例#24
0
        internal static Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemLinkTypeEnd Map(Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore store, IWorkItemLinkTypeEnd end)
        {
            var linkType = store.WorkItemLinkTypes.Single(type => type.ReferenceName == end.LinkType.ReferenceName);

            return(end.IsForwardLink ? linkType.ForwardEnd : linkType.ReverseEnd);
        }
示例#25
0
 public MockRelatedLink(IWorkItemLinkTypeEnd linkTypeEnd, int targetId)
     : base(targetId, linkTypeEnd)
 {
     LinkInfo = new WorkItemLinkInfo(0, targetId, linkTypeEnd);
 }