本文整理汇总了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;
}
示例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;
}
示例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;
}