本文整理汇总了C#中ITaskItem.ForEach方法的典型用法代码示例。如果您正苦于以下问题:C# ITaskItem.ForEach方法的具体用法?C# ITaskItem.ForEach怎么用?C# ITaskItem.ForEach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITaskItem
的用法示例。
在下文中一共展示了ITaskItem.ForEach方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDnnUserControlDictionary
/// <summary>
/// Creates the DNN user control dictionary.
/// </summary>
/// <param name="sourceFiles">The source files.</param>
private void CreateDnnUserControlDictionary(ITaskItem[] sourceFiles)
{
var desktopModuleFolder = string.Format(@"\{0}\", DnnGlobals.DnnDesktopModuleFolder);
var userControlBaseClassPattern = new Regex(@"\s(?i)inherits(?-i)=""[a-zA-Z0-9\.]+""\s", RegexOptions.IgnoreCase);
this.UserControls = new Dictionary<string, string>();
sourceFiles.ForEach(
item =>
{
if (item.ItemSpec.EndsWith(DnnGlobals.UserControlFileExtension, StringComparison.InvariantCultureIgnoreCase))
{
// Only for user controls...
using (var reader = new StreamReader(item.ItemSpec))
{
// TODO: optimize. Only read until found <> or EOF.
var content = reader.ReadToEnd();
var match = userControlBaseClassPattern.Match(content);
if (match.Success)
{
// We know that the match.Value includes a '=' character, because it is part of the Regular Expression.
var baseClass = match.Value.Split('=')
.Last()
.Trim(new[] { ' ', '"' });
var startOfDesktopModuleFolder = item.ItemSpec.IndexOf(desktopModuleFolder);
var relativeUserControlPath = item.ItemSpec.Substring(startOfDesktopModuleFolder + 1) // Add 1 so the first backslash won't be included.
.Replace(@"\", @"/"); // Replace the backslashes by forward slashes in line with relative URIs.
this.UserControls.Add(baseClass, relativeUserControlPath);
}
}
}
});
}