Esempio n. 1
0
        private static List <PackageReferenceSet> ReadReferenceSets(XElement referencesElement)
        {
            if (!referencesElement.HasElements)
            {
                return(new List <PackageReferenceSet>(0));
            }

            if (referencesElement.ElementsNoNamespace("group").Any() &&
                referencesElement.ElementsNoNamespace("reference").Any())
            {
                // TODO: Resources
                throw new InvalidDataException("NuGetResources.Manifest_ReferencesHasMixedElements");
            }

            var references = ReadReference(referencesElement, throwIfEmpty: false);

            if (references.Count > 0)
            {
                // old format, <reference> is direct child of <references>
                var referenceSet = new PackageReferenceSet(references);
                return(new List <PackageReferenceSet> {
                    referenceSet
                });
            }
            else
            {
                var groups = referencesElement.ElementsNoNamespace("group");
                return((from element in groups
                        select new PackageReferenceSet(element.GetOptionalAttributeValue("targetFramework")?.Trim(),
                                                       ReadReference(element, throwIfEmpty: true))).ToList());
            }
        }
Esempio n. 2
0
 private void FilterAssemblyReferences(List <IPackageAssemblyReference> assemblyReferences, ICollection <PackageReferenceSet> packageAssemblyReferences)
 {
     if ((packageAssemblyReferences != null) && (packageAssemblyReferences.Count > 0))
     {
         PackageReferenceSet packageReferences = this.Project.GetCompatibleItemsCore <PackageReferenceSet>(packageAssemblyReferences).FirstOrDefault <PackageReferenceSet>();
         if (packageReferences != null)
         {
             assemblyReferences.RemoveAll(assembly => !packageReferences.References.Contains <string>(assembly.Name, StringComparer.OrdinalIgnoreCase));
         }
     }
 }
Esempio n. 3
0
        private static List <ManifestReference> CreateReferences(PackageReferenceSet referenceSet)
        {
            if (referenceSet.References == null)
            {
                return(new List <ManifestReference>());
            }

            return((from reference in referenceSet.References
                    select new ManifestReference {
                File = reference.SafeTrim()
            }).ToList());
        }
Esempio n. 4
0
        private IList <IPackageAssemblyReference> GetFilteredAssembliesToDelete(IPackage package)
        {
            List <IPackageAssemblyReference> list = this.GetCompatibleInstalledItemsForPackage <IPackageAssemblyReference>(package.Id, package.AssemblyReferences, NetPortableProfileTable.Default).ToList <IPackageAssemblyReference>();

            if (list.Count != 0)
            {
                PackageReferenceSet packageReferences = this.GetCompatibleInstalledItemsForPackage <PackageReferenceSet>(package.Id, package.PackageAssemblyReferences, NetPortableProfileTable.Default).FirstOrDefault <PackageReferenceSet>();
                if (packageReferences != null)
                {
                    list.RemoveAll(p => !packageReferences.References.Contains <string>(p.Name, StringComparer.OrdinalIgnoreCase));
                }
            }
            return(list);
        }
Esempio n. 5
0
        private static List <PackageReferenceSet> ReadReferenceSets(XElement referencesElement)
        {
            if (!referencesElement.HasElements)
            {
                return(new List <PackageReferenceSet>(0));
            }

            if (referencesElement.ElementsNoNamespace("group").Any() &&
                referencesElement.ElementsNoNamespace("reference").Any())
            {
                throw new InvalidDataException(NuGetResources.Manifest_ReferencesHasMixedElements);
            }

            var references = ReadReference(referencesElement, throwIfEmpty: false);

            if (references.Any())
            {
                // old format, <reference> is direct child of <references>
                var referenceSet = new PackageReferenceSet(references);
                return(new List <PackageReferenceSet> {
                    referenceSet
                });
            }
            else
            {
                var groups = referencesElement.ElementsNoNamespace("group");
                return(groups.Select(element =>
                {
                    var framework = element.GetOptionalAttributeValue("targetFramework")?.Trim();
                    if (framework != null)
                    {
                        return new PackageReferenceSet(VersionUtility.ParseFrameworkName(framework), ReadReference(element, throwIfEmpty: true));
                    }
                    else
                    {
                        return new PackageReferenceSet(ReadReference(element, throwIfEmpty: true));
                    }
                }).ToList());
            }
        }
