當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。