本文整理汇总了C#中JSONArray.AddValue方法的典型用法代码示例。如果您正苦于以下问题:C# JSONArray.AddValue方法的具体用法?C# JSONArray.AddValue怎么用?C# JSONArray.AddValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONArray
的用法示例。
在下文中一共展示了JSONArray.AddValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToJSON
public JSONValue ToJSON()
{
var result = new JSONArray();
foreach (var item in this.Items)
{
result.AddValue(item.ToObject());
}
return result;
}
示例2: ToObject
public JSONObject ToObject()
{
JSONObject result = new JSONObject();
result.AddValue("text", Headline);
result.AddValue("content", Content);
result.AddValue("moduleId", ModuleId);
JSONArray items = new JSONArray();
foreach (var child in Items)
items.AddValue(child.ToObject());
result.AddValue("items", items);
return result;
}
示例3: 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;
}