Esempio n. 6
0
        private static List<ManifestReference> CreateReferences(PackageReferenceSet referenceSet)
        {
            if (referenceSet.References == null)
            {
                return new List<ManifestReference>();
            }

            return (from reference in referenceSet.References
                    select new ManifestReference { File = reference.SafeTrim() }).ToList();
        }
Esempio n. 7
0
		public void AddPackageReferences (params string[] names)
		{
			var frameworkName = new FrameworkName (".NET Framework, Version=4.0");
			var packageReferenceSet = new PackageReferenceSet (frameworkName, names);
			FakePackageAssemblyReferences.Add (packageReferenceSet);
		}
 public EditablePackageReferenceSet(PackageReferenceSet packageReferenceSet)
 {
     _targetFramework = packageReferenceSet.TargetFramework;
     _references = new ObservableCollection<string>(packageReferenceSet.References);
 }
Esempio n. 9
0
        private static List<PackageReferenceSet> ReadReferenceSets(XElement referencesElement)
        {
            if (!referencesElement.HasElements)
            {
                return new List<PackageReferenceSet>(0);
            }

            if (referencesElement.ElementsNoNamespace("group").Any() &&
                referencesElement.ElementsNoNamespace("reference").Any())
            {
                throw new InvalidDataException(NuGetResources.Manifest_ReferencesHasMixedElements);
            }

            var references = ReadReference(referencesElement, throwIfEmpty: false);
            if (references.Any())
            {
                // old format, <reference> is direct child of <references>
                var referenceSet = new PackageReferenceSet(references);
                return new List<PackageReferenceSet> { referenceSet };
            }
            else
            {
                var groups = referencesElement.ElementsNoNamespace("group");
                return groups.Select(element =>
                {
                    var framework = element.GetOptionalAttributeValue("targetFramework")?.Trim();
                    if (framework != null)
                    {
                        return new PackageReferenceSet(VersionUtility.ParseFrameworkName(framework), ReadReference(element, throwIfEmpty: true));
                    }
                    else
                    {
                        return new PackageReferenceSet(ReadReference(element, throwIfEmpty: true));
                    }
                }).ToList();
            }
        }
Esempio n. 10
0
 public AzurePackageReferenceSet(PackageReferenceSet referenceSet)
 {
     References = referenceSet.References.ToList();
     FrameWorkName = referenceSet.TargetFramework.ToString();
 }
Esempio n. 11
0
 private static List <ManifestReference> CreateReferences(PackageReferenceSet referenceSet) =>
 ((referenceSet.References != null) ? Enumerable.Select <string, ManifestReference>(referenceSet.References, delegate(string reference) {
     ManifestReference reference1 = new ManifestReference();
     reference1.File = reference.SafeTrim();
     return(reference1);
 }).ToList <ManifestReference>() : new List <ManifestReference>());
Esempio n. 12
0
        private static List<PackageReferenceSet> ReadReferenceSets(XElement referencesElement)
        {
            if (!referencesElement.HasElements)
            {
                return new List<PackageReferenceSet>(0);
            }

            if (referencesElement.ElementsNoNamespace("group").Any() &&
                referencesElement.ElementsNoNamespace("reference").Any())
            {
                // TODO: Resources
                throw new InvalidDataException("NuGetResources.Manifest_ReferencesHasMixedElements");
            }

            var references = ReadReference(referencesElement, throwIfEmpty: false);
            if (references.Count > 0)
            {
                // old format, <reference> is direct child of <references>
                var referenceSet = new PackageReferenceSet(references);
                return new List<PackageReferenceSet> { referenceSet };
            }
            else
            {
                var groups = referencesElement.ElementsNoNamespace("group");
                return (from element in groups
                        select new PackageReferenceSet(element.GetOptionalAttributeValue("targetFramework")?.Trim(),
                            ReadReference(element, throwIfEmpty: true))).ToList();
            }
        }