Esempio n. 1
0
 private static void SetFrameworkReferences(IObjectWriter writer, ISet <string> frameworkReferences)
 {
     if (frameworkReferences?.Any() == true)
     {
         writer.WriteNameArray("frameworkReferences", frameworkReferences.OrderBy(e => e));
     }
 }
Esempio n. 2
0
 private static void SetArrayValue(IObjectWriter writer, string name, IEnumerable <string> values)
 {
     if (values != null && values.Any())
     {
         writer.WriteNameArray(name, values);
     }
 }
Esempio n. 3
0
        private static void SetImports(IObjectWriter writer, IList <NuGetFramework> frameworks)
        {
            if (frameworks?.Any() == true)
            {
                var imports = frameworks.Select(framework => framework.GetShortFolderName());

                writer.WriteNameArray("imports", imports);
            }
        }
Esempio n. 4
0
        private static void SetFrameworkArrayToProperty(IObjectWriter writer, IList <NuGetFramework> frameworks, string propertyName)
        {
            if (frameworks?.Any() == true)
            {
                var shortNames = frameworks.Select(framework => framework.GetShortFolderName());

                writer.WriteNameArray(propertyName, shortNames);
            }
        }
Esempio n. 5
0
            public void WriteNameArray(string name, IEnumerable <string> values)
            {
                // if we are writing an empty import array, skip it.
                if (name == "#import" && !values.Any())
                {
                    return;
                }

                innerWriter.WriteNameArray(name, values);
            }
Esempio n. 6
0
        private static void SetDictionaryValues(IObjectWriter writer, string name, IDictionary <string, IEnumerable <string> > values)
        {
            if (values != null && values.Any())
            {
                writer.WriteObjectStart(name);

                var sortedValues = values.OrderBy(pair => pair.Key, StringComparer.Ordinal);

                foreach (var pair in sortedValues)
                {
                    writer.WriteNameArray(pair.Key, pair.Value);
                }

                writer.WriteObjectEnd();
            }
        }
Esempio n. 7
0
        private static void WriteRuntimeDescription(IObjectWriter writer, RuntimeDescription data)
        {
            writer.WriteObjectStart(data.RuntimeIdentifier);

            writer.WriteNameArray("#import", data.InheritedRuntimes);

            var sortedDependencySets = data.RuntimeDependencySets
                                       .OrderBy(pair => pair.Key, StringComparer.Ordinal)
                                       .Select(pair => pair.Value);

            foreach (var set in sortedDependencySets)
            {
                WriteRuntimeDependencySet(writer, set);
            }

            writer.WriteObjectEnd();
        }
Esempio n. 8
0
        private static void WriteCompatibilityProfile(IObjectWriter writer, CompatibilityProfile data)
        {
            writer.WriteObjectStart(data.Name);

            var frameworkGroups = data.RestoreContexts.GroupBy(context => context.Framework);

            foreach (var frameworkGroup in frameworkGroups)
            {
                var name     = frameworkGroup.Key.GetShortFolderName();
                var runtimes = frameworkGroup.ToList();
                if (runtimes.Count == 1)
                {
                    // Write a string
                    writer.WriteNameValue(name, runtimes[0].RuntimeIdentifier);
                }
                else if (runtimes.Count > 0)
                {
                    writer.WriteNameArray(name, runtimes.Select(rt => rt.RuntimeIdentifier));
                }
            }

            writer.WriteObjectEnd();
        }