Beispiel #1
0
        public void AddOrUpdate(string bstrName, string bstrVersion, Array pbstrMetadataElements, Array pbstrMetadataValues)
        {
            var matches = PackageReferenceNodes.Where(node => string.Equals(node.Name, bstrName, StringComparison.InvariantCultureIgnoreCase));

            if (matches.Count() > 0)
            {
                XSharpPackageReferenceNode currentPackage = matches.First();
                currentPackage.ItemNode.Item.SetMetadataValue("Version", bstrVersion);
                for (int j = 0; j < pbstrMetadataElements.Length; j++)
                {
                    currentPackage.ItemNode.SetMetadata((string)pbstrMetadataElements.GetValue(j), (string)pbstrMetadataValues.GetValue(j));
                }
                base.ProjectMgr.SetProjectFileDirty(value: true);
                currentPackage.ReDraw(UIHierarchyElement.Caption);
                ReDraw(UIHierarchyElement.Caption);
            }
            else
            {
                XSharpPackageReferenceNode packageReference = CreatePackageReferenceNode(bstrName);
                packageReference.ItemNode.Item.SetMetadataValue("Version", bstrVersion);
                for (int i = 0; i < pbstrMetadataElements.Length; i++)
                {
                    packageReference.ItemNode.SetMetadata((string)pbstrMetadataElements.GetValue(i), (string)pbstrMetadataValues.GetValue(i));
                }
                PackageReferenceNodes.Add(packageReference);
                AddChild(packageReference);
            }
        }
Beispiel #2
0
 internal virtual void LoadReferencesFromBuildProject(XSharpProjectNode buildProject)
 {
     foreach (var item in base.ProjectMgr.BuildProject.GetItems(ProjectFileConstants.PackageReference))
     {
         var           element       = new ProjectElement(base.ProjectMgr, item, false);
         var           referenceNode = new XSharpPackageReferenceNode(ProjectMgr, element);
         bool          found         = false;
         HierarchyNode i             = base.FirstChild;
         while (i != null && !found)
         {
             if (string.Compare(i.Caption, referenceNode.Caption, StringComparison.OrdinalIgnoreCase) == 0)
             {
                 found = true;
             }
             i = i.NextSibling;
         }
         if (!found)
         {
             AddChild(referenceNode);
             PackageReferenceNodes.Add(referenceNode);
         }
     }
 }