当前位置: 首页>>代码示例>>C#>>正文


C# JObject.GetJArray方法代码示例

本文整理汇总了C#中Newtonsoft.Json.Linq.JObject.GetJArray方法的典型用法代码示例。如果您正苦于以下问题:C# JObject.GetJArray方法的具体用法?C# JObject.GetJArray怎么用?C# JObject.GetJArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Newtonsoft.Json.Linq.JObject的用法示例。


在下文中一共展示了JObject.GetJArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateXDocument

        private static XDocument CreateXDocument(JObject catalogItem)
        {
            var document = new XDocument();
            var package = new XElement("metadata");
            var metadata = new XElement("metadata");

            // ID
            var id = new XElement("id", (string)catalogItem["id"]);

            // dependencies
            var dependencies = new XElement("dependencies");
            foreach (var group in catalogItem.GetJArray("dependencyGroups"))
            {
                var groupElement = new XElement("group");
                groupElement.SetAttributeValue("targetFramework", (string)group["targetFramework"]);
                foreach (var dependency in group.GetJArray("dependencies"))
                {
                    var dependencyElement = new XElement("dependency");
                    dependencyElement.SetAttributeValue("id", (string)dependency["id"]);
                    dependencyElement.SetAttributeValue("version", (string)dependency["range"]);
                    groupElement.Add(dependencyElement);
                }

                dependencies.Add(groupElement);
            }

            // framework assemblies
            var frameworkAssemblies = new XElement("frameworkAssemblies");
            foreach (var group in catalogItem.GetJArray("frameworkAssemblyGroup"))
            {
                var element = new XElement("frameworkAssembly");
                element.SetAttributeValue("targetFramework", (string)group["targetFramework"]);
                frameworkAssemblies.Add(element);
            }

            metadata.Add(id);
            metadata.Add(dependencies);
            metadata.Add(frameworkAssemblies);
            package.Add(metadata);
            document.Add(package);

            return document;
        }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:43,代码来源:CatalogNuspecReader.cs

示例2: CreateActionGroup

 private ActionGroup CreateActionGroup(JObject jActionGroup, ServiceConfiguration configuration)
 {
     var actionGroup = ActionGroup.CreateSilently(jActionGroup.Get("Name"), configuration, _navigationService);
     actionGroup.Actions.AddRange(jActionGroup.GetJArray("Actions").Select(j => CreateAction(j, configuration)));
     return actionGroup;
 }
开发者ID:johanclasson,项目名称:Rester,代码行数:6,代码来源:Serializer.cs

示例3: CreateServiceConfiguration

 private ServiceConfiguration CreateServiceConfiguration(JObject jConfig)
 {
     var configuration = ServiceConfiguration.CreateSilently(
         jConfig.Get("Name"), jConfig.Get("BaseUri"),
         _navigationService, _invokerFactory);
     var actionGroups = jConfig.GetJArray("ActionGroups").Select(j => CreateActionGroup(j, configuration));
     configuration.ActionGroups.AddRange(actionGroups);
     return configuration;
 }
开发者ID:johanclasson,项目名称:Rester,代码行数:9,代码来源:Serializer.cs


注:本文中的Newtonsoft.Json.Linq.JObject.GetJArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。