當前位置: 首頁>>代碼示例>>C#>>正文


C# Linq.JArray類代碼示例

本文整理匯總了C#中Newtonsoft.Json.Linq.JArray的典型用法代碼示例。如果您正苦於以下問題:C# JArray類的具體用法?C# JArray怎麽用?C# JArray使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JArray類屬於Newtonsoft.Json.Linq命名空間,在下文中一共展示了JArray類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ItemListStatic

 public ItemListStatic(JObject basicO,
     JObject dataO,
     JArray groupsA,
     JArray treeA,
     string type,
     string version,
     JObject originalObject)
 {
     data = new Dictionary<string, ItemStatic>();
     groups = new List<GroupStatic>();
     tree = new List<ItemTreeStatic>();
     if (basicO != null)
     {
         basic = HelperMethods.LoadBasicDataStatic(basicO);
     }
     if (dataO != null)
     {
         LoadData(dataO.ToString());
     }
     if (groupsA != null)
     {
         LoadGroups(groupsA);
     }
     if (treeA != null)
     {
         LoadTree(treeA);
     }
     this.type = type;
     this.version = version;
     this.originalObject = originalObject;
 }
開發者ID:mattregul,項目名稱:CreepScore,代碼行數:31,代碼來源:ItemListStatic.cs

示例2: CreateEDDNMessage

        public JObject CreateEDDNMessage(JournalFSDJump journal)
        {
            if (!journal.HasCoordinate)
                return null;

            JObject msg = new JObject();

            msg["header"] = Header();
            msg["$schemaRef"] = "http://schemas.elite-markets.net/eddn/journal/1/test";

            JObject message = new JObject();

            message["StarSystem"] = journal.StarSystem;
            message["Government"] = journal.Government;
            message["timestamp"] = journal.EventTimeUTC.ToString("yyyy-MM-ddTHH:mm:ssZ");
            message["Faction"] = journal.Faction;
            message["Allegiance"] = journal.Allegiance;
            message["StarPos"] = new JArray(new float[] { journal.StarPos.X, journal.StarPos.Y, journal.StarPos.Z });
            message["Security"] = journal.Security;
            message["event"] = journal.EventTypeStr;
            message["Economy"] = journal.Economy;

            msg["message"] = message;
            return msg;
        }
開發者ID:amatos,項目名稱:EDDiscovery,代碼行數:25,代碼來源:EDDNClass.cs

示例3: AfterSeleniumTestScenario

        public static void AfterSeleniumTestScenario()
        {
            var time = DateTime.UtcNow;

            var currentFeature = (JObject) FeatureContext.Current["currentFeature"];
            var scenarios = (JArray) currentFeature["scenarios"];
            var scenario = new JObject();
            scenario["title"] = ScenarioContext.Current.ScenarioInfo.Title;
            scenario["startTime"] = FeatureContext.Current["time"].ToString();
            scenario["endTime"] = time.ToString();
            scenario["tags"] = new JArray(ScenarioContext.Current.ScenarioInfo.Tags);

            var err = ScenarioContext.Current.TestError;
            if (err != null)
            {
                var error = new JObject();
                error["message"] = ScenarioContext.Current.TestError.Message;
                error["stackTrace"] = ScenarioContext.Current.TestError.StackTrace;
                scenario["error"] = error;
                scenario["status"] = "error";
            }
            else {
                scenario["status"] = "ok";
            }
            scenarios.Add(scenario);
        }
開發者ID:agentmilindu,項目名稱:CodeSpec,代碼行數:26,代碼來源:FeatureBase.cs

示例4: Get

        public IHttpActionResult Get(string name)
        {
            var json = string.Empty;
            var account = CloudStorageAccount.Parse(Config.Get("DeepStorage.OutputConnectionString"));
            var blobClient = account.CreateCloudBlobClient();
            var container = blobClient.GetContainerReference(Config.Get("DeepStorage.HdpContainerName"));

            var prefix = string.Format("{0}.json/part-r-", name);
            var matchingBlobs = container.ListBlobs(prefix, true);
            foreach (var part in matchingBlobs.OfType<CloudBlockBlob>())
            {
                json += part.DownloadText() + Environment.NewLine;
            }

            var outputArray = new JArray();
            foreach (var line in json.Split(new[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries))
            {
                dynamic raw = JObject.Parse(line);
                var formatted = new JArray();
                formatted.Add((string)raw.eventName);
                formatted.Add((long)raw.count);
                outputArray.Add(formatted);
            }

            return Ok(outputArray);
        }
開發者ID:smartpcr,項目名稱:bigdata2,代碼行數:26,代碼來源:QueryOutputController.cs

示例5: AddToSelf

    public void AddToSelf()
    {
      JArray a = new JArray();
      a.Add(a);

      Assert.IsFalse(ReferenceEquals(a[0], a));
    }
開發者ID:nagyist,項目名稱:Newtonsoft.Json,代碼行數:7,代碼來源:JArrayTests.cs

示例6: WriteJson

        /// <summary>
        ///     Writes the JSON representation of the object.
        /// </summary>
        /// <param name="writer">The <see cref="T:Newtonsoft.Json.JsonWriter" /> to write to.</param>
        /// <param name="value">The value.</param>
        /// <param name="serializer">The calling serializer.</param>
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var coordinateElements = value as List<IPosition>;
            if (coordinateElements != null && coordinateElements.Count > 0)
            {
                var coordinateArray = new JArray();

                foreach (var position in coordinateElements)
                {
                    // TODO: position types should expose a double[] coordinates property that can be used to write values 
                    var coordinates = (GeographicPosition)position;
                    var coordinateElement = new JArray(coordinates.Longitude, coordinates.Latitude);
                    if (coordinates.Altitude.HasValue)
                    {
                        coordinateElement = new JArray(coordinates.Longitude, coordinates.Latitude, coordinates.Altitude);
                    }

                    coordinateArray.Add(coordinateElement);
                }

                serializer.Serialize(writer, coordinateArray);
            }
            else
            {
                serializer.Serialize(writer, value);
            }
        }
