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


C# JsonArray.AddRange方法代码示例

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


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

示例1: TrySerializeNonPrimitiveObject

		public override bool TrySerializeNonPrimitiveObject(object input, out object output)
		{
			if (input is Exception)
			{
				var e = input as Exception;
				var exceptionsJson = this.FlattenExceptions(e).ToList();
				var array = new JsonArray(exceptionsJson.Count);
				array.AddRange(exceptionsJson);
				output = array;
				return true;

			}
			return base.TrySerializeNonPrimitiveObject(input, out output);
		}
开发者ID:niemyjski,项目名称:elasticsearch-net,代码行数:14,代码来源:ElasticsearchNetJsonStrategy.cs

示例2: GET

        public override ActionResult GET(System.Net.HttpListenerContext context, string httpActionPath)
        {
            JsonArray files = new JsonArray();
            files.AddRange(
                FileRepository.GetFiles()
                .Select(f => (JsonValue)new JsonObject {
                    { "Name", f.Name },
                    { "Size", f.Length },
                    { "Type", f.Extension },
                    { "Url", "/files/" + f.Name }
                })
            );

            var result = new ActionResult();
            result.Data = System.Text.Encoding.UTF8.GetBytes(files.ToString());
            result.ContentType = "application/json";
            return result;
        }
开发者ID:narent,项目名称:AirFolio,代码行数:18,代码来源:FilesAction.cs

示例3: GetActiveEventIDsByOwner

        /// <summary>
        /// Queries Facebook for all active events.
        /// </summary>
        /// <returns>Dictionary containing the Event ID as the key, and last Updated Time as the value.</returns>
        public static IDictionary<Int64, DateTime> GetActiveEventIDsByOwner(List<Owner> owners)
        {
            // Combine all owner IDs who do not need tokens
            HashSet<Int64> noTokenIds = new HashSet<Int64>(owners.Where(o => String.IsNullOrEmpty(o.AccessToken ?? null)).Select(o => o.OwnerID).ToList());
            //owners.RemoveAll(o => noTokenIds.Contains(o.OwnerID));

            IDictionary<string, string> ownerIds = owners.ToDictionary(o => o.OwnerID.ToString(), o => o.AccessToken ?? null);
            //ownerIds.Add(string.Join(",", noTokenIds.ToArray()), string.Empty);
            JsonArray fqlRaveResults = new JsonArray();
            foreach (string ownerId in ownerIds.Keys)
            {
              // Query Facebook for all active events
              _fb.AccessToken = String.IsNullOrEmpty(ownerIds[ownerId]) ? _GenericAccessToken : ownerIds[ownerId];
              try
              {
                // TODO: This is a temp workaround for this FB platform bug: https://developers.facebook.com/bugs/501594683237232
                //dynamic fqlJsonResult = _fb.Get("fql", new { q = String.Format("SELECT eid, update_time FROM event WHERE creator IN ({0}) AND eid IN (SELECT eid FROM event_member WHERE uid IN({0})) AND (end_time >= now() OR (end_time = 'null' AND start_time >= now()))", ownerId) });
                dynamic fqlJsonResult = _fb.Get("fql", new { q = String.Format("SELECT eid, update_time, creator FROM event WHERE eid IN (SELECT eid FROM event_member WHERE uid = {0}) AND (end_time >= now() OR (end_time = 'null' AND start_time >= now()))", ownerId) });
                fqlRaveResults.AddRange(fqlJsonResult.data);
              }
              catch (FacebookOAuthException)
              {
                  // TODO: Re-enable error notifications
                  //MailHelper.SendErrorMessage(String.Concat("An owner (ID: ", ownerId, ") has an invalid access token. I was unable to query their Events from Facebook."));
              }
            }

            // Convert results to dictionary and filter duplicates
            IList<FacebookEventMeta> hotfixResults = new List<FacebookEventMeta>();
            foreach (dynamic rid in fqlRaveResults)
            {
              hotfixResults.Add(new FacebookEventMeta { EID = rid.eid, Creator = rid.creator, UpdateTime = DateTimeConvertor.FromUnixTime(rid.update_time) });
            }
            hotfixResults = hotfixResults.Distinct().ToList();
            hotfixResults = hotfixResults.Where(r => owners.Any(o => o.OwnerID == r.Creator)).ToList();
            IDictionary<Int64, DateTime> results = hotfixResults.ToDictionary(r => r.EID, r => r.UpdateTime);

            return results;
        }
开发者ID:AndrewCraswell,项目名称:rave-radar,代码行数:43,代码来源:FQLToObjectsHelper.cs

示例4: SaveClassInfo

        void SaveClassInfo(DocComment dc, CorePlus.Json.JsonObject obj)
        {
            string fullName = dc.FullName;
            obj.Add("fullName",fullName);
            obj.Add("source", dc.Source);

            if(dc.Source != null) {
                obj.Add("sourceFile", "data/source/" + dc.Source + ".html#" + fullName.Replace('.', '-'));
            }

            SortedList<string, DocComment> members = new SortedList<string,DocComment>();
            SortedList<string, DocComment> statics = new SortedList<string, DocComment>();

            if (dc.MemberType == "class" && dc.Variant.Members != null) {
                GetMembersAndCopyToTmpList(dc.Variant.Members, members, statics);
            }

            // 如果有成员。生成成员字段。
            if(dc.Variant.Count > 0) {
                GetMembersAndCopyToTmpList(dc.Variant, members, statics);
            }

            if (_project.DefaultExtends != null && dc.MemberType == "class") {

                DocComment dc2 ;

                if (_data.DocComments.TryGetValue(_project.DefaultExtends, out dc2) && dc2.Variant != null) {

                    GetMembersAndCopyToTmpList(dc2.Variant, members, statics);
                }

            }

            DocComment e;
            if(dc.Extends != null && _data.DocComments.TryGetValue(dc.Extends, out e)) {
                string extends = dc.Extends;
                if (e.Variant.Members != null) {
                    GetMembersAndCopyToTmpList(e.Variant.Members, members, statics);
                }

                JsonArray baseClasses = new JsonArray();

                obj["baseClasses"] = baseClasses;
                while (extends != null && _data.DocComments.TryGetValue(extends, out e)) {
                    baseClasses.Insert(0, extends);

                    extends = e.Extends;
                }
            }

            if(dc.Implements != null) {
                foreach(string im in dc.Implements) {
                    if(_data.DocComments.TryGetValue(im, out e))
                        GetMembersAndCopyToTmpList(e.Variant, members, members);
                }
            }

            string memberOf = dc.FullName;
            SaveTmpList(members, obj, memberOf, false);
            SaveTmpList(statics, obj, memberOf, true);

            if(_extendsInfo.ContainsKey(fullName)) {

                JsonArray subClasses = new JsonArray();

                obj["subClasses"] = subClasses;
                var list = _extendsInfo[fullName];
                list.Sort();
                subClasses.AddRange(list);
            }

            foreach(string key in dc){
                AddSingle(obj, key, dc[key]);
            }
        }
开发者ID:xuld,项目名称:DocPlus,代码行数:75,代码来源:DocGenerator.cs


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