/// <summary> /// The item. /// </summary> /// <param name="name"> /// The name. /// </param> /// <param name="makeChampionUniq"> /// The make champion unique. /// </param> /// <returns> /// The <see cref="MenuItem" />. /// </returns> public MenuItem Item(string name, bool makeChampionUniq = false) { if (makeChampionUniq && ObjectManager.LocalHero != null) { name = ObjectManager.LocalHero.StoredName() + name; } var id = this.Name + name + (this.Parent != null ? this.Parent.Name : string.Empty); MenuItem tempItem; if (ItemDictionary.TryGetValue(id, out tempItem)) { return(tempItem); } tempItem = this.Items.FirstOrDefault(x => x.Name == name) ?? (from subMenu in this.Children where subMenu.Item(name) != null select subMenu.Item(name)) .FirstOrDefault(); if (tempItem != null) { ItemDictionary.Add(id, tempItem); } return(tempItem); }
public void OldSyntaxTests() { Parser p = new Parser(); ProjectInstance parentProject = new ProjectInstance(ProjectRootElement.Create()); ItemDictionary <ProjectItemInstance> itemBag = new ItemDictionary <ProjectItemInstance>(); itemBag.Add(new ProjectItemInstance(parentProject, "Compile", "foo.cs", parentProject.FullPath)); itemBag.Add(new ProjectItemInstance(parentProject, "Compile", "bar.cs", parentProject.FullPath)); itemBag.Add(new ProjectItemInstance(parentProject, "Compile", "baz.cs", parentProject.FullPath)); PropertyDictionary <ProjectPropertyInstance> propertyBag = new PropertyDictionary <ProjectPropertyInstance>(); propertyBag.Set(ProjectPropertyInstance.Create("foo", "true")); propertyBag.Set(ProjectPropertyInstance.Create("bar", "yes")); propertyBag.Set(ProjectPropertyInstance.Create("one", "1")); propertyBag.Set(ProjectPropertyInstance.Create("onepointzero", "1.0")); propertyBag.Set(ProjectPropertyInstance.Create("two", "2")); propertyBag.Set(ProjectPropertyInstance.Create("simple", "simplestring")); propertyBag.Set(ProjectPropertyInstance.Create("complex", "This is a complex string")); propertyBag.Set(ProjectPropertyInstance.Create("c1", "Another (complex) one.")); propertyBag.Set(ProjectPropertyInstance.Create("c2", "Another (complex) one.")); Expander <ProjectPropertyInstance, ProjectItemInstance> expander = new Expander <ProjectPropertyInstance, ProjectItemInstance>(propertyBag, itemBag, FileSystems.Default); AssertParseEvaluate(p, "(($(foo) != 'two' and $(bar)) and 5 >= 1) or $(one) == 1", expander, true); }
/// <summary> /// 報酬追加 /// </summary> /// <param name="loots"></param> /// <returns></returns> private AsyncSubject <Unit> AddLoots(List <LootItemStruct> loots) { AsyncSubject <Unit> subject = new AsyncSubject <Unit>(); ObservableUtils.Timer(loots.Count * 100 + 400).Subscribe(_ => { subject.OnNext(Unit.Default); subject.OnCompleted(); }); foreach (var(loot, index) in loots.Select((x, i) => (x, i))) { var pos = new Vector3(-500, -90 - (index * 60), 0); var itemObject = Object.Instantiate((GameObject)Resources.Load("Prefabs/GUI/ResultItem"), Vector3.zero, Quaternion.identity, _itemTransform); itemObject.transform.localPosition = pos; itemObject.GetComponent <CanvasGroup>().alpha = 0; var sprite = ItemDictionary.GetLootSprite(loot); //var sprite = AssetDatabase.LoadAssetAtPath<Sprite>("Assets/Resources/Sprites/Items/" + item.imageData.spritePath); itemObject.transform.Find("Icon").GetComponent <Image>().sprite = sprite; var text = ItemDictionary.GetText(loot); itemObject.transform.Find("Text").GetComponent <Text>().text = text; itemObject.transform.Find("Text").GetComponent <Text>().color = ItemDictionary.GetColor(loot.ItemId); itemObject.transform.Find("Type").GetComponent <TextMeshProUGUI>().text = ItemDictionary.GetCategoryName(loot.ItemId); itemObject.transform.Find("Type").GetComponent <TextMeshProUGUI>().color = ItemDictionary.GetColor(loot.ItemId); ObservableUtils.Timer(100 * index).Subscribe(_ => { itemObject.transform.DOLocalMoveX(0, 0.4f).Play(); itemObject.transform.GetComponent <CanvasGroup>().DOFade(1f, 0.4f).Play(); }); } return(subject); }
public void Initialize() { BigBoss.Debug.w(Logs.Main, "Starting Data Manager"); NPCs = new NPCDictionary <NPC, NPCInstance>(); Items = new ItemDictionary(); Materials = new ObjectDictionary <MaterialType>(); PlayerProfessions = new ProfessionTitles(); Strings = new Dictionary <string, string>(); LeveledItems = new ObjectDictionary <LeveledItemList> (); List <UnityEngine.Object> files = new List <UnityEngine.Object>(); files.AddRange(Resources.LoadAll("XML", typeof(TextAsset))); files.AddRange(Resources.LoadAll("XML/NPCs", typeof(TextAsset))); files.AddRange(Resources.LoadAll("XML/Strings", typeof(TextAsset))); files.AddRange(Resources.LoadAll("XML/Items", typeof(TextAsset))); files.AddRange(Resources.LoadAll("XML/LeveledLists", typeof(TextAsset))); foreach (UnityEngine.Object file in files) { #region DEBUG if (BigBoss.Debug.logging(Logs.XML)) { BigBoss.Debug.w(Logs.XML, "Parsing " + file.name + ".xml"); } #endregion ParseXML((file as TextAsset).text); } }
public void ValidUnqualifiedMetadataReference() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); List <string> parameters = new List <string>(); parameters.Add("@(File)"); parameters.Add("%(Culture)"); ItemDictionary <ProjectItemInstance> itemsByType = new ItemDictionary <ProjectItemInstance>(); List <ProjectItemInstance> items = new List <ProjectItemInstance>(); ProjectItemInstance a = new ProjectItemInstance(project, "File", "a.foo", project.FullPath); ProjectItemInstance b = new ProjectItemInstance(project, "File", "b.foo", project.FullPath); a.SetMetadata("Culture", "fr-fr"); b.SetMetadata("Culture", "en-en"); items.Add(a); items.Add(b); itemsByType.ImportItems(items); PropertyDictionary <ProjectPropertyInstance> properties = new PropertyDictionary <ProjectPropertyInstance>(); List <ItemBucket> buckets = BatchingEngine.PrepareBatchingBuckets(parameters, CreateLookup(itemsByType, properties), null); Assert.Equal(2, buckets.Count); }
private void Start() { cameraObject = GameObject.Find("Main Camera").GetComponent <AudioManager>(); hbM = FindObjectOfType <HotbarManager>(); itD = FindObjectOfType <ItemDictionary>(); itemSprite = gameObject.GetComponent <SpriteRenderer>(); }
public void InvalidUnqualifiedMetadataReference() { Assert.Throws <InvalidProjectFileException>(() => { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); List <string> parameters = new List <string>(); parameters.Add("@(File)"); parameters.Add("%(Culture)"); ItemDictionary <ProjectItemInstance> itemsByType = new ItemDictionary <ProjectItemInstance>(); List <ProjectItemInstance> items = new List <ProjectItemInstance>(); ProjectItemInstance a = new ProjectItemInstance(project, "File", "a.foo", project.FullPath); items.Add(a); ProjectItemInstance b = new ProjectItemInstance(project, "File", "b.foo", project.FullPath); items.Add(b); a.SetMetadata("Culture", "fr-fr"); itemsByType.ImportItems(items); PropertyDictionary <ProjectPropertyInstance> properties = new PropertyDictionary <ProjectPropertyInstance>(); // This is expected to throw because not all items contain a value for metadata "Culture". // Only a.foo has a Culture metadata. b.foo does not. List <ItemBucket> buckets = BatchingEngine.PrepareBatchingBuckets(parameters, CreateLookup(itemsByType, properties), MockElementLocation.Instance); } ); }
public void StringExpansionTests() { Parser p = new Parser(); ProjectInstance parentProject = new ProjectInstance(ProjectRootElement.Create()); ItemDictionary <ProjectItemInstance> itemBag = new ItemDictionary <ProjectItemInstance>(); itemBag.Add(new ProjectItemInstance(parentProject, "Compile", "foo.cs", parentProject.FullPath)); itemBag.Add(new ProjectItemInstance(parentProject, "Compile", "bar.cs", parentProject.FullPath)); itemBag.Add(new ProjectItemInstance(parentProject, "Compile", "baz.cs", parentProject.FullPath)); PropertyDictionary <ProjectPropertyInstance> propertyBag = new PropertyDictionary <ProjectPropertyInstance>(); propertyBag.Set(ProjectPropertyInstance.Create("foo", "true")); propertyBag.Set(ProjectPropertyInstance.Create("bar", "yes")); propertyBag.Set(ProjectPropertyInstance.Create("one", "1")); propertyBag.Set(ProjectPropertyInstance.Create("onepointzero", "1.0")); propertyBag.Set(ProjectPropertyInstance.Create("two", "2")); propertyBag.Set(ProjectPropertyInstance.Create("simple", "simplestring")); propertyBag.Set(ProjectPropertyInstance.Create("complex", "This is a complex string")); propertyBag.Set(ProjectPropertyInstance.Create("c1", "Another (complex) one.")); propertyBag.Set(ProjectPropertyInstance.Create("c2", "Another (complex) one.")); propertyBag.Set(ProjectPropertyInstance.Create("TestQuote", "Contains'Quote'")); propertyBag.Set(ProjectPropertyInstance.Create("AnotherTestQuote", "Here's Johnny!")); propertyBag.Set(ProjectPropertyInstance.Create("Atsign", "Test the @ replacement")); Expander <ProjectPropertyInstance, ProjectItemInstance> expander = new Expander <ProjectPropertyInstance, ProjectItemInstance>(propertyBag, itemBag, FileSystems.Default); AssertParseEvaluate(p, "'simplestring: true foo.cs;bar.cs;baz.cs' == '$(simple): $(foo) @(compile)'", expander, true); AssertParseEvaluate(p, "'$(c1) $(c2)' == 'Another (complex) one. Another (complex) one.'", expander, true); AssertParseEvaluate(p, "'CONTAINS%27QUOTE%27' == '$(TestQuote)'", expander, true); AssertParseEvaluate(p, "'Here%27s Johnny!' == '$(AnotherTestQuote)'", expander, true); AssertParseEvaluate(p, "'Test the %40 replacement' == $(Atsign)", expander, true); }
/// <summary> /// 戦闘イベント処理 /// </summary> /// <param name="subject"></param> /// <param name="dungeonEffectView"></param> private static void BattleEvent(AsyncSubject <Unit> subject, DungeonEffectView dungeonEffectView) { dungeonEffectView.OpenTransition().Subscribe(_ => { var dungeon = GameObject.Find("Dungeon"); dungeon.SetActive(false); //戦闘画面を立ち上げる GameSceneManager.BootBattle().Subscribe(loots => { dungeonEffectView.OpenTransition().Subscribe(___ => { //戦闘画面を消す GameSceneManager.EndBattle(); dungeon.SetActive(true); dungeonEffectView.HideTransition().Subscribe(____ => { //報酬ログを流す List <string> texts = new List <string>(); loots.ForEach(loot => { texts.Add(ItemDictionary.GetAnnounceText(loot)); }); AnnounceTextView.Instance.AddText(texts); subject.OnNext(Unit.Default); subject.OnCompleted(); }); }); }); dungeonEffectView.HideTransition(); }); }
public void ItemListTests() { Parser p = new Parser(); ProjectInstance parentProject = new ProjectInstance(ProjectRootElement.Create()); ItemDictionary <ProjectItemInstance> itemBag = new ItemDictionary <ProjectItemInstance>(); itemBag.Add(new ProjectItemInstance(parentProject, "Compile", "foo.cs", parentProject.FullPath)); itemBag.Add(new ProjectItemInstance(parentProject, "Compile", "bar.cs", parentProject.FullPath)); itemBag.Add(new ProjectItemInstance(parentProject, "Compile", "baz.cs", parentProject.FullPath)); itemBag.Add(new ProjectItemInstance(parentProject, "Boolean", "true", parentProject.FullPath)); Expander <ProjectPropertyInstance, ProjectItemInstance> expander = new Expander <ProjectPropertyInstance, ProjectItemInstance>(new PropertyDictionary <ProjectPropertyInstance>(), itemBag); AssertParseEvaluate(p, "@(Compile) == 'foo.cs;bar.cs;baz.cs'", expander, true); AssertParseEvaluate(p, "@(Compile,' ') == 'foo.cs bar.cs baz.cs'", expander, true); AssertParseEvaluate(p, "@(Compile,'') == 'foo.csbar.csbaz.cs'", expander, true); AssertParseEvaluate(p, "@(Compile->'%(Filename)') == 'foo;bar;baz'", expander, true); AssertParseEvaluate(p, "@(Compile -> 'temp\\%(Filename).xml', ' ') == 'temp\\foo.xml temp\\bar.xml temp\\baz.xml'", expander, true); AssertParseEvaluate(p, "@(Compile->'', '') == ''", expander, true); AssertParseEvaluate(p, "@(Compile->'') == ';;'", expander, true); AssertParseEvaluate(p, "@(Compile->'%(Nonexistent)', '') == ''", expander, true); AssertParseEvaluate(p, "@(Compile->'%(Nonexistent)') == ';;'", expander, true); AssertParseEvaluate(p, "@(Boolean)", expander, true); AssertParseEvaluate(p, "@(Boolean) == true", expander, true); AssertParseEvaluate(p, "'@(Empty, ';')' == ''", expander, true); }
/// <summary> /// Removes all items from the given cell. /// If the items don't occupy another cell, they are removed as well. /// </summary> /// <param name="cell">The cell to remove items from</param> public void Remove(Point cell) { lock (lockObject) { Point c = Clamp(cell); List <T> l; Grid.TryGetValue(c, out l); if (l != null) { foreach (T i in l) { List <Point> pl; ItemDictionary.TryGetValue(i, out pl); if (pl != null) { pl.Remove(c); if (pl.Count == 0) { ListOfPointQueue.Enqueue(pl); ItemDictionary.Remove(i); } } } l.Clear(); ListOfItemQueue.Enqueue(l); Grid.Remove(cell); } } }
private void AddToItems(T item, Point cell) { List <Point> pl; ItemDictionary.TryGetValue(item, out pl); if (pl == null) { if (ListOfPointQueue.Count > 0) { pl = ListOfPointQueue.Dequeue(); } else { pl = new List <Point>(); } pl.Add(cell); ItemDictionary.Add(item, pl); } else { if (!pl.Contains(cell)) { pl.Add(cell); } } }
public override void ProcessFeatures(Dictionary <string, Feature> features) { base.ProcessFeatures(features); string filename = Header.FileName; if (Path.GetFileName(filename) != filename) { if (string.IsNullOrWhiteSpace(OutputDir)) { OutputDir = Path.GetDirectoryName(filename); } else { OutputDir = Path.Combine(OutputDir, Path.GetDirectoryName(filename)); } filename = Path.GetFileName(filename); } ItemDictionary.OutputStats( Inputs, filename, OutputDir, GetBoolean(features, IndividualValue), GetBoolean(features, BaddumpColumnValue), GetBoolean(features, NodumpColumnValue), GetStatReportFormat(features)); }
public void ClearMarkedTest() { // Setup the dictionary var dict = new ItemDictionary { ["game-1"] = new ConcurrentList <DatItem> { new Rom { Name = "rom-1", Size = 1024, CRC = "DEADBEEF", SHA1 = "0000000fbbb37f8488100b1b4697012de631a5e6", Machine = new Machine { Name = "game-1" }, }, new Rom { Name = "rom-2", Size = 1024, CRC = "DEADBEEF", SHA1 = "000000e948edcb4f7704b8af85a77a3339ecce44", Machine = new Machine { Name = "game-1" }, Remove = true, }, }, }; dict.ClearMarked(); Assert.Single(dict.Keys); Assert.Single(dict["game-1"]); }
protected override void EvaluateMove() { PotvinCustomerRelocationMove move = CustomerRelocationMoveParameter.ActualValue; PotvinEncoding newSolution = CustomerRelocationMoveParameter.ActualValue.Individual.Clone() as PotvinEncoding; PotvinCustomerRelocationMoveMaker.Apply(newSolution, move, ProblemInstance); UpdateEvaluation(newSolution); //Apply memory, only if move is worse if (MoveQualityParameter.ActualValue.Value >= QualityParameter.ActualValue.Value) { VariableCollection memory = MemoriesParameter.ActualValue; string key = AdditionFrequencyMemoryKeyParameter.Value.Value; if (memory != null && memory.ContainsKey(key)) { ItemDictionary <PotvinCustomerRelocationMoveAttribute, IntValue> additionFrequency = memory[key].Value as ItemDictionary <PotvinCustomerRelocationMoveAttribute, IntValue>; PotvinCustomerRelocationMoveAttribute attr = new PotvinCustomerRelocationMoveAttribute(0, move.Tour, move.City); if (additionFrequency.ContainsKey(attr)) { int frequency = additionFrequency[attr].Value; double quality = MoveQualityParameter.ActualValue.Value; MoveQualityParameter.ActualValue.Value += LambdaParameter.Value.Value * quality * frequency; } } } }
public void InputItemThatCorrelatesWithMultipleTransformOutputItems() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); string inputs = "@(Items)"; string outputs = "@(Items->'%(Filename).dll');@(Items->'%(Filename).xml')"; FileWriteInfo[] filesToAnalyze = new FileWriteInfo[] { new FileWriteInfo("a.cs", _yesterday), new FileWriteInfo("a.dll", _today), new FileWriteInfo("a.xml", _today), new FileWriteInfo("b.cs", _yesterday), new FileWriteInfo("b.dll", _twoDaysAgo), new FileWriteInfo("b.xml", _today), new FileWriteInfo("c.cs", _yesterday), new FileWriteInfo("c.dll", _today), new FileWriteInfo("c.xml", _today) }; List <ProjectItemInstance> items = new List <ProjectItemInstance>(); items.Add(new ProjectItemInstance(project, "Items", "a.cs", project.FullPath)); items.Add(new ProjectItemInstance(project, "Items", "b.cs", project.FullPath)); items.Add(new ProjectItemInstance(project, "Items", "c.cs", project.FullPath)); ItemDictionary <ProjectItemInstance> itemsByName = new ItemDictionary <ProjectItemInstance>(); itemsByName.ImportItems(items); DependencyAnalysisResult result = PerformDependencyAnalysisTestHelper(filesToAnalyze, itemsByName, inputs, outputs); Assert.Equal(DependencyAnalysisResult.IncrementalBuild, result); // "Should only build partially." }
private void DrawLevel() { if (!Level.Singleton) { return; } EditorGUI.indentLevel++; Level level = Level.Singleton; List <ItemData> levelCollectedItems = level.CollectedItems; ItemDictionary itemDictionary = new ItemDictionary(); foreach (ItemData collectedItem in levelCollectedItems) { itemDictionary.TryGetValue(collectedItem, out int curAmount); curAmount++; itemDictionary[collectedItem] = curAmount; } foreach (KeyValuePair <ItemData, int> keyValuePair in itemDictionary) { EditorGUILayout.LabelField(keyValuePair.Key.itemName, keyValuePair.Value + ""); } EditorGUI.indentLevel--; }
void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); if (dictAmulet == null) { dictAmulet = new Dictionary <ItemName, Amulet>(); //Debug.Log("Amulet Null"); foreach (AmuletDictionary dict in amulets) { dictAmulet.Add(dict.key, dict.amulet); } amulets.Clear(); //Debug.Log("Amulet punya amulet air "+(dictAmulet.ContainsKey(ItemName.Amulet_Air))); } if (dictEquipment == null) { //Debug.Log("Equipment Null"); dictEquipment = new Dictionary <ItemName, Equipment>(); foreach (EqupmentDictionary dict in equipments) { dictEquipment.Add(dict.key, dict.equipment); } equipments.Clear(); } if (dictConsumable == null) { //Debug.Log("Consumable Null"); dictConsumable = new Dictionary <ItemName, Consumable>(); foreach (ConsumableDictionary dict in consumables) { dictConsumable.Add(dict.key, dict.consumable); } consumables.Clear(); } if (dictQuestItem == null) { dictQuestItem = new Dictionary <ItemName, QuestItem>(); foreach (QuestItemDictionary dict in questItems) { dictQuestItem.Add(dict.key, dict.questItem); } questItems.Clear(); } }
public void ResetStatisticsTest() { var dict = new ItemDictionary { GameCount = 1 }; dict.ResetStatistics(); Assert.Equal(0, dict.GameCount); }
/// <summary> /// Removes the first occurrence of a specific object from the <see cref="T:System.Collections.Generic.ICollection`1" />. /// </summary> /// <param name="item">The object to remove from the <see cref="T:System.Collections.Generic.ICollection`1" />.</param> /// <returns>true if <paramref name="item" /> was successfully removed from the <see cref="T:System.Collections.Generic.ICollection`1" />; otherwise, false. This method also returns false if <paramref name="item" /> is not found in the original <see cref="T:System.Collections.Generic.ICollection`1" />.</returns> public bool Remove(TItem item) { if (HasKey) { ItemDictionary.Remove(ExtractKey(item)); } ++m_VersionTag; return(ItemList.Remove(item)); }
public void BucketByTest(ItemKey itemKey, int expected) { // Setup the dictionary var dict = new ItemDictionary { ["game-1"] = new ConcurrentList <DatItem> { new Rom { Name = "rom-1", Size = 1024, CRC = "DEADBEEF", SHA1 = "0000000fbbb37f8488100b1b4697012de631a5e6", Machine = new Machine { Name = "game-1" }, }, new Rom { Name = "rom-2", Size = 1024, CRC = "DEADBEEF", SHA1 = "000000e948edcb4f7704b8af85a77a3339ecce44", Machine = new Machine { Name = "game-1" }, }, }, ["game-2"] = new ConcurrentList <DatItem> { new Rom { Name = "rom-3", Size = 1024, CRC = "DEADBEEF", SHA1 = "00000ea4014ce66679e7e17d56ac510f67e39e26", Machine = new Machine { Name = "game-2" }, }, new Rom { Name = "rom-4", Size = 1024, CRC = "DEADBEEF", SHA1 = "00000151d437442e74e5134023fab8bf694a2487", Machine = new Machine { Name = "game-2" }, }, }, }; dict.BucketBy(itemKey, DedupeType.None); Assert.Equal(expected, dict.Keys.Count); }
/// <summary> /// Removes all items from the <see cref="T:System.Collections.Generic.ICollection`1" />. /// </summary> public void Clear() { ItemList.Clear(); ++m_VersionTag; if (HasKey) { ItemDictionary.Clear(); } }
public WoodenSword(PlayerControl player, ItemDictionary itemDict) { playerObj = player; itemDictObj = itemDict; name = "wooden sword"; ItemType itemType = ItemType.Weapon; description = "An old wooden sword used for training"; stackable = false; }
/// <summary> /// Adds an item to the <see cref="T:System.Collections.Generic.ICollection`1" />. /// </summary> /// <param name="item">The object to add to the <see cref="T:System.Collections.Generic.ICollection`1" />.</param> public void Add(TItem item) { ItemList.Add(item); ++m_VersionTag; if (HasKey) { ItemDictionary.Add(ExtractKey(item), item); } }
/// <summary> /// Inserts an item to the <see cref="T:System.Collections.Generic.IList`1" /> at the specified index. /// </summary> /// <param name="index">The zero-based index at which <paramref name="item" /> should be inserted.</param> /// <param name="item">The object to insert into the <see cref="T:System.Collections.Generic.IList`1" />.</param> public void Insert(int index, TItem item) { ItemList.Insert(index, item); ++m_VersionTag; if (HasKey) { ItemDictionary.Add(ExtractKey(item), item); } }
public PlayerStore(string name) { Name = name; KnownSongs = new List <string>(); _itemInventory = new ItemDictionary(); _itemInventoryData = new List <string>(); _itemInventoryAmount = new List <int>(); _knownItems = new List <ItemData>(); _knownItemsData = new List <string>(); }
//setup constructor public PlayerControl(Map map, CombatManager combatManager) { MapRef = map; combatManagerRef = combatManager; inventory = new ItemDictionary(this); player = new Player(combatManagerRef, inventory); player.AddToParty(this); //setup combat number StepsForCombat(); }
/// <summary> /// 獲得したアイテムを表示する /// </summary> /// <param name="loots"></param> public void AddLootImages(List <LootItemStruct> loots) { var lootTransform = Modal.transform.Find("Content/LootItems"); loots.ForEach(loot => { var lootObject = Object.Instantiate( (GameObject)Resources.Load("Prefabs/Modal/DungeonEvent/Parts/LootItem"), lootTransform); lootObject.GetComponent <Image>().sprite = ItemDictionary.GetLootSprite(loot); }); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var gearName = value as string; if (gearName == null) { return(""); } return(ItemDictionary.GetInGameName(gearName)); }
//setup player public Player(CombatManager manager, ItemDictionary inventory) : base(manager, inventory) { attributes = new Attributes(1, 5, 5, 5, 5); attributes.SetResource(); combatManager = manager; spellBook = new MagicDictionary(this, combatManager); //spell tests spellBook.Fireball(); spellBook.ConeOfCold(); spellBook.Heal(); }
public void SecondaryItemNotShadowedByPrimaryItem() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); ItemDictionary<ProjectItemInstance> table1 = new ItemDictionary<ProjectItemInstance>(); table1.Add(new ProjectItemInstance(project, "i1", "a1", project.FullPath)); table1.Add(new ProjectItemInstance(project, "i2", "a%3b1", project.FullPath)); Lookup lookup = LookupHelpers.CreateLookup(table1); Lookup.Scope enteredScope = lookup.EnterScope("x"); // Should return item from the secondary table. Assert.Equal("a1", lookup.GetItems("i1").First().EvaluatedInclude); Assert.Equal("a;1", lookup.GetItems("i2").First().EvaluatedInclude); }
public void KeepMetadataOnlySpecifiedNoneSpecified() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); ItemDictionary<ProjectItemInstance> table1 = new ItemDictionary<ProjectItemInstance>(); Lookup lookup = LookupHelpers.CreateLookup(table1); Lookup.Scope enteredScope = lookup.EnterScope("x"); // Add an item with m=m1 ProjectItemInstance item1 = new ProjectItemInstance(project, "i1", "a2", project.FullPath); item1.SetMetadata("m1", "m1"); item1.SetMetadata("m2", "m2"); lookup.AddNewItem(item1); Lookup.Scope enteredScope2 = lookup.EnterScope("x"); // Test keeping only specified metadata Lookup.MetadataModifications newMetadata = new Lookup.MetadataModifications(keepOnlySpecified: true); ICollection<ProjectItemInstance> group = lookup.GetItems(item1.ItemType); lookup.ModifyItems(item1.ItemType, group, newMetadata); group = lookup.GetItems("i1"); Assert.Equal(1, group.Count); // m1 and m2 are gone. Assert.Equal(String.Empty, group.First().GetMetadataValue("m1")); Assert.Equal(String.Empty, group.First().GetMetadataValue("m2")); enteredScope2.LeaveScope(); group = lookup.GetItems("i1"); Assert.Equal(1, group.Count); // m1 and m2 are gone. Assert.Equal(String.Empty, group.First().GetMetadataValue("m1")); Assert.Equal(String.Empty, group.First().GetMetadataValue("m2")); enteredScope.LeaveScope(); group = lookup.GetItems("i1"); Assert.Equal(1, group.Count); // m1 and m2 are gone. Assert.Equal(String.Empty, group.First().GetMetadataValue("m1")); Assert.Equal(String.Empty, group.First().GetMetadataValue("m2")); }
public void KeepMetadataOnlySpecifiedPropagate4() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); ItemDictionary<ProjectItemInstance> table1 = new ItemDictionary<ProjectItemInstance>(); Lookup lookup = LookupHelpers.CreateLookup(table1); Lookup.Scope enteredScope = lookup.EnterScope("x"); // Add an item with m=m1 ProjectItemInstance item1 = new ProjectItemInstance(project, "i1", "a2", project.FullPath); item1.SetMetadata("m1", "m1"); item1.SetMetadata("m2", "m2"); lookup.AddNewItem(item1); Lookup.Scope enteredScope2 = lookup.EnterScope("x"); // Get rid of all of the metadata, then add m3 Lookup.MetadataModifications newMetadata = new Lookup.MetadataModifications(keepOnlySpecified: true); newMetadata.Add("m3", "m3"); ICollection<ProjectItemInstance> group = lookup.GetItems(item1.ItemType); lookup.ModifyItems(item1.ItemType, group, newMetadata); group = lookup.GetItems("i1"); Assert.Equal(1, group.Count); // m1 and m2 are gone. Assert.Equal(String.Empty, group.First().GetMetadataValue("m1")); Assert.Equal(String.Empty, group.First().GetMetadataValue("m2")); // m3 is still there. Assert.Equal("m3", group.First().GetMetadataValue("m3")); enteredScope2.LeaveScope(); // Keep m3. Lookup.MetadataModifications newMetadata2 = new Lookup.MetadataModifications(keepOnlySpecified: true); newMetadata2["m3"] = Lookup.MetadataModification.CreateFromNoChange(); group = lookup.GetItems(item1.ItemType); lookup.ModifyItems(item1.ItemType, group, newMetadata2); group = lookup.GetItems("i1"); Assert.Equal(1, group.Count); // m1 and m2 are gone Assert.Equal(String.Empty, group.First().GetMetadataValue("m1")); Assert.Equal(String.Empty, group.First().GetMetadataValue("m2")); // m3 is still there Assert.Equal("m3", group.First().GetMetadataValue("m3")); enteredScope.LeaveScope(); group = lookup.GetItems("i1"); Assert.Equal(1, group.Count); // m1 and m2 are gone Assert.Equal(String.Empty, group.First().GetMetadataValue("m1")); Assert.Equal(String.Empty, group.First().GetMetadataValue("m2")); // m3 is still there. Assert.Equal("m3", group.First().GetMetadataValue("m3")); }
private static Lookup CreateLookup(ItemDictionary<ProjectItemInstance> itemsByType, PropertyDictionary<ProjectPropertyInstance> properties) { return new Lookup(itemsByType, properties, null); }
public void OldSyntaxTests() { Parser p = new Parser(); ProjectInstance parentProject = new ProjectInstance(ProjectRootElement.Create()); ItemDictionary<ProjectItemInstance> itemBag = new ItemDictionary<ProjectItemInstance>(); itemBag.Add(new ProjectItemInstance(parentProject, "Compile", "foo.cs", parentProject.FullPath)); itemBag.Add(new ProjectItemInstance(parentProject, "Compile", "bar.cs", parentProject.FullPath)); itemBag.Add(new ProjectItemInstance(parentProject, "Compile", "baz.cs", parentProject.FullPath)); PropertyDictionary<ProjectPropertyInstance> propertyBag = new PropertyDictionary<ProjectPropertyInstance>(); propertyBag.Set(ProjectPropertyInstance.Create("foo", "true")); propertyBag.Set(ProjectPropertyInstance.Create("bar", "yes")); propertyBag.Set(ProjectPropertyInstance.Create("one", "1")); propertyBag.Set(ProjectPropertyInstance.Create("onepointzero", "1.0")); propertyBag.Set(ProjectPropertyInstance.Create("two", "2")); propertyBag.Set(ProjectPropertyInstance.Create("simple", "simplestring")); propertyBag.Set(ProjectPropertyInstance.Create("complex", "This is a complex string")); propertyBag.Set(ProjectPropertyInstance.Create("c1", "Another (complex) one.")); propertyBag.Set(ProjectPropertyInstance.Create("c2", "Another (complex) one.")); Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(propertyBag, itemBag); AssertParseEvaluate(p, "(($(foo) != 'two' and $(bar)) and 5 >= 1) or $(one) == 1", expander, true); }
public void ModifyItemTwiceInSameScope2() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); ItemDictionary<ProjectItemInstance> table1 = new ItemDictionary<ProjectItemInstance>(); Lookup lookup = LookupHelpers.CreateLookup(table1); // Add an item with m=m1 and n=n1 and o=o1 ProjectItemInstance item1 = new ProjectItemInstance(project, "i1", "a2", project.FullPath); item1.SetMetadata("m", "m1"); item1.SetMetadata("n", "n1"); item1.SetMetadata("o", "o1"); lookup.PopulateWithItem(item1); Lookup.Scope enteredScope = lookup.EnterScope("x"); // It's still m=m1, n=n1, o=o1 ICollection<ProjectItemInstance> group = lookup.GetItems("i1"); Assert.Equal(1, group.Count); Assert.Equal("m1", group.First().GetMetadataValue("m")); Assert.Equal("n1", group.First().GetMetadataValue("n")); Assert.Equal("o1", group.First().GetMetadataValue("o")); // Make a modification to the item to be m=m2 and n=n2 Lookup.MetadataModifications newMetadata = new Lookup.MetadataModifications(keepOnlySpecified: false); newMetadata.Add("m", "m2"); newMetadata.Add("n", "n2"); group = new List<ProjectItemInstance>(); group.Add(item1); lookup.ModifyItems("i1", group, newMetadata); // It's now m=m2, n=n2, o=o1 ICollection<ProjectItemInstance> foundGroup = lookup.GetItems("i1"); Assert.Equal(1, foundGroup.Count); Assert.Equal("m2", foundGroup.First().GetMetadataValue("m")); Assert.Equal("n2", foundGroup.First().GetMetadataValue("n")); Assert.Equal("o1", foundGroup.First().GetMetadataValue("o")); // Make a modification to the item to be n=n3 newMetadata = new Lookup.MetadataModifications(keepOnlySpecified: false); newMetadata.Add("n", "n3"); lookup.ModifyItems("i1", group, newMetadata); // It's now m=m2, n=n3, o=o1 foundGroup = lookup.GetItems("i1"); Assert.Equal(1, foundGroup.Count); Assert.Equal("m2", foundGroup.First().GetMetadataValue("m")); Assert.Equal("n3", foundGroup.First().GetMetadataValue("n")); Assert.Equal("o1", foundGroup.First().GetMetadataValue("o")); // But the original item hasn't changed yet Assert.Equal("m1", item1.GetMetadataValue("m")); Assert.Equal("n1", item1.GetMetadataValue("n")); Assert.Equal("o1", item1.GetMetadataValue("o")); enteredScope.LeaveScope(); // It's still m=m2, n=n3, o=o1 foundGroup = lookup.GetItems("i1"); Assert.Equal(1, foundGroup.Count); Assert.Equal("m2", foundGroup.First().GetMetadataValue("m")); Assert.Equal("n3", foundGroup.First().GetMetadataValue("n")); Assert.Equal("o1", foundGroup.First().GetMetadataValue("o")); // And the original item has changed Assert.Equal("m2", item1.GetMetadataValue("m")); Assert.Equal("n3", item1.GetMetadataValue("n")); Assert.Equal("o1", item1.GetMetadataValue("o")); }
public void ValidUnqualifiedMetadataReference() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); List<string> parameters = new List<string>(); parameters.Add("@(File)"); parameters.Add("%(Culture)"); ItemDictionary<ProjectItemInstance> itemsByType = new ItemDictionary<ProjectItemInstance>(); List<ProjectItemInstance> items = new List<ProjectItemInstance>(); ProjectItemInstance a = new ProjectItemInstance(project, "File", "a.foo", project.FullPath); ProjectItemInstance b = new ProjectItemInstance(project, "File", "b.foo", project.FullPath); a.SetMetadata("Culture", "fr-fr"); b.SetMetadata("Culture", "en-en"); items.Add(a); items.Add(b); itemsByType.ImportItems(items); PropertyDictionary<ProjectPropertyInstance> properties = new PropertyDictionary<ProjectPropertyInstance>(); List<ItemBucket> buckets = BatchingEngine.PrepareBatchingBuckets(parameters, CreateLookup(itemsByType, properties), null); Assert.AreEqual(2, buckets.Count); }
internal static Lookup CreateLookup(PropertyDictionary<ProjectPropertyInstance> properties, ItemDictionary<ProjectItemInstance> items) { Lookup lookup = new Lookup(items, properties, null); return lookup; }
public void RemoveItemFromProjectPreviouslyModifiedAndGottenThroughGetItem() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); // Create some project state with an item with m=m1 and n=n1 ItemDictionary<ProjectItemInstance> table1 = new ItemDictionary<ProjectItemInstance>(); ProjectItemInstance item1 = new ProjectItemInstance(project, "i1", "a2", project.FullPath); item1.SetMetadata("m", "m1"); table1.Add(item1); Lookup lookup = LookupHelpers.CreateLookup(table1); Lookup.Scope enteredScope = lookup.EnterScope("x"); // Make a modification to the item to be m=m2 Lookup.MetadataModifications newMetadata = new Lookup.MetadataModifications(keepOnlySpecified: false); newMetadata.Add("m", "m2"); List<ProjectItemInstance> group = new List<ProjectItemInstance>(); group.Add(item1); lookup.ModifyItems(item1.ItemType, group, newMetadata); // Get the item (under the covers, it cloned it in order to apply the modification) ICollection<ProjectItemInstance> group2 = lookup.GetItems(item1.ItemType); Assert.Equal(1, group2.Count); ProjectItemInstance item1b = group2.First(); // Remove the item lookup.RemoveItem(item1b); // There's now no items at all ICollection<ProjectItemInstance> group3 = lookup.GetItems(item1.ItemType); Assert.Equal(0, group3.Count); // Leave scope enteredScope.LeaveScope(); // And now none left in the project either Assert.Equal(0, table1["i1"].Count); }
public void ModifyItemInProjectPreviouslyModifiedAndGottenThroughGetItem() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); // Create some project state with an item with m=m1 and n=n1 ItemDictionary<ProjectItemInstance> table1 = new ItemDictionary<ProjectItemInstance>(); ProjectItemInstance item1 = new ProjectItemInstance(project, "i1", "a2", project.FullPath); item1.SetMetadata("m", "m1"); table1.Add(item1); Lookup lookup = LookupHelpers.CreateLookup(table1); Lookup.Scope enteredScope = lookup.EnterScope("x"); // Make a modification to the item to be m=m2 Lookup.MetadataModifications newMetadata = new Lookup.MetadataModifications(keepOnlySpecified: false); newMetadata.Add("m", "m2"); List<ProjectItemInstance> group = new List<ProjectItemInstance>(); group.Add(item1); lookup.ModifyItems(item1.ItemType, group, newMetadata); // Get the item (under the covers, it cloned it in order to apply the modification) ICollection<ProjectItemInstance> group2 = lookup.GetItems(item1.ItemType); Assert.Equal(1, group2.Count); ProjectItemInstance item1b = group2.First(); // Modify to m=m3 Lookup.MetadataModifications newMetadata2 = new Lookup.MetadataModifications(keepOnlySpecified: false); newMetadata2.Add("m", "m3"); List<ProjectItemInstance> group3 = new List<ProjectItemInstance>(); group3.Add(item1b); lookup.ModifyItems(item1b.ItemType, group3, newMetadata2); // Modifications are visible ICollection<ProjectItemInstance> group4 = lookup.GetItems(item1b.ItemType); Assert.Equal(1, group4.Count); Assert.Equal("m3", group4.First().GetMetadataValue("m")); // Leave scope enteredScope.LeaveScope(); // Still visible ICollection<ProjectItemInstance> group5 = lookup.GetItems(item1b.ItemType); Assert.Equal(1, group5.Count); Assert.Equal("m3", group5.First().GetMetadataValue("m")); // And the one in the project is changed Assert.Equal("m3", item1.GetMetadataValue("m")); }
public void InvalidUnqualifiedMetadataReference() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); List<string> parameters = new List<string>(); parameters.Add("@(File)"); parameters.Add("%(Culture)"); ItemDictionary<ProjectItemInstance> itemsByType = new ItemDictionary<ProjectItemInstance>(); List<ProjectItemInstance> items = new List<ProjectItemInstance>(); ProjectItemInstance a = new ProjectItemInstance(project, "File", "a.foo", project.FullPath); items.Add(a); ProjectItemInstance b = new ProjectItemInstance(project, "File", "b.foo", project.FullPath); items.Add(b); a.SetMetadata("Culture", "fr-fr"); itemsByType.ImportItems(items); PropertyDictionary<ProjectPropertyInstance> properties = new PropertyDictionary<ProjectPropertyInstance>(); // This is expected to throw because not all items contain a value for metadata "Culture". // Only a.foo has a Culture metadata. b.foo does not. List<ItemBucket> buckets = BatchingEngine.PrepareBatchingBuckets(parameters, CreateLookup(itemsByType, properties), MockElementLocation.Instance); }
public void NoItemsConsumed() { List<string> parameters = new List<string>(); parameters.Add("$(File)"); parameters.Add("%(Culture)"); ItemDictionary<ProjectItemInstance> itemsByType = new ItemDictionary<ProjectItemInstance>(); PropertyDictionary<ProjectPropertyInstance> properties = new PropertyDictionary<ProjectPropertyInstance>(); // This is expected to throw because we have no idea what item list %(Culture) refers to. List<ItemBucket> buckets = BatchingEngine.PrepareBatchingBuckets(parameters, CreateLookup(itemsByType, properties), MockElementLocation.Instance); }
public void Regress_Mutation_DuplicateBatchingBucketsAreFoldedTogether() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); List<string> parameters = new List<string>(); parameters.Add("%(File.Culture)"); ItemDictionary<ProjectItemInstance> itemsByType = new ItemDictionary<ProjectItemInstance>(); List<ProjectItemInstance> items = new List<ProjectItemInstance>(); items.Add(new ProjectItemInstance(project, "File", "a.foo", project.FullPath)); items.Add(new ProjectItemInstance(project, "File", "b.foo", project.FullPath)); // Need at least two items for this test case to ensure multiple buckets might be possible itemsByType.ImportItems(items); PropertyDictionary<ProjectPropertyInstance> properties = new PropertyDictionary<ProjectPropertyInstance>(); List<ItemBucket> buckets = BatchingEngine.PrepareBatchingBuckets(parameters, CreateLookup(itemsByType, properties), null); // If duplicate buckes have been folded correctly, then there will be exactly one bucket here // containing both a.foo and b.foo. Assert.AreEqual(1, buckets.Count); }
public void AddsAreCombinedWithPopulates() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); // One item in the project ItemDictionary<ProjectItemInstance> table1 = new ItemDictionary<ProjectItemInstance>(); table1.Add(new ProjectItemInstance(project, "i1", "a1", project.FullPath)); Lookup lookup = LookupHelpers.CreateLookup(table1); // We see the one item Assert.Equal("a1", lookup.GetItems("i1").First().EvaluatedInclude); Assert.Equal(1, lookup.GetItems("i1").Count); // One item in the project Assert.Equal("a1", table1["i1"].First().EvaluatedInclude); Assert.Equal(1, table1["i1"].Count); // Start a target Lookup.Scope enteredScope = lookup.EnterScope("x"); // We see the one item Assert.Equal("a1", lookup.GetItems("i1").First().EvaluatedInclude); Assert.Equal(1, lookup.GetItems("i1").Count); // One item in the project Assert.Equal("a1", table1["i1"].First().EvaluatedInclude); Assert.Equal(1, table1["i1"].Count); // Start a task (eg) and add a new item Lookup.Scope enteredScope2 = lookup.EnterScope("x"); lookup.AddNewItem(new ProjectItemInstance(project, "i1", "a2", project.FullPath)); // Now we see two items Assert.Equal("a1", lookup.GetItems("i1").First().EvaluatedInclude); Assert.Equal("a2", lookup.GetItems("i1").ElementAt(1).EvaluatedInclude); Assert.Equal(2, lookup.GetItems("i1").Count); // But there's still one item in the project Assert.Equal("a1", table1["i1"].First().EvaluatedInclude); Assert.Equal(1, table1["i1"].Count); // Finish the task enteredScope2.LeaveScope(); // We still see two items Assert.Equal("a1", lookup.GetItems("i1").First().EvaluatedInclude); Assert.Equal("a2", lookup.GetItems("i1").ElementAt(1).EvaluatedInclude); Assert.Equal(2, lookup.GetItems("i1").Count); // But there's still one item in the project Assert.Equal("a1", table1["i1"].First().EvaluatedInclude); Assert.Equal(1, table1["i1"].Count); // Finish the target enteredScope.LeaveScope(); // We still see two items Assert.Equal("a1", lookup.GetItems("i1").First().EvaluatedInclude); Assert.Equal("a2", lookup.GetItems("i1").ElementAt(1).EvaluatedInclude); Assert.Equal(2, lookup.GetItems("i1").Count); // And now the items have gotten put into the global group Assert.Equal("a1", table1["i1"].First().EvaluatedInclude); Assert.Equal("a2", table1["i1"].ElementAt(1).EvaluatedInclude); Assert.Equal(2, table1["i1"].Count); }
public void ModifyItemTwiceInSameScope1() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); ItemDictionary<ProjectItemInstance> table1 = new ItemDictionary<ProjectItemInstance>(); Lookup lookup = LookupHelpers.CreateLookup(table1); // Add an item with m=m1 and n=n1 ProjectItemInstance item1 = new ProjectItemInstance(project, "i1", "a2", project.FullPath); item1.SetMetadata("m", "m1"); lookup.PopulateWithItem(item1); Lookup.Scope enteredScope = lookup.EnterScope("x"); // Make a modification to the item to be m=m2 Lookup.MetadataModifications newMetadata = new Lookup.MetadataModifications(keepOnlySpecified: false); newMetadata.Add("m", "m2"); ICollection<ProjectItemInstance> group = new List<ProjectItemInstance>(); group.Add(item1); lookup.ModifyItems(item1.ItemType, group, newMetadata); // Make an unrelated modification to the item newMetadata = new Lookup.MetadataModifications(keepOnlySpecified: false); newMetadata.Add("n", "n1"); lookup.ModifyItems(item1.ItemType, group, newMetadata); // It's now m=m2 group = lookup.GetItems("i1"); Assert.Equal(1, group.Count); Assert.Equal("m2", group.First().GetMetadataValue("m")); }
public void PropertyFunctionConsumingItemMetadata() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); PropertyDictionary<ProjectPropertyInstance> pg = new PropertyDictionary<ProjectPropertyInstance>(); Dictionary<string, string> itemMetadataTable = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); itemMetadataTable["Compile.Identity"] = "fOo.Cs"; StringMetadataTable itemMetadata = new StringMetadataTable(itemMetadataTable); List<ProjectItemInstance> ig = new List<ProjectItemInstance>(); pg.Set(ProjectPropertyInstance.Create("SomePath", @"c:\some\path")); ig.Add(new ProjectItemInstance(project, "Compile", "fOo.Cs", project.FullPath)); ItemDictionary<ProjectItemInstance> itemsByType = new ItemDictionary<ProjectItemInstance>(); itemsByType.ImportItems(ig); Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(pg, itemsByType, itemMetadata); string result = expander.ExpandIntoStringLeaveEscaped(@"$([System.IO.Path]::Combine($(SomePath),%(Compile.Identity)))", ExpanderOptions.ExpandAll, MockElementLocation.Instance); Assert.Equal(@"c:\some\path\fOo.Cs", result); }
public void ModifyItemThatWasAddedInSameScope() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); ItemDictionary<ProjectItemInstance> table1 = new ItemDictionary<ProjectItemInstance>(); Lookup lookup = LookupHelpers.CreateLookup(table1); Lookup.Scope enteredScope = lookup.EnterScope("x"); // Add an item with m=m1 ProjectItemInstance item1 = new ProjectItemInstance(project, "i1", "a2", project.FullPath); item1.SetMetadata("m", "m1"); lookup.AddNewItem(item1); // Change the item to be m=m2 Lookup.MetadataModifications newMetadata = new Lookup.MetadataModifications(keepOnlySpecified: false); newMetadata.Add("m", "m2"); ICollection<ProjectItemInstance> group = new List<ProjectItemInstance>(); group.Add(item1); lookup.ModifyItems(item1.ItemType, group, newMetadata); // Now it has m=m2 group = lookup.GetItems("i1"); Assert.Equal(1, group.Count); Assert.Equal("m2", group.First().GetMetadataValue("m")); // But the original item hasn't changed yet Assert.Equal("m1", item1.GetMetadataValue("m")); enteredScope.LeaveScope(); // It still has m=m2 group = lookup.GetItems("i1"); Assert.Equal(1, group.Count); Assert.Equal("m2", group.First().GetMetadataValue("m")); // But now the original item has changed as well Assert.Equal("m2", item1.GetMetadataValue("m")); }
public void ExpandAllIntoTaskItems3() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); PropertyDictionary<ProjectPropertyInstance> pg = new PropertyDictionary<ProjectPropertyInstance>(); List<ProjectItemInstance> ig = new List<ProjectItemInstance>(); ig.Add(new ProjectItemInstance(project, "Compile", "foo.cs", project.FullPath)); ig.Add(new ProjectItemInstance(project, "Compile", "bar.cs", project.FullPath)); List<ProjectItemInstance> ig2 = new List<ProjectItemInstance>(); ig2.Add(new ProjectItemInstance(project, "Resource", "bing.resx", project.FullPath)); ItemDictionary<ProjectItemInstance> itemsByType = new ItemDictionary<ProjectItemInstance>(); itemsByType.ImportItems(ig); itemsByType.ImportItems(ig2); Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(pg, itemsByType); IList<TaskItem> itemsOut = expander.ExpandIntoTaskItemsLeaveEscaped("foo;bar;@(compile);@(resource)", ExpanderOptions.ExpandPropertiesAndItems, MockElementLocation.Instance); ObjectModelHelpers.AssertItemsMatch(@" foo bar foo.cs bar.cs bing.resx ", GetTaskArrayFromItemList(itemsOut)); }
// Use this for initialization void Start() { itemDictionary = (ItemDictionary)GameObject.Find("MasterController").GetComponent("ItemDictionary"); MedItems = new List<int>(); Equipment = new List<int>(); }
public void InvalidItemInConditionEvaluation() { Parser p = new Parser(); ProjectInstance parentProject = new ProjectInstance(ProjectRootElement.Create()); ItemDictionary<ProjectItemInstance> itemBag = new ItemDictionary<ProjectItemInstance>(); itemBag.Add(new ProjectItemInstance(parentProject, "Compile", "a", parentProject.FullPath)); PropertyDictionary<ProjectPropertyInstance> propertyBag = new PropertyDictionary<ProjectPropertyInstance>(); Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(propertyBag, itemBag); AssertParseEvaluateThrow(p, "@(Compile) > 0", expander, null); }
public void ConditionedPropertyUpdateTests() { Parser p = new Parser(); ProjectInstance parentProject = new ProjectInstance(ProjectRootElement.Create()); ItemDictionary<ProjectItemInstance> itemBag = new ItemDictionary<ProjectItemInstance>(); itemBag.Add(new ProjectItemInstance(parentProject, "Compile", "foo.cs", parentProject.FullPath)); itemBag.Add(new ProjectItemInstance(parentProject, "Compile", "bar.cs", parentProject.FullPath)); itemBag.Add(new ProjectItemInstance(parentProject, "Compile", "baz.cs", parentProject.FullPath)); Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(new PropertyDictionary<ProjectPropertyInstance>(), itemBag); Dictionary<string, List<string>> conditionedProperties = new Dictionary<string, List<string>>(); ConditionEvaluator.IConditionEvaluationState state = new ConditionEvaluator.ConditionEvaluationState<ProjectPropertyInstance, ProjectItemInstance> ( String.Empty, expander, ExpanderOptions.ExpandAll, conditionedProperties, Environment.CurrentDirectory, ElementLocation.EmptyLocation ); List<string> properties = null; AssertParseEvaluate(p, "'0' == '1'", expander, false, state); Assert.IsTrue(conditionedProperties.Count == 0); AssertParseEvaluate(p, "$(foo) == foo", expander, false, state); Assert.IsTrue(conditionedProperties.Count == 1); properties = conditionedProperties["foo"]; Assert.IsTrue(properties.Count == 1); AssertParseEvaluate(p, "'$(foo)' != 'bar'", expander, true, state); Assert.IsTrue(conditionedProperties.Count == 1); properties = conditionedProperties["foo"]; Assert.IsTrue(properties.Count == 2); AssertParseEvaluate(p, "'$(branch)|$(build)|$(platform)' == 'lab22dev|debug|x86'", expander, false, state); Assert.IsTrue(conditionedProperties.Count == 4); properties = conditionedProperties["foo"]; Assert.IsTrue(properties.Count == 2); properties = conditionedProperties["branch"]; Assert.IsTrue(properties.Count == 1); properties = conditionedProperties["build"]; Assert.IsTrue(properties.Count == 1); properties = conditionedProperties["platform"]; Assert.IsTrue(properties.Count == 1); AssertParseEvaluate(p, "'$(branch)|$(build)|$(platform)' == 'lab21|debug|x86'", expander, false, state); Assert.IsTrue(conditionedProperties.Count == 4); properties = conditionedProperties["foo"]; Assert.IsTrue(properties.Count == 2); properties = conditionedProperties["branch"]; Assert.IsTrue(properties.Count == 2); properties = conditionedProperties["build"]; Assert.IsTrue(properties.Count == 1); properties = conditionedProperties["platform"]; Assert.IsTrue(properties.Count == 1); AssertParseEvaluate(p, "'$(branch)|$(build)|$(platform)' == 'lab23|retail|ia64'", expander, false, state); Assert.IsTrue(conditionedProperties.Count == 4); properties = conditionedProperties["foo"]; Assert.IsTrue(properties.Count == 2); properties = conditionedProperties["branch"]; Assert.IsTrue(properties.Count == 3); properties = conditionedProperties["build"]; Assert.IsTrue(properties.Count == 2); properties = conditionedProperties["platform"]; Assert.IsTrue(properties.Count == 2); DumpDictionary(conditionedProperties); }
public void RemoveItemAddedInLowerScope() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); ItemDictionary<ProjectItemInstance> table1 = new ItemDictionary<ProjectItemInstance>(); Lookup lookup = LookupHelpers.CreateLookup(table1); // Start a target Lookup.Scope enteredScope = lookup.EnterScope("x"); // Add an item ProjectItemInstance item1 = new ProjectItemInstance(project, "i1", "a2", project.FullPath); lookup.AddNewItem(item1); // Start a task (eg) Lookup.Scope enteredScope2 = lookup.EnterScope("x"); // We see the item below Assert.Equal(1, lookup.GetItems("i1").Count); // Remove that item lookup.RemoveItem(item1); // We see no items Assert.Equal(0, lookup.GetItems("i1").Count); // Finish the task enteredScope2.LeaveScope(); // We still see no items Assert.Equal(0, lookup.GetItems("i1").Count); // Finish the target enteredScope.LeaveScope(); // We still see no items Assert.Equal(0, lookup.GetItems("i1").Count); }
public void AddsWithDuplicateRemovalItemSpecsOnly() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); // One item in the project ItemDictionary<ProjectItemInstance> table1 = new ItemDictionary<ProjectItemInstance>(); table1.Add(new ProjectItemInstance(project, "i1", "a1", project.FullPath)); // Add an existing duplicate table1.Add(new ProjectItemInstance(project, "i1", "a1", project.FullPath)); Lookup lookup = LookupHelpers.CreateLookup(table1); var scope = lookup.EnterScope("test"); // This one should not get added ProjectItemInstance[] newItems = new ProjectItemInstance[] { new ProjectItemInstance(project, "i1", "a1", project.FullPath), // Should not get added new ProjectItemInstance(project, "i1", "a2", project.FullPath), // Should get added }; // Perform the addition lookup.AddNewItemsOfItemType("i1", newItems, doNotAddDuplicates: true); var group = lookup.GetItems("i1"); // We should have the original two duplicates plus one new addition. Assert.Equal(3, group.Count); // Only two of the items should have the 'a1' include. Assert.Equal(2, group.Where(item => item.EvaluatedInclude == "a1").Count()); // And ensure the other item got added. Assert.Equal(1, group.Where(item => item.EvaluatedInclude == "a2").Count()); scope.LeaveScope(); group = lookup.GetItems("i1"); // We should have the original two duplicates plus one new addition. Assert.Equal(3, group.Count); // Only two of the items should have the 'a1' include. Assert.Equal(2, group.Where(item => item.EvaluatedInclude == "a1").Count()); // And ensure the other item got added. Assert.Equal(1, group.Where(item => item.EvaluatedInclude == "a2").Count()); }
public void GetBuckets() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); List<string> parameters = new List<string>(); parameters.Add("@(File);$(unittests)"); parameters.Add("$(obj)\\%(Filename).ext"); parameters.Add("@(File->'%(extension)')"); // attributes in transforms don't affect batching ItemDictionary<ProjectItemInstance> itemsByType = new ItemDictionary<ProjectItemInstance>(); IList<ProjectItemInstance> items = new List<ProjectItemInstance>(); items.Add(new ProjectItemInstance(project, "File", "a.foo", project.FullPath)); items.Add(new ProjectItemInstance(project, "File", "b.foo", project.FullPath)); items.Add(new ProjectItemInstance(project, "File", "c.foo", project.FullPath)); items.Add(new ProjectItemInstance(project, "File", "d.foo", project.FullPath)); items.Add(new ProjectItemInstance(project, "File", "e.foo", project.FullPath)); itemsByType.ImportItems(items); items = new List<ProjectItemInstance>(); items.Add(new ProjectItemInstance(project, "Doc", "a.doc", project.FullPath)); items.Add(new ProjectItemInstance(project, "Doc", "b.doc", project.FullPath)); items.Add(new ProjectItemInstance(project, "Doc", "c.doc", project.FullPath)); items.Add(new ProjectItemInstance(project, "Doc", "d.doc", project.FullPath)); items.Add(new ProjectItemInstance(project, "Doc", "e.doc", project.FullPath)); itemsByType.ImportItems(items); PropertyDictionary<ProjectPropertyInstance> properties = new PropertyDictionary<ProjectPropertyInstance>(); properties.Set(ProjectPropertyInstance.Create("UnitTests", "unittests.foo")); properties.Set(ProjectPropertyInstance.Create("OBJ", "obj")); List<ItemBucket> buckets = BatchingEngine.PrepareBatchingBuckets(parameters, CreateLookup(itemsByType, properties), MockElementLocation.Instance); Assert.AreEqual(5, buckets.Count); foreach (ItemBucket bucket in buckets) { // non-batching data -- same for all buckets XmlAttribute tempXmlAttribute = (new XmlDocument()).CreateAttribute("attrib"); tempXmlAttribute.Value = "'$(Obj)'=='obj'"; Assert.IsTrue(ConditionEvaluator.EvaluateCondition(tempXmlAttribute.Value, ParserOptions.AllowAll, bucket.Expander, ExpanderOptions.ExpandAll, Directory.GetCurrentDirectory(), MockElementLocation.Instance, null, new BuildEventContext(1, 2, 3, 4))); Assert.AreEqual("a.doc;b.doc;c.doc;d.doc;e.doc", bucket.Expander.ExpandIntoStringAndUnescape("@(doc)", ExpanderOptions.ExpandItems, MockElementLocation.Instance)); Assert.AreEqual("unittests.foo", bucket.Expander.ExpandIntoStringAndUnescape("$(bogus)$(UNITTESTS)", ExpanderOptions.ExpandPropertiesAndMetadata, MockElementLocation.Instance)); } Assert.AreEqual("a.foo", buckets[0].Expander.ExpandIntoStringAndUnescape("@(File)", ExpanderOptions.ExpandItems, MockElementLocation.Instance)); Assert.AreEqual(".foo", buckets[0].Expander.ExpandIntoStringAndUnescape("@(File->'%(Extension)')", ExpanderOptions.ExpandItems, MockElementLocation.Instance)); Assert.AreEqual("obj\\a.ext", buckets[0].Expander.ExpandIntoStringAndUnescape("$(obj)\\%(Filename).ext", ExpanderOptions.ExpandPropertiesAndMetadata, MockElementLocation.Instance)); // we weren't batching on this attribute, so it has no value Assert.AreEqual(String.Empty, buckets[0].Expander.ExpandIntoStringAndUnescape("%(Extension)", ExpanderOptions.ExpandAll, MockElementLocation.Instance)); ProjectItemInstanceFactory factory = new ProjectItemInstanceFactory(project, "i"); items = buckets[0].Expander.ExpandIntoItemsLeaveEscaped("@(file)", factory, ExpanderOptions.ExpandItems, MockElementLocation.Instance); Assert.IsNotNull(items); Assert.AreEqual(1, items.Count); int invalidProjectFileExceptions = 0; try { // This should throw because we don't allow item lists to be concatenated // with other strings. bool throwAway; items = buckets[0].Expander.ExpandSingleItemVectorExpressionIntoItems("@(file)$(unitests)", factory, ExpanderOptions.ExpandItems, false /* no nulls */, out throwAway, MockElementLocation.Instance); } catch (InvalidProjectFileException ex) { // check we don't lose error codes from IPFE's during build Assert.AreEqual(ex.ErrorCode, "MSB4012"); invalidProjectFileExceptions++; } // We do allow separators in item vectors, this results in an item group with a single flattened item items = buckets[0].Expander.ExpandIntoItemsLeaveEscaped("@(file, ',')", factory, ExpanderOptions.ExpandItems, MockElementLocation.Instance); Assert.IsNotNull(items); Assert.AreEqual(1, items.Count); Assert.AreEqual("a.foo", items[0].EvaluatedInclude); Assert.AreEqual(1, invalidProjectFileExceptions); }
/// <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); }
public void AddsWithDuplicateRemovalWithMetadata() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); ItemDictionary<ProjectItemInstance> table1 = new ItemDictionary<ProjectItemInstance>(); // Two items, differ only by metadata table1.Add(new ProjectItemInstance(project, "i1", "a1", new KeyValuePair<string, string>[] { new KeyValuePair<string, string>("m1", "m1") }, project.FullPath)); table1.Add(new ProjectItemInstance(project, "i1", "a1", new KeyValuePair<string, string>[] { new KeyValuePair<string, string>("m1", "m2") }, project.FullPath)); Lookup lookup = LookupHelpers.CreateLookup(table1); var scope = lookup.EnterScope("test"); // This one should not get added ProjectItemInstance[] newItems = new ProjectItemInstance[] { new ProjectItemInstance(project, "i1", "a1", project.FullPath), // Should get added new ProjectItemInstance(project, "i1", "a2", new KeyValuePair<string, string>[] { new KeyValuePair<string, string>( "m1", "m1" ) }, project.FullPath), // Should get added new ProjectItemInstance(project, "i1", "a1", new KeyValuePair<string, string>[] { new KeyValuePair<string, string>( "m1", "m1" ) }, project.FullPath), // Should not get added new ProjectItemInstance(project, "i1", "a1", new KeyValuePair<string, string>[] { new KeyValuePair<string, string>( "m1", "m3" ) }, project.FullPath), // Should get added }; // Perform the addition lookup.AddNewItemsOfItemType("i1", newItems, doNotAddDuplicates: true); var group = lookup.GetItems("i1"); // We should have the original two duplicates plus one new addition. Assert.Equal(5, group.Count); // Four of the items will have the a1 include Assert.Equal(4, group.Where(item => item.EvaluatedInclude == "a1").Count()); // One item will have the a2 include Assert.Equal(1, group.Where(item => item.EvaluatedInclude == "a2").Count()); scope.LeaveScope(); group = lookup.GetItems("i1"); // We should have the original two duplicates plus one new addition. Assert.Equal(5, group.Count); // Four of the items will have the a1 include Assert.Equal(4, group.Where(item => item.EvaluatedInclude == "a1").Count()); // One item will have the a2 include Assert.Equal(1, group.Where(item => item.EvaluatedInclude == "a2").Count()); }
/// <summary> /// Creates an expander populated with some ProjectPropertyInstances and ProjectPropertyItems. /// </summary> /// <returns></returns> private Expander<ProjectPropertyInstance, ProjectItemInstance> CreateItemFunctionExpander() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); PropertyDictionary<ProjectPropertyInstance> pg = new PropertyDictionary<ProjectPropertyInstance>(); pg.Set(ProjectPropertyInstance.Create("p", "v0")); pg.Set(ProjectPropertyInstance.Create("p", "v1")); pg.Set(ProjectPropertyInstance.Create("Val", "2")); pg.Set(ProjectPropertyInstance.Create("a", "filename")); ItemDictionary<ProjectItemInstance> ig = new ItemDictionary<ProjectItemInstance>(); for (int n = 0; n < 10; n++) { ProjectItemInstance pi = new ProjectItemInstance(project, "i", "i" + n.ToString(), project.FullPath); for (int m = 0; m < 5; m++) { pi.SetMetadata("Meta" + m.ToString(), @"c:\firstdirectory\seconddirectory\file" + m.ToString() + ".ext"); } pi.SetMetadata("Meta9", @"seconddirectory\file.ext"); pi.SetMetadata("Meta10", @";someo%3bherplace\foo.txt;secondd%3brectory\file.ext;"); pi.SetMetadata("MetaBlank", @""); if (n % 2 > 0) { pi.SetMetadata("Even", "true"); pi.SetMetadata("Odd", "false"); } else { pi.SetMetadata("Even", "false"); pi.SetMetadata("Odd", "true"); } ig.Add(pi); } Dictionary<string, string> itemMetadataTable = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); itemMetadataTable["Culture"] = "abc%253bdef;$(Gee_Aych_Ayee)"; itemMetadataTable["Language"] = "english"; IMetadataTable itemMetadata = new StringMetadataTable(itemMetadataTable); Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(pg, ig, itemMetadata); return expander; }
public void Removes() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); // One item in the project ItemDictionary<ProjectItemInstance> table1 = new ItemDictionary<ProjectItemInstance>(); ProjectItemInstance item1 = new ProjectItemInstance(project, "i1", "a1", project.FullPath); table1.Add(item1); Lookup lookup = LookupHelpers.CreateLookup(table1); // Start a target Lookup.Scope enteredScope = lookup.EnterScope("x"); // Start a task (eg) and add a new item Lookup.Scope enteredScope2 = lookup.EnterScope("x"); ProjectItemInstance item2 = new ProjectItemInstance(project, "i1", "a2", project.FullPath); lookup.AddNewItem(item2); // Remove one item lookup.RemoveItem(item1); // We see one item Assert.Equal(1, lookup.GetItems("i1").Count); Assert.Equal("a2", lookup.GetItems("i1").First().EvaluatedInclude); // Remove the other item lookup.RemoveItem(item2); // We see no items Assert.Equal(0, lookup.GetItems("i1").Count); // Finish the task enteredScope2.LeaveScope(); // We still see no items Assert.Equal(0, lookup.GetItems("i1").Count); // But there's still one item in the project Assert.Equal("a1", table1["i1"].First().EvaluatedInclude); Assert.Equal(1, table1["i1"].Count); // Finish the target enteredScope.LeaveScope(); // We still see no items Assert.Equal(0, lookup.GetItems("i1").Count); // And now there are no items in the project either Assert.Equal(0, table1["i1"].Count); }
/// <summary> /// Creates an expander populated with some ProjectPropertyInstances and ProjectPropertyItems. /// </summary> /// <returns></returns> private Expander<ProjectPropertyInstance, ProjectItemInstance> CreateExpander() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); PropertyDictionary<ProjectPropertyInstance> pg = new PropertyDictionary<ProjectPropertyInstance>(); pg.Set(ProjectPropertyInstance.Create("p", "v0")); pg.Set(ProjectPropertyInstance.Create("p", "v1")); ItemDictionary<ProjectItemInstance> ig = new ItemDictionary<ProjectItemInstance>(); ProjectItemInstance i0 = new ProjectItemInstance(project, "i", "i0", project.FullPath); ProjectItemInstance i1 = new ProjectItemInstance(project, "i", "i1", project.FullPath); ig.Add(i0); ig.Add(i1); Expander<ProjectPropertyInstance, ProjectItemInstance> expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(pg, ig); return expander; }
public void RemoveItemPopulatedInLowerScope() { ProjectInstance project = ProjectHelpers.CreateEmptyProjectInstance(); ItemDictionary<ProjectItemInstance> table1 = new ItemDictionary<ProjectItemInstance>(); Lookup lookup = LookupHelpers.CreateLookup(table1); ProjectItemInstance item1 = new ProjectItemInstance(project, "i1", "a2", project.FullPath); // Start a target Lookup.Scope enteredScope = lookup.EnterScope("x"); // There's one item in this batch lookup.PopulateWithItem(item1); // We see it Assert.Equal(1, lookup.GetItems("i1").Count); // Make a clone so we can keep an eye on that item Lookup lookup2 = lookup.Clone(); // We can see the item in the clone Assert.Equal(1, lookup2.GetItems("i1").Count); // Start a task (eg) Lookup.Scope enteredScope2 = lookup.EnterScope("x"); // We see the item below Assert.Equal(1, lookup.GetItems("i1").Count); // Remove that item lookup.RemoveItem(item1); // We see no items Assert.Equal(0, lookup.GetItems("i1").Count); // The clone is unaffected so far Assert.Equal(1, lookup2.GetItems("i1").Count); // Finish the task enteredScope2.LeaveScope(); // We still see no items Assert.Equal(0, lookup.GetItems("i1").Count); // But now the clone doesn't either Assert.Equal(0, lookup2.GetItems("i1").Count); // Finish the target enteredScope.LeaveScope(); // We still see no items Assert.Equal(0, lookup.GetItems("i1").Count); Assert.Equal(0, lookup2.GetItems("i1").Count); }