本文整理匯總了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;
}