コード例 #1
0
        /// <summary>
        /// Determines whether the specified <paramref name="assembly"/> references the provided <paramref name="package"/>.
        /// </summary>
        /// <param name="assembly"><see cref="Assembly"/> to check if contains a reference to the provided <paramref name="package"/>.</param>
        /// <param name="package"><see cref="PackageReference"/> of Durian package to check for.</param>
        /// <exception cref="ArgumentNullException"><paramref name="package"/> is <see langword="null"/>. -or- <paramref name="assembly"/> is <see langword="null"/>.</exception>
        public static bool HasReference(this Assembly assembly, PackageReference package)
        {
            if (assembly is null)
            {
                throw new ArgumentNullException(nameof(assembly));
            }

            if (package is null)
            {
                throw new ArgumentNullException(nameof(package));
            }

            return(HasReference_Internal(assembly, package.EnumValue));
        }
コード例 #2
0
        /// <summary>
        /// Converts a collection of <see cref="DurianPackage"/>s into an array of <see cref="PackageReference"/>s.
        /// </summary>
        /// <param name="packages">A collection of <see cref="DurianPackage"/>s to convert.</param>
        /// <exception cref="ArgumentNullException"><paramref name="packages"/> is <see langword="null"/>.</exception>
        /// <exception cref="InvalidOperationException">Unknown <see cref="DurianPackage"/> value detected.</exception>
        public static PackageReference[] ToReferences(IEnumerable <DurianPackage> packages)
        {
            if (packages is null)
            {
                throw new ArgumentNullException(nameof(packages));
            }

            DurianPackage[] array = packages.ToArray();

            if (array.Length == 0)
            {
                return(Array.Empty <PackageReference>());
            }

            PackageReference[] references = new PackageReference[array.Length];

            for (int i = 0; i < references.Length; i++)
            {
                references[i] = new PackageReference(array[i]);
            }

            return(references);
        }