本文整理汇总了C#中JSONObject.AddValue方法的典型用法代码示例。如果您正苦于以下问题:C# JSONObject.AddValue方法的具体用法?C# JSONObject.AddValue怎么用?C# JSONObject.AddValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONObject
的用法示例。
在下文中一共展示了JSONObject.AddValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseMailTo
public static JSONObject ParseMailTo(string mailTo)
{
var result = new JSONObject();
var parts = mailTo.Replace("mailto:", "").Split('#');
result.AddValue("address", parts[0]);
result.AddValue("subject", parts.Length > 1 ? parts[1] : "");
return result;
}
示例2: ParseUrl
public static JSONObject ParseUrl(string href)
{
var result = new JSONObject();
var parts = href.Split('#');
result.AddValue("anchor", parts.Length > 1 ? parts[1] : "");
result.AddValue("query", parts[0].Contains("?") ? parts[0].Substring(parts[0].IndexOf("?")+1) : "");
return result;
}
示例3: CreateNewFolder
public static JSONObject CreateNewFolder(string providerName, string referenceId, string parentId, string name)
{
var provider = ProviderHelper.GetTreeNodeProvider(providerName, referenceId);
var documentType = DocumentType.GetByAlias("GridModuleFolder");
var treeNode = provider.CreateNode(name, parentId, documentType.Id.ToString());
var result = new JSONObject();
result.AddValue("parentId", parentId);
result.AddValue("addedId", treeNode.Id);
return result;
}
示例4: SubscribeToList
public bool SubscribeToList(string listId, string email, System.Collections.Specialized.NameValueCollection userDetails)
{
var parameters = new JSONObject();
parameters.AddValue("apikey", _configuration.ApiKey);
parameters.AddValue("id", listId);
parameters.AddValue("email_address", email);
var result = CallMethod("listSubscribe", parameters);
return true;
}
示例5: GetValues
public static JSONObject GetValues(string referenceId, string itemId)
{
var data = GetAccordionData(referenceId);
var item = data.GetItem(itemId);
JSONObject result = new JSONObject();
result.AddValue("headline", item.Headline);
result.AddValue("content", item.Content);
result.AddValue("isRoot", item.Id == data.Id);
if (item.Id == data.Id)
{
result.AddValue("canMoveUp", false);
result.AddValue("canMoveDown", false);
}
else
{
var parent = item.Parent;
var index = item.Parent.Items.IndexOf(item);
result.AddValue("canMoveUp", index > 0);
result.AddValue("canMoveDown", index < parent.Items.Count-1);
}
if (!string.IsNullOrEmpty(item.ModuleId))
{
var module = CmsService.Instance.GetItem<Entity>(new Id(item.ModuleId));
if (module != null)
{
result.AddValue("moduleId", item.ModuleId);
result.AddValue("moduleName", module.EntityName);
}
}
return result;
}
示例6: AddAccordionSibling
public static JSONObject AddAccordionSibling(string itemId, string referenceId)
{
var data = GetAccordionData(referenceId);
var item = data.GetItem(itemId);
var parent = item.Parent;
var newItem = data.AddItem(parent.Id, "New Accordion Item", "", "");
var result = new JSONObject();
result.AddValue("addedId", newItem.Id);
result.AddValue("parentId", parent.Id);
return result;
}
示例7: AddImageGalleryChild
public static JSONObject AddImageGalleryChild(string itemId, string referenceId)
{
var item = new ImageGalleryItem("New Image", Id.Null, "", "");
var data = GetImageGalleryData(referenceId);
var before = data.Items.Where(i => i.Id == itemId).FirstOrDefault();
if (before == null)
data.Items.Add(item);
else
data.Items.Insert(data.Items.IndexOf(before)+1, item);
var result = new JSONObject();
result.AddValue("rootId", HttpContext.Current.Request.QueryString["itemId"]);
result.AddValue("addedId", item.Id.ToString());
return result;
}
示例8: GetLists
public IEnumerable<MailingList> GetLists()
{
var parameters = new JSONObject();
parameters.AddValue("apikey", _configuration.ApiKey);
var result = CallMethod("lists", parameters);
var count = (int) result["total"];
if (count == 0)
return new MailingList[0];
var data = (JSONArray) result["data"];
return data.Values.Cast<JSONObject>().Select(o => new MailingList((string)o["id"], HttpUtility.HtmlDecode((string)o["name"]))).ToArray();
}
示例9: OnPreRender
protected override void OnPreRender(EventArgs e)
{
var options = new JSONObject();
options.AddValue("mode", "exact");
if (Width.HasValue)
options.AddValue("width", Width.Value.Value.ToString());
options.AddValue("elements", _textbox.ClientID);
options.AddValue("theme", "advanced");
options.AddValue("plugins", GetPlugins());
options.AddValue("theme_advanced_buttons1", GetButtons1());
options.AddValue("theme_advanced_buttons2", GetButtons2());
options.AddValue("theme_advanced_buttons3", GetButtons3());
//options.AddValue("theme_advanced_buttons4", GetButtons4());
options.AddValue("theme_advanced_toolbar_location", "top");
options.AddValue("theme_advanced_toolbar_align", "left");
options.AddValue("theme_advanced_statusbar_location", "bottom");
//options.AddValue("theme_advanced_resizing", true);
options.AddValue("template_external_list_url", "lists/template_list.js");
options.AddValue("external_link_list_url", "lists/link_list.js");
options.AddValue("external_image_list_url", "lists/image_list.js");
options.AddValue("media_external_list_url", "lists/media_list.js");
//options.AddValue("style_formats", JSONArray.Parse("[{title : 'Bold text', inline : 'b'},{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},{title : 'Example 1', inline : 'span', classes : 'example1'},{title : 'Example 2', inline : 'span', classes : 'example2'},{title : 'Table styles'},{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}]"));
options.AddValue("template_replace_values", JSONObject.Parse("{ username : \"Some User\", staffid : \"991234\" }"));
if (!string.IsNullOrEmpty(HiddenId))
{
var setup = new JSONDelegate("ed");
setup.Lines.Add("ed.onInit.add(function(ed, evt) {");
setup.Lines.Add("initializeEditorValue(ed, doc, '" + HiddenId + "');");
setup.Lines.Add("var dom = ed.dom;");
setup.Lines.Add("var doc = ed.getDoc();");
setup.Lines.Add("tinymce.dom.Event.add(doc, 'blur', function(e) {");
setup.Lines.Add("updateEditorValue(ed, doc,'" + HiddenId + "');");
setup.Lines.Add("});");
setup.Lines.Add("});");
options.AddValue("setup", setup);
}
var script = new StringBuilder();
script.AppendLine("tinyMCE.init(" + options.ToString() + ");");
if (RegisterFormBind)
script.AppendLine("$(theForm).bind(\"onSave\", function() { $(\"#" + _textbox.ClientID + "\").val(tinyMCE.get('" + _textbox.ClientID + "').save()); });");
Page.ClientScript.RegisterStartupScript(Page.GetType(), "tinyMCEditor" + _textbox.ClientID, script.ToString(), true);
base.OnPreRender(e);
}
示例10: 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();
}
示例11: GetListsTmp
public string GetListsTmp()
{
var parameters = new JSONObject();
parameters.AddValue("apikey", _configuration.ApiKey);
return CallMethod("lists", parameters).ToString();
}
示例12: 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;
}
示例13: 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;
}
示例14: ToObject
public JSONObject ToObject()
{
var result = new JSONObject();
result.AddValue("name", Text);
result.AddValue("headline", Headline);
result.AddValue("content", Content);
result.AddValue("imageId", ImageId);
return result;
}
示例15: OnPreRender
protected override void OnPreRender(EventArgs e)
{
var options = new JSONObject();
options.AddValue("mode", "exact");
if (Width.HasValue)
options.AddValue("width", Width.Value.Value.ToString());
else
options.AddValue("width", 800);
options.AddValue("elements", _textbox.ClientID);
options.AddValue("convert_urls", false);
options.AddValue("theme", "advanced");
options.AddValue("plugins", GetPlugins());
var styleOptions = GetStyleOptions();
if (!string.IsNullOrEmpty(styleOptions))
options.AddValue("theme_advanced_styles", styleOptions);
options.AddValue("theme_advanced_buttons1", GetButtons1());
options.AddValue("theme_advanced_buttons2", GetButtons2());
options.AddValue("theme_advanced_buttons3", GetButtons3());
options.AddValue("theme_advanced_toolbar_location", "top");
options.AddValue("theme_advanced_toolbar_align", "left");
options.AddValue("theme_advanced_statusbar_location", "bottom");
options.AddValue("template_external_list_url", "lists/template_list.js");
options.AddValue("external_link_list_url", "lists/link_list.js");
options.AddValue("external_image_list_url", "lists/image_list.js");
options.AddValue("media_external_list_url", "lists/media_list.js");
if (StyleSheets != null && StyleSheets.Any())
options.AddValue("content_css", StyleSheets.ToSeparatedString(","));
options.AddValue("verify_html", false);
options.AddValue("valid_elements", "*[*]");
//options.AddValue("valid_elements", GetValidElements());
options.AddValue("invalid_elements", GetInvalidElements());
//options.AddValue("template_replace_values", JSONObject.Parse("{ username : \"Some User\", staffid : \"991234\" }"));
var setup = new JSONDelegate("ed");
if (!string.IsNullOrEmpty(HiddenId))
{
setup.Lines.Add("ed.onInit.add(function(ed, evt) {");
setup.Lines.Add("initializeEditorValue(ed, doc, '" + HiddenId + "');");
setup.Lines.Add("var dom = ed.dom;");
setup.Lines.Add("var doc = ed.getDoc();");
setup.Lines.Add("tinymce.dom.Event.add(doc, 'blur', function(e) {");
setup.Lines.Add("updateEditorValue(ed, doc,'" + HiddenId + "');");
setup.Lines.Add("});");
setup.Lines.Add("});");
}
setup.Lines.Add("ed.onNodeChange.addToTop(function(ed, cm, n) {");
setup.Lines.Add("var macroElement = ed.dom.getParent(ed.selection.getStart(), 'div.umbMacroHolder');");
setup.Lines.Add("if (macroElement) {");
setup.Lines.Add("ed.selection.select(macroElement);");
setup.Lines.Add("var currentSelection = ed.selection.getStart();");
setup.Lines.Add("if (tinymce.isIE) {");
setup.Lines.Add("if (!ed.dom.hasClass(currentSelection, 'umbMacroHolder')) {");
setup.Lines.Add("while (!ed.dom.hasClass(currentSelection, 'umbMacroHolder') && currentSelection.parentNode) {");
setup.Lines.Add("currentSelection = currentSelection.parentNode;");
setup.Lines.Add("}");
setup.Lines.Add("ed.selection.select(currentSelection);");
setup.Lines.Add("}");
setup.Lines.Add("}");
setup.Lines.Add("cm.setActive('umbracomacro', ed.dom.hasClass(currentSelection, 'umbMacroHolder') || ed.dom.hasClass(macroElement, 'umbMacroHolder'));");
setup.Lines.Add("}");
setup.Lines.Add("});");
options.AddValue("setup", setup);
var script = new StringBuilder();
script.AppendLine("tinyMCE.init(" + options.ToString() + ");");
if (RegisterFormBind)
script.AppendLine("$(theForm).bind(\"onSave\", function() { $(\"#" + _textbox.ClientID + "\").val(tinyMCE.get('" + _textbox.ClientID + "').save()); });");
Page.ClientScript.RegisterStartupScript(Page.GetType(), "tinyMCEditor" + _textbox.ClientID, script.ToString(), true);
base.OnPreRender(e);
}