Beispiel #1
0
        public override void Execute()
        {
            this.ValidateObject();

            tracer.Info(
                Resources.CreateArtifactLinkCommand_TraceInitial, this.CurrentElement.InstanceName);

            foreach (var item in Solution.Traverse().Where(t => !string.IsNullOrEmpty(t.PhysicalPath) && Items.Contains(t.PhysicalPath.ToLowerInvariant())))
            {
                tracer.Info(
                    Resources.CreateArtifactLinkCommand_TraceCreateLink, this.CurrentElement.InstanceName, item.GetLogicalPath());

                SolutionArtifactLinkReference.AddReference(this.CurrentElement, UriService.CreateUri(item))
                .Tag = this.Tag ?? string.Empty;
            }
        }
Beispiel #2
0
        internal void AssociateDroppedSolutionItems(HashSet <string> paths)
        {
            if (paths.Count == 0)
            {
                return;
            }

            var existingUris = new HashSet <string>(SolutionArtifactLinkReference
                                                    .GetReferenceValues(this.CurrentElement)
                                                    .Select(u => u.ToString().ToLowerInvariant()));

            var items = this.Solution.Find(i =>
                                           (i.Kind == ItemKind.Item || i.Kind == ItemKind.Project) &&
                                           paths.Contains(i.PhysicalPath.ToLowerInvariant()));

            foreach (var item in items)
            {
                var uri = UriService.CreateUri(item);
                if (!existingUris.Contains(uri.ToString().ToLowerInvariant()))
                {
                    // add new reference with tag
                    ReferenceKindProvider <SolutionArtifactLinkReference, Uri> .AddReference(CurrentElement, uri).Tag =
                        this.Tag ?? string.Empty;
                }
                else
                {
                    // Update tag on reference (add if not already exist)
                    var reference = ReferenceKindProvider <SolutionArtifactLinkReference, Uri> .GetReference(CurrentElement, uri);

                    if (reference != null)
                    {
                        reference.AddTag(this.Tag);
                    }
                }
            }
        }