本文整理汇总了C#中IList.ForEach方法的典型用法代码示例。如果您正苦于以下问题:C# IList.ForEach方法的具体用法?C# IList.ForEach怎么用?C# IList.ForEach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IList
的用法示例。
在下文中一共展示了IList.ForEach方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Append
/// <summary>
/// Function to append errors in validation error dictionary.
/// </summary>
/// <param name="errorsDictionary">Errors dictionary</param>
/// <param name="errors">List of errors</param>
public static void Append(this Dictionary<string, string> errorsDictionary, IList<ErrorListItem> errors)
{
if (errors != null)
{
errors.ForEach(item => Append(errorsDictionary, item));
}
}
示例2: PopulateProperties
private void PopulateProperties( GraphicStructure paletteStructure, IList<GraphicStructure> pixelStructures )
{
Palette = new Palette( paletteStructure.Pixels, Palette.ColorDepth._16bit );
List<byte> pix = new List<byte>();
pixelStructures.ForEach( p => pix.AddRange( p.Pixels ) );
Pixels = pix.AsReadOnly();
}
示例3: get_lines
private static string get_lines(IList<FinishedAndRawInventoryCounted> counteds)
{
var retVal = "Dell Part Number Available FG Qty Available RAW Qty\r\n";
counteds.ForEach(
i => retVal += get_line(i) + "\r\n");
return retVal;
}
示例4: FillActiveUserFilesListView
public static void FillActiveUserFilesListView(IList<ActiveUserFile> activeUserFiles, ListView target)
{
target.Items.Clear();
target.Columns.Clear();
target.Columns.Add("File Name");
target.Columns.Add("Reference Computer");
target.Columns.Add("Memory Use");
target.Columns.Add("CPU Use");
target.Columns.Add("Description");
IList<String> images = new List<string>();
images.Add("TrendWinForm.Images.Icons.File_byJesse_48.png");
PopulateListViewImages(images, target);
activeUserFiles.ForEach(auf =>
{
var item = new ListViewItem(auf.ReferenceComputer.ToString());
item.Text = auf.FileName;
item.SubItems.Add(auf.ReferenceComputer.Make + " " + auf.ReferenceComputer.Model);
item.SubItems.Add(auf.MemoryUsage.ToString());
item.SubItems.Add(auf.CpuUsage.ToString());
item.SubItems.Add(auf.Description);
item.ImageIndex = 0;
target.Items.Add(item);
});
}
示例5: GetContryDetailsModel
protected IList<ICountryDetails> GetContryDetailsModel(IList<Country> countries)
{
var contryDetails = new List<ICountryDetails>();
countries.ForEach(c => contryDetails.Add(GetContryDetailsModel(c)));
return contryDetails;
}
示例6: AddBuildings
private void AddBuildings(TreeViewItem projectItem, IList<Web.Models.Building> buildings)
{
buildings.ForEach(b =>
{
var buildingItem = new TreeViewItem() { };
View1.Items.Add(projectItem);
});
}
示例7: CopyValidationErrors
/// <summary>
/// Copies the validation errors.
/// </summary>
/// <param name="modelState">State of the model.</param>
/// <param name="validationErrors">The validation errors.</param>
public static void CopyValidationErrors(this ModelStateDictionary modelState, IList<ValidationError> validationErrors)
{
validationErrors.ForEach(error => modelState.AddModelError(error.Property, /* strValue, */ error.Message));
//string strValue = null;
//if (error.AttemptedValue != null)
// strValue = error.AttemptedValue.ToString();
}
示例8: AskOrBoolReturnHooks
private static bool AskOrBoolReturnHooks(CommandArgs args, IList<Func<CommandArgs, bool>> hooks)
{
bool ret = false;
hooks.ForEach(delegate(Func<CommandArgs, bool> a){
ret |= a(args);
});
return ret;
}
示例9: EncodeNodes
private static IEnumerable<NodeData> EncodeNodes(
IList<ExplorationNode> nodes,
Dictionary<ExplorationEdge, uint> edgeToId)
{
List<NodeData> nodeData = new List<NodeData>();
nodes.ForEach(
(node) => nodeData.Add(new NodeData(node, edgeToId)));
return nodeData.OrderBy((node) => node.NodeId);
}
示例10: Scan
public IList<Token> Scan(IList<Token> tokens, Options options)
{
tokens.ForEach(token => token.Tag(
new ITag[]
{
ScanOrdinal(token, options),
ScanOrdinalDay(token)
}.Where(
x => x != null).ToList()));
return tokens;
}
示例11: BuildGenusTypeDictionary
private IDictionary<GenusTypeDto, PhotoDto> BuildGenusTypeDictionary(IList<GenusTypeDto> dtoList)
{
var dictionary = new Dictionary<GenusTypeDto, PhotoDto>();
dtoList.ForEach(x =>
{
var photo = this.photosRepository.GetSingleForGenusType(x.Id);
dictionary.Add(x, photo == null ? null : DtoFactory.Build(photo));
});
return dictionary;
}
示例12: OrderLine
public OrderLine(Product product, int quantity, IList<Outcome> outcomes):this()
{
Product = product;
Quantity = quantity;
Price = product.Price;
ProductName = product.Name;
Outcomes = outcomes;
outcomes.ForEach(x => x.OrderLine = this);
Profit = Outcomes.Sum(outcome => outcome.Profit);
SummWithDiscount = Outcomes.Sum(outcome => outcome.SummWithDiscount);
}
示例13: ParseResult
public void ParseResult(IList<string> lines)
{
lines.ForEach(l =>
{
if (l.StartsWith("dangling commit "))
{
var commit = new BareCommitResult();
commit.ParseResult(new List<string>() { l.Remove(0, l.LastIndexOf(" ", StringComparison.Ordinal) + 1)});
Commits.Add(commit);
}
});
}
示例14: InteractiveTests
public InteractiveTests()
{
InitializeComponent();
_tests = AllTypes.InCurrentAssembly()
.Where(x => x.IsConcrete() && x.IsAssignableTo<UiTest>())
.Select(x => (UiTest)Activator.CreateInstance(x))
.ToList();
_tests
.ForEach(x => x.Owner = this);
_tests.Select(x => x.Module)
.Distinct()
.ForEach(x => _moduleNames.Add(x));
_modules.DataSource = _moduleNames.ToList() ;
}
示例15: Compress
/// <summary>
/// Compresses the specified file.
/// </summary>
/// <typeparam name="T">Must be <see cref="IStringSectioned"/> and <see cref="ICompressed"/></typeparam>
/// <param name="file">The file to compress.</param>
/// <param name="ignoreSections">A dictionary indicating which entries to not compress, with each key being the section that contains the ignored
/// entries and each item in the value being an entry to ignore</param>
/// <param name="callback">The progress callback.</param>
public static CompressionResult Compress( IList<IList<string>> sections, byte terminator, GenericCharMap charmap, IList<bool> allowedSections )
{
int length = 0;
sections.ForEach( s => length += charmap.StringsToByteArray( s, terminator ).Length );
byte[] result = new byte[length];
int[] lengths = new int[sections.Count];
int pos = 0;
for( int section = 0; section < sections.Count; section++ )
{
int oldPos = pos;
if ( allowedSections == null || allowedSections[section] )
{
CompressSection( charmap.StringsToByteArray( sections[section], terminator ), result, ref pos );
}
else
{
byte[] secResult = charmap.StringsToByteArray( sections[section], terminator );
secResult.CopyTo( result, pos );
pos += secResult.Length;
}
lengths[section] = pos - oldPos;
}
return new CompressionResult( result.Sub( 0, pos - 1 ), lengths );
}