本文整理汇总了C#中Jayrock.Json.JsonArray.Add方法的典型用法代码示例。如果您正苦于以下问题:C# JsonArray.Add方法的具体用法?C# JsonArray.Add怎么用?C# JsonArray.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jayrock.Json.JsonArray
的用法示例。
在下文中一共展示了JsonArray.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
{
if (request.UriPath == Url)
{
ThreadStore.UpdateThreadStoreStats();
ThreadStoreStats stats = ThreadStore.StoreStats;
JsonArray ja = new JsonArray();
IEnumerable<string> boards = Program.ValidBoards.Keys;
for (int i = 0, j = boards.Count(); i < j; i++)
{
string boardName = boards.ElementAt(i);
int threadCount = stats[boardName];
if (threadCount > 0)
{
JsonArray inner = new JsonArray();
inner.Add(boardName);
inner.Add(threadCount);
ja.Add(inner);
}
}
WriteJsonResponse(response, ja.ToString());
return true;
}
return false;
}
示例2: AddNullValue
public void AddNullValue()
{
JsonArray a = new JsonArray();
a.Add(null);
Assert.AreEqual(1, a.Count);
Assert.IsNull(a[0]);
}
示例3: AddNullValueViaIList
public void AddNullValueViaIList()
{
IList list = new JsonArray();
list.Add(null);
Assert.AreEqual(1, list.Count);
Assert.IsNull(list[0]);
}
示例4: Process
public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
{
if (request.UriPath.StartsWith(Url))
{
string day_number = request.QueryString[UrlParameters.DayNumber].Value;
int dayNumber = 0;
DateTime day = DateTime.Now;
if (Int32.TryParse(day_number, out dayNumber))
{
day = new DateTime(day.Year, 1, 1);
dayNumber--;
if (!DateTime.IsLeapYear(day.Year) && dayNumber == 365)
{
dayNumber--;
}
day = day.AddDays(dayNumber);
}
var sdata = NetworkUsageCounter.GetDayStats(day);
JsonArray ja = new JsonArray();
for (int i = 0; i < sdata.Length; i++)
{
double t = sdata[i].Value / 1024 / 1024;
JsonArray inner = new JsonArray();
inner.Add(sdata[i].Key);
inner.Add(Math.Round(t, 2, MidpointRounding.AwayFromZero));
ja.Add(inner);
}
WriteJsonResponse(response, ja.ToString());
return true;
}
return false;
}
示例5: ContentsClearedBeforeImporting
public void ContentsClearedBeforeImporting()
{
JsonArray a = new JsonArray();
a.Add(new object());
Assert.AreEqual(1, a.Length);
a.Import(new JsonTextReader(new StringReader("[123]")));
Assert.AreEqual(1, a.Length);
}
示例6: GetString
public override string GetString(IEnumerable<IFreeDocument> datas)
{
var nodeGroup = new JsonArray();
foreach (IFreeDocument data in datas)
{
nodeGroup.Add(GetJsonObject(data));
}
return nodeGroup.ToString();
}
示例7: ImportIsExceptionSafe
public void ImportIsExceptionSafe()
{
JsonArray a = new JsonArray();
object o = new object();
a.Add(o);
try
{
a.Import(new JsonTextReader(new StringReader("[123,456,")));
}
catch (JsonException)
{
}
Assert.AreEqual(1, a.Count);
Assert.AreSame(o, a[0]);
}
示例8: TeacherRecommended
private void TeacherRecommended(HttpContext context)
{
string topStr = context.Request.Params["TopNum"];
int topNum = Common.Globals.SafeInt(topStr, 0);
BLL.UserExp.UsersExp userBll = new BLL.UserExp.UsersExp();
DataSet ds = userBll.GetReTeacher(topNum);
JsonObject json = new JsonObject();
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
JsonArray data = new JsonArray();
data.Add(ds.Tables[0]);
json.Put(TAO_KEY_DATA, data);
json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
}
else
{
json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
}
}
else
{
json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
}
context.Response.Write(json.ToString());
}
示例9: GetPanelsArray
private JsonArray GetPanelsArray()
{
object propertyValue = ControlInfo.Properties.GetPropertyValue("DesignTimeTabs");
if (propertyValue == null || propertyValue.Equals(""))
{
JsonArray panels = new JsonArray();
panels.Add(new JsonObject(new string[] { "id", "selected" }, new string[] { "tabPanel1", "false" }));
return panels;
}
else
{
return JsonConvert.Import(propertyValue as string) as JsonArray;
}
}
示例10: SetFilesItemState
private void SetFilesItemState(string datatype)
{
JsonArray array = new JsonArray();
lock (filesListView)
{
lock (filesListView.Items)
{
foreach (FileListViewItem item in filesListView.SelectedItems)
{
array.Add(item.FileIndex);
}
}
}
DispatchFilesUpdate(datatype, array);
}
示例11: SaveListViewProperties
public void SaveListViewProperties(ListView listView)
{
JsonArray widths = new JsonArray();
JsonArray indexes = new JsonArray();
foreach (ColumnHeader column in listView.Columns)
{
widths.Add(column.Width);
indexes.Add(column.DisplayIndex);
}
LocalSettings settings = Program.Settings;
settings.SetObject(CONFKEYPREFIX_LISTVIEW_WIDTHS + listView.Name, widths.ToString());
settings.SetObject(CONFKEYPREFIX_LISTVIEW_INDEXES + listView.Name, indexes.ToString());
lock (listView)
{
IListViewItemSorter listViewItemSorter = (IListViewItemSorter)listView.ListViewItemSorter;
settings.SetObject(CONFKEYPREFIX_LISTVIEW_SORTINDEX + listView.Name, listViewItemSorter.Order == SortOrder.Descending ? -listViewItemSorter.SortColumn : listViewItemSorter.SortColumn);
}
}
示例12: GetTeachInfo
/// <summary>
/// 根据关键字查询课程信息
/// </summary>
/// <param name="context"></param>
private void GetTeachInfo(HttpContext context)
{
BLL.SysManage.UsersExp ubll = new BLL.SysManage.UsersExp();
string uid = context.Request.Params["uid"];
JsonObject json = new JsonObject();
if (!string.IsNullOrEmpty(uid))
{
List<Maticsoft.Model.UserExp.UsersExp> list = ubll.GetModelList(int.Parse(uid));
if (list.Count > 0)
{
JsonArray data = new JsonArray();
list.ForEach(info => data.Add(
new JsonObject(
new string[] { "UserAvatar", "Tags" },
new object[] { info.UserAvatar, info.Tags }
)));
json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
json.Put(TAO_KEY_DATA, data);
}
}
else
{
json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
}
context.Response.Write(json.ToString());
}
示例13: GetCourseByCateID
/// <summary>
/// 根据分类ID查询课程信息
/// </summary>
/// <param name="context"></param>
private void GetCourseByCateID(HttpContext context)
{
int RowCount = 0;
int PageCount = 0;
string strId = context.Request.Params["cateID"];
string strPi = context.Request.Params["pageIndex"];
int intPi = 0;
if (!int.TryParse(strPi, out intPi))//将字符串页码 转成 整型页码,如果失败,设置页码为1
{
intPi = 1;
}
int intPz = 7;
int OrderType = Maticsoft.Common.Globals.SafeInt(context.Request.Params["SortT"], 0);
int courseType = Maticsoft.Common.Globals.SafeInt(context.Request.Params["CourseType"], 0);
string strTime = context.Request.Params["TimeStr"];
JsonObject json = new JsonObject();
if (!string.IsNullOrEmpty(strId))
{
int CID = Common.Globals.SafeInt(strId, -1);
if (courseType == 1)
{
List<Maticsoft.Model.Tao.SearchCourse> list = coursesBLL.GetListByCateId(out RowCount, out PageCount, CID, intPi, intPz, OrderType, strTime, courseType);
if (list.Count > 0)
{
JsonArray data = new JsonArray();
list.ForEach(info => data.Add(
new JsonObject(
new string[] { "CourseID", "CourseName", "TimeDuration", "Price", "PV", "CreatedUserID", "ImageUrl", "TrueName", "DepartmentID", "NAME", "CategoryId" },
new object[] { info.Courseid, info.Coursename, info.Timeduration, info.Price, info.Pv, info.Createduserid, info.Imageurl, info.TrueName, info.DepartmentId, info.EnterName, info.CategoryId }
)));
json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
json.Put(TAO_KEY_DATA, data);
}
}
else if (courseType == 2)
{
BLL.Tao.OffLineCourse bll = new BLL.Tao.OffLineCourse();
List<Maticsoft.Model.Tao.SearchCourse> Offlist = bll.GetListByCateId(out RowCount, out PageCount, CID, intPi, intPz, OrderType, strTime);
if (Offlist.Count > 0)
{
JsonArray data = new JsonArray();
Offlist.ForEach(info => data.Add(
new JsonObject(
new string[] { "CourseID", "CourseName", "TimeDuration", "Price", "PV", "CreatedUserID", "ImageUrl", "TrueName", "DepartmentID", "NAME", "CategoryId", "BookCount" },
new object[] { info.Courseid, info.Coursename, info.StartTime.ToString("yyyy-MM-dd"), info.Price, info.Pv, info.Createduserid, info.Imageurl, info.TrueName, info.DepartmentId, info.EnterName, info.CategoryId,info.BookCount }
)));
json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
json.Put(TAO_KEY_DATA, data);
}
}
else
{
List<Maticsoft.Model.Tao.SearchCourse> list = coursesBLL.GetListByCateId(out RowCount, out PageCount, CID, intPi, intPz, OrderType, strTime, courseType);
if (list.Count > 0)
{
JsonArray data = new JsonArray();
list.ForEach(info => data.Add(
new JsonObject(
new string[] { "CourseID", "CourseName", "TimeDuration", "Price", "PV", "CreatedUserID", "ImageUrl", "TrueName", "DepartmentID", "NAME", "CategoryId" },
new object[] { info.Courseid, info.Coursename, info.Timeduration, info.Price, info.Pv, info.Createduserid, info.Imageurl, info.TrueName, info.DepartmentId, info.EnterName, info.CategoryId }
)));
json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
json.Put(TAO_KEY_DATA, data);
}
}
json.Put("ROWCOUNT", RowCount);
json.Put("PAGECOUNT", PageCount);
}
else
{
json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
}
context.Response.Write(json.ToString());
}
示例14: RelateTeacherCourse
private void RelateTeacherCourse(HttpContext context)
{
int RowCount = 0;
int PageCount = 0;
string strId = context.Request.Params["CateId"];
string strPi = context.Request.Params["pageIndex"];
int intPi = 0;
if (!int.TryParse(strPi, out intPi))//将字符串页码 转成 整型页码,如果失败,设置页码为1
{
intPi = 1;
}
int intPz = Maticsoft.Common.Globals.SafeInt(context.Request.Params["pageSize"], 1);
JsonObject json = new JsonObject();
if (!string.IsNullOrEmpty(strId))
{
List<Maticsoft.Model.Tao.SearchCourse> list = coursesBLL.GetListByTeacherID(out RowCount, out PageCount, int.Parse(strId), intPi, intPz);
if (list.Count > 0)
{
JsonArray data = new JsonArray();
list.ForEach(info => data.Add(
new JsonObject(
new string[] { "CourseID", "CourseName", "TimeDuration", "Price", "PV", "CreatedUserID", "ImageUrl", "TrueName", "DepartmentID", "NAME", "CategoryId" },
new object[] { info.Courseid, info.Coursename, info.Timeduration, info.Price, info.Pv, info.Createduserid, info.Imageurl, info.TrueName, info.DepartmentId, info.EnterName, info.CategoryId }
)));
json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
json.Put(TAO_KEY_DATA, data);
}
json.Put("ROWCOUNT", RowCount);
json.Put("PAGECOUNT", PageCount);
}
else
{
json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
}
context.Response.Write(json.ToString());
}
示例15: GetCourseByKEY
/// <summary>
/// 根据关键字查询课程信息
/// </summary>
/// <param name="context"></param>
private void GetCourseByKEY(HttpContext context)
{
int RowCount = 0;
int PageCount = 0;
string strIKey = context.Request.Params["StrKey"];
string strPi = context.Request.Params["pageIndex"];
int intPi = 0;
if (!int.TryParse(strPi, out intPi))//将字符串页码 转成 整型页码,如果失败,设置页码为1
{
intPi = 1;
}
int intPz = 7;
int OrderType = Maticsoft.Common.Globals.SafeInt(context.Request.Params["SortT"], 0);
int courseType = Maticsoft.Common.Globals.SafeInt(context.Request.Params["CourseType"], 0);
string strTime = context.Request.Params["TimeStr"];
int? deptid = null;
if (context.Request.Params["DPT"] != "null")
{
deptid = Maticsoft.Common.Globals.SafeInt(context.Request.Params["DPT"], -1);
}
JsonObject json = new JsonObject();
if (!string.IsNullOrEmpty(strIKey))
{
List<Maticsoft.Model.Tao.SearchCourse> list = coursesBLL.GetListByKEY(out RowCount, out PageCount, strIKey, intPi, intPz, OrderType, strTime, courseType, deptid);
if (list.Count > 0)
{
JsonArray data = new JsonArray();
list.ForEach(info => data.Add(
new JsonObject(
new string[] { "CourseID", "CourseName", "TimeDuration", "Price", "PV", "CreatedUserID", "ImageUrl", "TrueName", "DepartmentID", "NAME", "CategoryId" },
new object[] { info.Courseid, info.Coursename, info.Timeduration, info.Price, info.Pv, info.Createduserid, info.Imageurl, info.TrueName, info.DepartmentId, info.EnterName, info.CategoryId }
)));
json.Put(TAO_KEY_STATUS, TAO_STATUS_SUCCESS);
json.Put(TAO_KEY_DATA, data);
}
json.Put("ROWCOUNT", RowCount);
json.Put("PAGECOUNT", PageCount);
}
else
{
json.Put(TAO_KEY_STATUS, TAO_STATUS_FAILED);
}
context.Response.Write(json.ToString());
}