本文整理汇总了C#中System.Windows.Documents.List.ToJSONString方法的典型用法代码示例。如果您正苦于以下问题:C# List.ToJSONString方法的具体用法?C# List.ToJSONString怎么用?C# List.ToJSONString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.List
的用法示例。
在下文中一共展示了List.ToJSONString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SyncTasks
public void SyncTasks(string tasklistId
, Action<RestResponse, object> successCallback
, Action<Exception> failCallback
, object userState)
{
List<ChangeLog> changeLogs = this._changeLogRepository.GetAllChangeLog(tasklistId);
List<Dictionary<string, string>> changeLogsArray = new List<Dictionary<string, string>>();
foreach (var changeLog in changeLogs)
{
Dictionary<string, string> dict = new Dictionary<string, string>();
dict.Add("Type", changeLog.ChangeType);
dict.Add("ID", changeLog.DataId);
dict.Add("Name", changeLog.Name);
dict.Add("Value", changeLog.Value);
changeLogsArray.Add(dict);
}
List<TaskIdx> taskIdxs = this._taskIdxRepository.GetAllTaskIdx(tasklistId);
List<Dictionary<string, string>> taskIdxsArray = new List<Dictionary<string, string>>();
foreach(var taskIdx in taskIdxs)
{
Dictionary<string, string> dict = new Dictionary<string,string>();
dict.Add("By", taskIdx.By);
dict.Add("Key", taskIdx.Key);
dict.Add("Name", taskIdx.Name);
JArray indexesArray = null;
if(string.IsNullOrEmpty(taskIdx.Indexes))
{
indexesArray = new JArray();
}
else
{
indexesArray = (JArray)taskIdx.Indexes.ToJSONObject();
}
dict.Add("Indexs", indexesArray.ToJSONString());
taskIdxsArray.Add(dict);
}
string changeLogsJson = changeLogsArray.ToJSONString();
//TODO:暂不处理排序功能
string taskIdxsJson = "[]";
Console.WriteLine("changeLogsJson: " + changeLogsJson);
Console.WriteLine("taskIdxsJson: " + taskIdxsJson);
Dictionary<string, string> postDict = new Dictionary<string,string>();
postDict.Add("tasklistId", tasklistId);
postDict.Add("changes", changeLogsJson);
postDict.Add("by", "ByPriority");
postDict.Add("sorts", taskIdxsJson);
this.UploadString(Constant.TASK_SYNC_URL, postDict, successCallback, failCallback, userState);
}