コード例 #1
0
ファイル: Program.cs プロジェクト: senendra/Mood_Analyser
        static void Main(string[] args)
        {
            Console.WriteLine("Enter message: ");
            string       message   = Console.ReadLine();
            MoodAnalyser checkmood = new MoodAnalyser(message);
            string       result    = checkmood.AnalyseMood();

            Console.WriteLine(result + " MOOD");
            MoodAnalyserRefection.InvokeAnalyseMood("MyMoodAnalyser.MoodAnalyser", "MoodAnalyser");
        }
コード例 #2
0
 public static string SetField(string message, string fieldName)
 {
     try
     {
         MoodAnalyser moodAnalyser = new MoodAnalyser();
         Type         type         = typeof(MoodAnalyser);
         FieldInfo    field        = type.GetField(fieldName, BindingFlags.Public | BindingFlags.Instance);
         if (message == null)
         {
             throw new MoodAnalysisCustomException(MoodAnalysisCustomException.ExceptionType.EMPTY, "Message should not be null.");
         }
         field.SetValue(moodAnalyser, message);
         return(moodAnalyser.message);
     }
     catch (NullReferenceException)
     {
         throw new MoodAnalysisCustomException(MoodAnalysisCustomException.ExceptionType.NO_SUCH_FIELD, "NO such field found");
     }
 }