public static string Invoke(string methodName, string message = null, MoodAnalyser moodAnalyser = null) { try { var methodInfo = typeof(MoodAnalyser).GetMethod(methodName); var result = (string)methodInfo.Invoke(moodAnalyser ?? MoodAnalyserFactory.Initialize("MoodAnalyser"), new object[] { message }); return(result); } catch (Exception) { throw new MoodAnalysisException("No Such Method Exists", MoodAnalysisException.error.No_Such_Method); } }
static void Main(string[] args) { Console.WriteLine("Welcome to Mood Analyser Program!"); MoodAnalyserFactory.Initialize("MoodAnalyser"); MoodAnalyserReflector.Invoke("AnalyseMood"); }