開發者ID:tobiashoeft,項目名稱:GeoJSON.Net,代碼行數:33,代碼來源:LineStringConverter.cs

示例7: GetPropertyEditors

 /// <summary>
 /// Parse the property editors from the json array
 /// </summary>
 /// <param name="jsonEditors"></param>
 /// <returns></returns>
 internal static IEnumerable<PropertyEditor> GetPropertyEditors(JArray jsonEditors)
 {
     return JsonConvert.DeserializeObject<IEnumerable<PropertyEditor>>(
         jsonEditors.ToString(), 
         new PropertyEditorConverter(),
         new PreValueFieldConverter());
 }
開發者ID:phaniarveti,項目名稱:Experiments,代碼行數:12,代碼來源:ManifestParser.cs

示例8: Diff

 public static JArray Diff(JArray source, JArray target, out bool changed, bool nullOnRemoved = false)
 {
     changed = source.Count != target.Count;
     var diffs = new JToken[target.Count];
     var commonLen = Math.Min(diffs.Length, source.Count);
     for (int i = 0; i < commonLen; i++)
     {
         if (target[i].Type == JTokenType.Object && source[i].Type == JTokenType.Object)
         {
             var subchanged = false;
             diffs[i] = Diff((JObject)source[i], (JObject)target[i], out subchanged, nullOnRemoved);
             if (subchanged) changed = true;
         }
         else if (target[i].Type == JTokenType.Array && source[i].Type == JTokenType.Array)
         {
             var subchanged = false;
             diffs[i] = Diff((JArray)source[i], (JArray)target[i], out subchanged, nullOnRemoved);
             if (subchanged) changed = true;
         }
         else
         {
             diffs[i] = target[i];
             if (!JToken.DeepEquals(source[i], target[i]))
                 changed = true;
         }
     }
     for (int i = commonLen; i < diffs.Length; i++)
     {
         diffs[i] = target[i];
         changed = true;
     }
     return new JArray(diffs);
 }
開發者ID:holajan,項目名稱:dotvvm,代碼行數:33,代碼來源:JsonUtils.cs

示例9: LoadMemberList

 /// <summary>
 /// Loads member list
 /// </summary>
 /// <param name="a">json list of members</param>
 void LoadMemberList(JArray a)
 {
     for (int i = 0; i < a.Count; i++)
     {
         memberList.Add(new TeamMemberInfo((long)a[i]["inviteDate"], (long?)a[i]["joinDate"], (long)a[i]["playerId"], (string)a[i]["status"]));
     }
 }
開發者ID:mattregul,項目名稱:CreepScore,代碼行數:11,代碼來源:Roster.cs

示例10: Button_Click

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                dynamic jsonConfig = new JObject();

                var sizeX = int.Parse(SizeXBox.Text);
                jsonConfig.sizeX = sizeX;
                var sizeY = int.Parse(SizeYBox.Text);
                jsonConfig.sizeY = sizeY;

                var markerIds = new JArray();

                var startId = int.Parse(MarkerIdsBox.Text);
                for (int i = 0; i < sizeX * sizeY; i++)
                {
                    markerIds.Add(startId + i);
                }

                jsonConfig.markerIds = markerIds;
                jsonConfig.imgFilename = ImgFilenameBox.Text;
                jsonConfig.configFilename = ConfigFilenameBox.Text;
                jsonConfig.dictionaryName = ArucoDictionaries.SelectedItem as string;
                jsonConfig.pixelSize = int.Parse(PixelSizeBox.Text);
                jsonConfig.interMarkerDistance = float.Parse(InterMarkerDistanceBox.Text);

                ImageProcessing.GenerateMarkerMap(jsonConfig.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
        }
開發者ID:SebiH,項目名稱:BachelorProject,代碼行數:34,代碼來源:MarkerMapGenerator.xaml.cs

