From 5e30e457366a3d0377d37a7e6aafb894bcf9255d Mon Sep 17 00:00:00 2001 From: Adefolarin Adeniji Date: Sat, 28 Aug 2021 12:33:43 +0100 Subject: [PATCH] modification - Modified files --- csharpcore/GildedRose/GildedRose.cs | 5 +++++ csharpcore/GildedRose/Program.cs | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/csharpcore/GildedRose/GildedRose.cs b/csharpcore/GildedRose/GildedRose.cs index b97a20cc..7d907e5c 100644 --- a/csharpcore/GildedRose/GildedRose.cs +++ b/csharpcore/GildedRose/GildedRose.cs @@ -9,5 +9,10 @@ namespace GildedRoseKata { this.Items = Items; } + + public static object GetPropValue(object src, string propName) + { + return src.GetType().GetProperty(propName).GetValue(src, null); + } } } diff --git a/csharpcore/GildedRose/Program.cs b/csharpcore/GildedRose/Program.cs index a2c4972e..53ef162c 100644 --- a/csharpcore/GildedRose/Program.cs +++ b/csharpcore/GildedRose/Program.cs @@ -41,9 +41,9 @@ namespace GildedRoseKata // this conjured item does not work properly yet new Conjured() {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6} }; - + var app = new GildedRose(items); - + for (var i = 0; i < 31; i++) { Console.WriteLine("-------- day " + i + " --------"); @@ -55,7 +55,7 @@ namespace GildedRoseKata // Get the type contained 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 // property string @@ -78,6 +78,10 @@ namespace GildedRoseKata updateQualityMethod.Invoke(instance, new object[0]); updateSellinMethod.Invoke(instance, new object[0]); + // update t + t.SellIn = instance.SellIn; + t.Quality = instance.Quality; + Console.WriteLine(""); }