本文整理汇总了C#中Lookup.PopulateWithItems方法的典型用法代码示例。如果您正苦于以下问题:C# Lookup.PopulateWithItems方法的具体用法?C# Lookup.PopulateWithItems怎么用?C# Lookup.PopulateWithItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lookup
的用法示例。
在下文中一共展示了Lookup.PopulateWithItems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StringMetadataTable
/// <summary>
/// Creates a set of complicated item metadata and properties, and items to exercise
/// the Expander class. The data here contains escaped characters, metadata that
/// references properties, properties that reference items, and other complex scenarios.
/// </summary>
/// <param name="pg"></param>
/// <param name="primaryItemsByName"></param>
/// <param name="secondaryItemsByName"></param>
/// <param name="itemMetadata"></param>
private void CreateComplexPropertiesItemsMetadata
(
out ReadOnlyLookup readOnlyLookup,
out StringMetadataTable itemMetadata
)
{
ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance();
Dictionary<string, string> itemMetadataTable = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
itemMetadataTable["Culture"] = "abc%253bdef;$(Gee_Aych_Ayee)";
itemMetadataTable["Language"] = "english";
itemMetadata = new StringMetadataTable(itemMetadataTable);
PropertyDictionary<ProjectPropertyInstance> pg = new PropertyDictionary<ProjectPropertyInstance>();
pg.Set(ProjectPropertyInstance.Create("Gee_Aych_Ayee", "ghi"));
pg.Set(ProjectPropertyInstance.Create("OutputPath", @"\jk ; l\mno%253bpqr\stu"));
pg.Set(ProjectPropertyInstance.Create("TargetPath", "@(IntermediateAssembly->'%(RelativeDir)')"));
List<ProjectItemInstance> intermediateAssemblyItemGroup = new List<ProjectItemInstance>();
ProjectItemInstance i1 = new ProjectItemInstance(project, "IntermediateAssembly", @"subdir1\engine.dll", project.FullPath);
intermediateAssemblyItemGroup.Add(i1);
i1.SetMetadata("aaa", "111");
ProjectItemInstance i2 = new ProjectItemInstance(project, "IntermediateAssembly", @"subdir2\tasks.dll", project.FullPath);
intermediateAssemblyItemGroup.Add(i2);
i2.SetMetadata("bbb", "222");
List<ProjectItemInstance> contentItemGroup = new List<ProjectItemInstance>();
ProjectItemInstance i3 = new ProjectItemInstance(project, "Content", "splash.bmp", project.FullPath);
contentItemGroup.Add(i3);
i3.SetMetadata("ccc", "333");
List<ProjectItemInstance> resourceItemGroup = new List<ProjectItemInstance>();
ProjectItemInstance i4 = new ProjectItemInstance(project, "Resource", "string$(p).resx", project.FullPath);
resourceItemGroup.Add(i4);
i4.SetMetadata("ddd", "444");
ProjectItemInstance i5 = new ProjectItemInstance(project, "Resource", "dialogs%253b.resx", project.FullPath);
resourceItemGroup.Add(i5);
i5.SetMetadata("eee", "555");
List<ProjectItemInstance> contentItemGroup2 = new List<ProjectItemInstance>();
ProjectItemInstance i6 = new ProjectItemInstance(project, "Content", "about.bmp", project.FullPath);
contentItemGroup2.Add(i6);
i6.SetMetadata("fff", "666");
ItemDictionary<ProjectItemInstance> secondaryItemsByName = new ItemDictionary<ProjectItemInstance>();
secondaryItemsByName.ImportItems(resourceItemGroup);
secondaryItemsByName.ImportItems(contentItemGroup2);
Lookup lookup = new Lookup(secondaryItemsByName, pg, null);
// Add primary items
lookup.EnterScope("x");
lookup.PopulateWithItems("IntermediateAssembly", intermediateAssemblyItemGroup);
lookup.PopulateWithItems("Content", contentItemGroup);
readOnlyLookup = new ReadOnlyLookup(lookup);
}
示例2: foreach
/// <summary>
/// Creates an instance of this class using the given bucket data.
/// </summary>
/// <param name="itemNames">Item types being batched on: null indicates no batching is occurring</param>
/// <param name="itemMetadata">Hashtable of item metadata values: null indicates no batching is occurring</param>
internal ItemBucket
(
ICollection<string> itemNames,
Dictionary<string, string> metadata,
Lookup lookup,
int bucketSequenceNumber
)
{
ErrorUtilities.VerifyThrow(lookup != null, "Need lookup.");
// Create our own lookup just for this bucket
_lookup = lookup.Clone();
// Push down the items, so that item changes in this batch are not visible to parallel batches
_lookupEntry = _lookup.EnterScope("ItemBucket()");
// Add empty item groups for each of the item names, so that (unless items are added to this bucket) there are
// no item types visible in this bucket among the item types being batched on
if (itemNames != null)
{
foreach (string name in itemNames)
{
_lookup.PopulateWithItems(name, new List<ProjectItemInstance>());
}
}
_metadata = metadata;
_expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(_lookup.ReadOnlyLookup, _lookup.ReadOnlyLookup, new StringMetadataTable(metadata));
_bucketSequenceNumber = bucketSequenceNumber;
}