本文整理汇总了C#中Collection.ToDictionary方法的典型用法代码示例。如果您正苦于以下问题:C# Collection.ToDictionary方法的具体用法?C# Collection.ToDictionary怎么用?C# Collection.ToDictionary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collection
的用法示例。
在下文中一共展示了Collection.ToDictionary方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PromptForChoice
public override int PromptForChoice(string caption, string message, Collection<ChoiceDescription> choices,
int defaultChoice)
{
if (Context.Job == null)
{
throw new NotImplementedException();
}
var parameters =
new Hashtable(choices.ToDictionary(p => "btn_" + choices.IndexOf(p),
p => WebUtil.SafeEncode(p.Label.Replace("&", ""))))
{
{"te", message},
{"cp", caption},
{"dc", defaultChoice.ToString(CultureInfo.InvariantCulture)}
};
Context.Site = Factory.GetSite(Context.Job.Options.SiteName);
var lineWidth = choices.Count*80 + 140;
var strLineWidth = lineWidth/8;
var lineHeight = 0;
foreach (var line in message.Split('\n'))
{
lineHeight += 1 + line.Length/strLineWidth;
}
lineHeight = Math.Max(lineHeight*21 + 130,150);
var dialogResult = JobContext.ShowModalDialog(parameters, "ConfirmChoice",
lineWidth.ToString(CultureInfo.InvariantCulture), lineHeight.ToString(CultureInfo.InvariantCulture));
if (!string.IsNullOrEmpty(dialogResult))
{
return int.Parse(dialogResult.Substring(4));
}
return -1;
}
示例2: PromptForChoice
public override int PromptForChoice(string caption, string message, Collection<ChoiceDescription> choices,
int defaultChoice)
{
if (Context.Job == null)
{
throw new NotImplementedException();
}
var parameters =
new Hashtable(choices.ToDictionary(p => "btn_" + choices.IndexOf(p),
p => WebUtil.SafeEncode(p.Label.Replace("&", ""))))
{
{"te", message},
{"cp", caption},
{"dc", defaultChoice.ToString(CultureInfo.InvariantCulture)}
};
Context.Site = Factory.GetSite(Context.Job.Options.SiteName);
string dialogResult = JobContext.ShowModalDialog(parameters, "ConfirmChoice", "800", "300");
if (!string.IsNullOrEmpty(dialogResult))
{
return int.Parse(dialogResult.Substring(4));
}
return -1;
}
示例3: CellsToColumn
public Dictionary<string, ICell> CellsToColumn(Collection<ICell> cells)
{
return cells.ToDictionary(cell => Headers[cell.RowNum - 1], cell => cell);
}