本文整理汇总了C#中JSONArray.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# JSONArray.AddRange方法的具体用法?C# JSONArray.AddRange怎么用?C# JSONArray.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONArray
的用法示例。
在下文中一共展示了JSONArray.AddRange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleChange
public static JSONObject HandleChange(JSONArray request)
{
var provider = new LinqIt.UmbracoCustomFieldTypes.UmbracoTreeModuleProvider(HttpContext.Current.Request.QueryString["itemId"]);
var placeholderData = provider.GetPlaceholderData();
var layout = provider.GetLayout().Rows.SelectMany(r => r.Cells).ToArray();
var result = layout.ToDictionary(cell => cell.Key, cell => new GridPlaceholderData(cell.Key, cell.ColumnSpan));
var response = new JSONObject();
var messages = new JSONArray();
response.AddValue("messages", messages);
foreach (JSONObject replacement in request.Values)
{
var from = (string) replacement["from"];
var id = (string) replacement["id"];
var to = (string) replacement["to"];
var message = new JSONObject();
message.AddValue("ph", from);
message.AddValue("id", id);
if (string.IsNullOrEmpty(to))
{
message.AddValue("type", "alert");
message.AddValue("text", _removedMessage);
}
else
{
var oldItem = placeholderData[from].Items.Where(i => i.Id == id).FirstOrDefault();
var newItem = provider.GetItem(id);
newItem.ColumnSpan = oldItem.ColumnSpan;
var cell = result[to];
if (cell.Items.Where(i => i.Id == newItem.Id).Any())
{
message.AddValue("type", "alert");
message.AddValue("text", _duplicateMessage);
}
else
{
if (cell.Span < newItem.ColumnSpan)
{
newItem.ColumnSpan = provider.GetItemColumnOptions(id).Where(o => o <= cell.Span).Max();
message.AddValue("type", "info");
message.AddValue("text", string.Format(_resizedMessage, newItem.ColumnSpan));
}
else
{
message.AddValue("type", "ok");
}
cell.AddItem(newItem);
}
}
messages.AddValue(message);
}
response.AddValue("hiddenId", HttpContext.Current.Request.QueryString["hiddenId"]);
var values = new JSONArray();
values.AddRange(result.Values.Select(v => v.ToJSON()).ToArray());
response.AddValue("value", values.ToString());
return response;
}
示例2: ToString
public override string ToString()
{
var result = new JSONObject();
if (!string.IsNullOrEmpty(Query))
result.AddValue("q", Query);
if (!string.IsNullOrEmpty(TemplateName))
result.AddValue("t", TemplateName);
if (From.HasValue)
result.AddValue("df", From.Value);
if (To.HasValue)
result.AddValue("dt", To.Value);
if (CategorizationIds != null && CategorizationIds.Any())
{
var cids = new JSONArray();
cids.AddRange(CategorizationIds.Select(id => id.IntValue));
result.AddValue("cids", cids);
}
return result.ToString();
}