static ImmutableDictionary <string, AssetsFileTargetLibrary> ParseLibraries(LockFileTarget lockFileTarget)
            {
                ImmutableDictionary <string, AssetsFileTargetLibrary> .Builder builder = ImmutableDictionary.CreateBuilder <string, AssetsFileTargetLibrary>(StringComparer.Ordinal);

                foreach (LockFileTargetLibrary lockFileLibrary in lockFileTarget.Libraries)
                {
                    if (AssetsFileTargetLibrary.TryCreate(lockFileLibrary, out AssetsFileTargetLibrary? library))
                    {
                        builder.Add(library.Name, library);
                    }
                }

                return(builder.ToImmutable());
            }
Exemplo n.º 2
0
        public static bool TryCreate(LockFileTargetLibrary lockFileLibrary, [NotNullWhen(returnValue: true)] out AssetsFileTargetLibrary?library)
        {
            AssetsFileLibraryType type;

            if (lockFileLibrary.Type == "package")
            {
                type = AssetsFileLibraryType.Package;
            }
            else if (lockFileLibrary.Type == "project")
            {
                type = AssetsFileLibraryType.Project;
            }
            else
            {
                library = null;
                return(false);
            }

            library = new AssetsFileTargetLibrary(lockFileLibrary, type);
            return(true);
        }