modification

- Modified files
This commit is contained in:
Adefolarin Adeniji 2021-08-28 12:33:43 +01:00
parent a15e48a03e
commit 5e30e45736
2 changed files with 12 additions and 3 deletions

View File

@ -9,5 +9,10 @@ namespace GildedRoseKata
{ {
this.Items = Items; this.Items = Items;
} }
public static object GetPropValue(object src, string propName)
{
return src.GetType().GetProperty(propName).GetValue(src, null);
}
} }
} }

View File

@ -41,9 +41,9 @@ namespace GildedRoseKata
// this conjured item does not work properly yet // this conjured item does not work properly yet
new Conjured() {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6} new Conjured() {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6}
}; };
var app = new GildedRose(items); var app = new GildedRose(items);
for (var i = 0; i < 31; i++) for (var i = 0; i < 31; i++)
{ {
Console.WriteLine("-------- day " + i + " --------"); Console.WriteLine("-------- day " + i + " --------");
@ -55,7 +55,7 @@ namespace GildedRoseKata
// Get the type contained // Get the type contained
Type type = t.GetType(); Type type = t.GetType();
var instance = Activator.CreateInstance(type); dynamic instance = Activator.CreateInstance(type) as Item;
// Get a property on the type that is stored in the // Get a property on the type that is stored in the
// property string // property string
@ -78,6 +78,10 @@ namespace GildedRoseKata
updateQualityMethod.Invoke(instance, new object[0]); updateQualityMethod.Invoke(instance, new object[0]);
updateSellinMethod.Invoke(instance, new object[0]); updateSellinMethod.Invoke(instance, new object[0]);
// update t
t.SellIn = instance.SellIn;
t.Quality = instance.Quality;
Console.WriteLine(""); Console.WriteLine("");
} }