Exemple #1
0
        private static void ThrowIfInvalidArtifactLink(IProductElement elementWithArtifactLink, IItemContainer targetItem)
        {
            if (targetItem == null)
            {
                tracer.Verbose(
                    Resources.PathResolver_TraceInvalidArtifactLink, elementWithArtifactLink.GetSafeInstanceName());

                throw new InvalidOperationException(string.Format(
                                                        CultureInfo.CurrentCulture,
                                                        Resources.PathResolver_ErrorInvalidArtifactLink,
                                                        elementWithArtifactLink.TryGetReference(ReferenceKindConstants.SolutionItem),
                                                        elementWithArtifactLink.GetSafeInstanceName()));
            }
        }
Exemple #2
0
        private static void ThrowIfNoAncestorWithLink(IProductElement context, IProductElement ancestor, string path)
        {
            if (ancestor == null)
            {
                tracer.Verbose(
                    Resources.PathResolver_TraceNoAncestor);

                throw new InvalidOperationException(string.Format(
                                                        CultureInfo.CurrentCulture,
                                                        Resources.PathResolver_ErrorNoAncestorWithArtifactLink,
                                                        context.GetSafeInstanceName(),
                                                        path));
            }
        }
Exemple #3
0
        private static void ThrowIfNoLinkOnElement(IProductElement context, string path)
        {
            if (string.IsNullOrEmpty(context.TryGetReference(ReferenceKindConstants.SolutionItem)))
            {
                tracer.Verbose(
                    Resources.PathResolver_TraceInvalidParentArtifactLink);

                throw new InvalidOperationException(string.Format(
                                                        CultureInfo.CurrentCulture,
                                                        Resources.PathResolver_ErrorNoArtifactLinkOnParent,
                                                        path,
                                                        context.GetSafeInstanceName()));
            }
        }
Exemple #4
0
        private IItemContainer ResolveReference(IProductElement context, Func <IItemContainer, bool> solutionItemFilter, string path)
        {
            // create a filter function the matches any links that include the tag (if any)
            var tagFilter = new Func <IReference, bool>(x => true);
            var tag       = GetArtifactReferenceTag(path);

            if (!string.IsNullOrEmpty(tag))
            {
                tagFilter = r => r.ContainsTag(tag);
            }

            // filter by tag, and then by solution item constraints
            var references = SolutionArtifactLinkReference.GetResolvedReferences(context, this.UriService, tagFilter)
                             .Where(solutionItemFilter);

            if (references.Count() > 1)
            {
                tracer.Warn(
                    Resources.PathResolver_TraceResolvedMultipleReferences, context.GetSafeInstanceName());
            }

            return(references
                   .FirstOrDefault());
        }