示例11: AnalyzeScores

        public string AnalyzeScores(string localizationCode, string messages)
        {
            JsonSerializer serializer = new JsonSerializer();
            TextReader reader = new StringReader(messages);
            JArray jArray = (JArray)serializer.Deserialize(reader, typeof(JArray));

            JArray scoreResults = new JArray();

            for (int index = 0; index < jArray.Count; index++ )
            {
                JToken entry = jArray[index];
                IMessage message = new Message
                {
                     Content = new StringBuilder( entry["text"].ToString()),
                     Metadata = new StringBuilder(entry.ToString())
                };

                double score =  this.AnalyzeScore(localizationCode, message);

                entry["Score"] = score;

                scoreResults.Add(entry);
            }

            TextWriter writer = new StringWriter();

            serializer.Serialize(writer, scoreResults);

            string mergedJsonResult = writer.ToString();

            return mergedJsonResult;
        }
開發者ID:evelasco85,項目名稱:MEQS,代碼行數:32,代碼來源:ExecutionEngine.cs

示例12: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            if (context.Session["Authentication"] == null)
                throw new Exception("Ошибка обновления");

            int ShopId = Convert.ToInt32(context.Session["ShopId"]);
            int ArticleId = Convert.ToInt32(context.Request["ArticleId"]);

            var dsStatistic = new dsStatistic();
            (new DataSets.dsStatisticTableAdapters.taSalesHistory()).Fill
                (dsStatistic.tbSalesHistory, ShopId, ArticleId);

            var JHistory = new JArray();
            foreach (dsStatistic.tbSalesHistoryRow rw in dsStatistic.tbSalesHistory)
                JHistory.Add(new JObject(
                    new JProperty("Дата_продажи",rw.Дата_продажи),
                    new JProperty("Номер_чека", rw.Номер_чека),
                    new JProperty("Количество", rw.Количество),
                    new JProperty("ПрИнфо", rw.ПрИнфо),
                    new JProperty("Инфо", rw.Инфо)
                    ));

            var JObject = new JObject(
                new JProperty("Код_артикула", ArticleId),
                new JProperty("История", JHistory));

            context.Response.ContentType = "application/json";
            context.Response.Write(JObject.ToString());
        }
開發者ID:PeletonSoft,項目名稱:WebProjects,代碼行數:29,代碼來源:Content.ashx.cs

示例13: GetProductIDs

        public DocumentSearchResponse GetProductIDs(JArray relatedItems)
        {
            // Execute search to find all the related products
            try
            {
                SearchParameters sp = new SearchParameters()
                {
                    SearchMode = SearchMode.Any,
                    // Limit results
                    Select = new List<String>() {"product_id","brand_name","product_name","srp","net_weight","recyclable_package",
                        "low_fat","units_per_case","product_subcategory","product_category","product_department","url", "recommendations"},
                };

                // Filter based on the product ID's
                string productIdFilter = null;
                foreach (var item in relatedItems)
                {
                    productIdFilter += "product_id eq '" + item.ToString() + "' or ";
                }
                productIdFilter = productIdFilter.Substring(0, productIdFilter.Length - 4);
                sp.Filter = productIdFilter;

                return _indexClient.Documents.Search("*", sp);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error querying index: {0}\r\n", ex.Message.ToString());
            }
            return null;
        }
開發者ID:HeidiSteen,項目名稱:AzureSearchDemos,代碼行數:30,代碼來源:Search.cs

示例14: Prep

 public static List<SysObj> Prep(JArray list)
 {
     SysObj sys = null;
     var setting = new JsonSerializerSettings();
     setting.NullValueHandling = NullValueHandling.Ignore;
     List<SysObj> systems = new List<SysObj>();
     List<SysObj> result = new List<SysObj>();
     for (int cnt = 0; cnt < list.Count; cnt++)
     {
         sys = JsonConvert.DeserializeObject<SysObj>(list[cnt].ToString(), setting);
         if (string.IsNullOrEmpty(sys.security))
             sys.security = "None";
         if (string.IsNullOrEmpty(sys.power))
             sys.power = "None";
         if (string.IsNullOrEmpty(sys.primary_economy))
             sys.primary_economy = "None";
         if (string.IsNullOrEmpty(sys.simbad_ref))
             sys.simbad_ref = "";
         if (string.IsNullOrEmpty(sys.power_state))
             sys.power_state = "None";
         if (string.IsNullOrEmpty(sys.state))
             sys.state = "None";
         if (string.IsNullOrEmpty(sys.allegiance))
             sys.allegiance = "None";
         if (string.IsNullOrEmpty(sys.government))
             sys.government = "None";
         if (string.IsNullOrEmpty(sys.faction))
             sys.faction = "None";
         if (sys.needs_permit.Equals(null))
             sys.needs_permit = 0;
         systems.Add(sys);
     }
     return systems;
 }
開發者ID:urmamasllama,項目名稱:EDAdvancedSearch,代碼行數:34,代碼來源:EDS.cs

示例15: PlayerStatsSummaryList

 public PlayerStatsSummaryList(JArray playerStatSummariesA, long summonerId, CreepScore.Season season)
 {
     playerStatSummaries = new List<PlayerStatsSummary>();
     LoadPlayerStatSummaries(playerStatSummariesA);
     this.summonerId = summonerId;
     this.season = season;
 }
開發者ID:mattregul,項目名稱:CreepScore,代碼行數:7,代碼來源:PlayerStatsSummaryList.cs


注:本文中的Newtonsoft.Json.Linq.JArray類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。