本文整理汇总了C#中System.Web.Script.Serialization.JavaScriptSerializer.ForEach方法的典型用法代码示例。如果您正苦于以下问题:C# Script.Serialization.JavaScriptSerializer.ForEach方法的具体用法?C# Script.Serialization.JavaScriptSerializer.ForEach怎么用?C# Script.Serialization.JavaScriptSerializer.ForEach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Script.Serialization.JavaScriptSerializer
的用法示例。
在下文中一共展示了Script.Serialization.JavaScriptSerializer.ForEach方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetReportOutputConfiguration
private string GetReportOutputConfiguration(int reportId, int userId, IEnumerable<ReportColumn> columnsSwapHistory, IEnumerable<ReportColumn> columnsWidthHistory)
{
var userReport = GetUserReport(reportId, userId);
var columnsConfig = new JavaScriptSerializer().Deserialize<List<ReportColumn>>(userReport.OutputConfiguration);
columnsConfig.ForEach(reportConfig =>
{
var lastIndex = columnsSwapHistory.LastOrDefault(columnSwap => columnSwap.Name == reportConfig.Name);
//There was an index change so an offset has to be performed
if (!lastIndex.IsNull())
{
//Right offset
if (lastIndex.Index > reportConfig.Index)
{
foreach (var column in columnsConfig.Where(colum => colum.Index <= lastIndex.Index && colum.Index > reportConfig.Index))
column.Index--;
}
else
{
//Left offset
foreach (var column in columnsConfig.Where(colum => colum.Index >= lastIndex.Index && colum.Index < reportConfig.Index))
column.Index++;
}
reportConfig.Index = lastIndex.Index;
}
var lastWidth = columnsWidthHistory.LastOrDefault(columnWidth => columnWidth.Name == reportConfig.Name);
if (!lastWidth.IsNull())
reportConfig.Width = lastWidth.Width;
});
var jsonResult = new JsonSerializer().Serialize(columnsConfig);
return jsonResult;
}