Ejemplo n.º 1
0
        private static void WriteCompatibilityProfile(JObject jObject, CompatibilityProfile data)
        {
            var value = new JObject();

            jObject[data.Name] = value;
            foreach (var frameworkGroup in data.RestoreContexts.GroupBy(f => f.Framework))
            {
                var name     = frameworkGroup.Key.GetShortFolderName();
                var runtimes = frameworkGroup.ToList();
                if (runtimes.Count == 1)
                {
                    // Write a string
                    value[name] = runtimes[0].RuntimeIdentifier;
                }
                else if (runtimes.Count > 0)
                {
                    var array = new JArray();
                    value[name] = array;
                    foreach (var runtime in runtimes)
                    {
                        array.Add(runtime.RuntimeIdentifier);
                    }
                }
            }
        }
Ejemplo n.º 2
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();
        }