Beispiel #1
0
 public void AddLanguage(string languageCode, PackageAssemblyXmlLanguageDocs docs)
 {
     languages[languageCode.ToLowerInvariant()] = docs;
 }
Beispiel #2
0
        async Task ReadAsync(HttpClient httpClient, string packageUri)
        {
            this.Client = httpClient;
            var entries = await ReadEntriesAsync(httpClient, packageUri);

            TargetFrameworks.Clear();
            Content.Clear();
            Tools.Clear();
            Entry nuspecEntry = null;

            foreach (var e in entries.Where(x => Path.GetFileName(x.FullName) != "_._").OrderBy(x => x.FullName))
            {
                var n       = e.FullName;
                var isBuild = n.StartsWith("build/", StringComparison.InvariantCultureIgnoreCase);
                var isLib   = n.StartsWith("lib/", StringComparison.InvariantCultureIgnoreCase);
                if ((isBuild || isLib) && (n.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase) ||
                                           n.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase) ||
                                           n.EndsWith(".xml", StringComparison.InvariantCultureIgnoreCase)))
                {
                    var    parts = n.Split('/', StringSplitOptions.RemoveEmptyEntries);
                    string tfm;
                    if (parts.Length >= 3)
                    {
                        tfm = Uri.UnescapeDataString(parts[1].Trim().ToLowerInvariant());
                    }
                    else
                    {
                        tfm = "net";
                    }
                    var tf = TargetFrameworks.FirstOrDefault(x => x.Moniker == tfm);
                    if (tf == null)
                    {
                        tf = new PackageTargetFramework(this, httpClient)
                        {
                            Moniker = tfm,
                        };
                        TargetFrameworks.Add(tf);
                    }
                    if (n.EndsWith(".xml", StringComparison.InvariantCultureIgnoreCase))
                    {
                        var docs = new PackageAssemblyXmlLanguageDocs(e);
                        if (string.IsNullOrEmpty(docs.Error))
                        {
                            // System.Console.WriteLine(docs.AssemblyName);
                            if (!tf.AssemblyXmlDocs.TryGetValue(docs.AssemblyName, out var allLanguageDocs))
                            {
                                allLanguageDocs = new PackageAssemblyXmlDocs(docs.AssemblyName);
                                tf.AssemblyXmlDocs[docs.AssemblyName] = allLanguageDocs;
                            }
                            allLanguageDocs.AddLanguage(docs.LanguageCode, docs);
                        }
                    }
                    else if (isBuild)
                    {
                        tf.BuildAssemblies.Add(new PackageAssembly(e, tf));
                    }
                    else
                    {
                        tf.Assemblies.Add(new PackageAssembly(e, tf));
                    }
                }
                else if (n.EndsWith(".nuspec", StringComparison.InvariantCultureIgnoreCase))
                {
                    nuspecEntry = e;
                }
                else if (n.StartsWith("content/", StringComparison.InvariantCultureIgnoreCase))
                {
                    Content.Add(new PackageFile(e));
                }
                else if (n.StartsWith("tools/", StringComparison.InvariantCultureIgnoreCase))
                {
                    Tools.Add(new PackageFile(e));
                }
                else
                {
                    // System.Console.WriteLine(e);
                }
            }
            if (nuspecEntry != null)
            {
                ReadNuspec(nuspecEntry);
            }
            TargetFrameworks.Sort((a, b) => string.Compare(a.Moniker, b.Moniker, StringComparison.Ordinal));
        }