//Method: MyMethod //Purpose: Call all methods of an object through interfaces and parent based on object type static void MyMethod(object obj) { if (obj.GetType() == typeof(Fantasy)) { Fantasy f1 = (Fantasy)obj; f1.Read(); f1.AddNotes("I like wizards."); IFantasy fantasy = (IFantasy)obj; fantasy.UseMagic(); } else if (obj.GetType() == typeof(Mystery)) { Mystery m1 = (Mystery)obj; m1.Read(); m1.AddNotes("The butler did it."); IMystery mystery = (IMystery)obj; mystery.CommitCrime(); } }
public override void ProcessMysteries(string Mysteries) { List <string> MysteryList = Mysteries.Split(',').ToList(); foreach (string mystery in MysteryList) { int Pos = mystery.IndexOf(PathfinderConstants.SPACE); string temp = mystery.Trim();; if (Pos >= 0) { temp = mystery.Substring(0, Pos).Trim(); } IMystery mysteryClass = MysteryReflectionWrapper.AddMysteryClass(temp); if (mysteryClass == null) { throw new Exception("Mystery not defined - " + temp); } OracleMysteries.Add(mysteryClass); } OracleMysteries.Remove(null); }