Exemplo n.º 1
0
        /// <summary>
        /// Use Case 6 :
        /// Use Reflection to Invoke the method
        /// </summary>
        /// <param name="className"></param>
        /// <param name="methodName"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public static string InvokeTheMethod(string className, string methodName, string message)
        {
            Type type1 = typeof(MoodAnalyser);

            try
            {
                ConstructorInfo constructor      = type1.GetConstructor(new[] { typeof(string) });
                object          obj              = MoodAnalyserFactory.CreatedMoodAnalyserUsingParameterizedConstructor(className, methodName, message);
                Assembly        excutingAssambly = Assembly.GetExecutingAssembly();
                Type            type             = excutingAssambly.GetType(className);
                MethodInfo      getMoodMethod    = type.GetMethod(methodName);
                string          msg              = (string)getMoodMethod.Invoke(obj, null);
                return(msg);
            }
            catch (Exception)
            {
                throw new MoodAnalyzerException(MoodAnalyzerException.ExceptionType.INVALID_INPUT, "No Such Method");
            }
        }