예제 #1
0
        /// <summary>
        /// 根据题目类型,构建一个答案项反序化处理器
        /// </summary>
        /// <param name="questionType"></param>
        /// <returns></returns>
        private AnswerDeserializeHandler CreateDeserializeHandler(QuestionType questionType)
        {
            AnswerDeserializeHandler _handler = default(AnswerDeserializeHandler);

            switch (questionType)
            {
            case QuestionType.SINGLE_CHOICE:
                _handler = new SingleChoiceDeserializeHandler();
                break;

            case QuestionType.MULTIPLE_CHOICE:
                _handler = new MultipleChoiceDeserializeHandler();
                break;

            case QuestionType.TRUE_OR_FALSE:
                _handler = new TrueOrFalseDeserializeHandler();
                break;

            case QuestionType.GAP_FILLING:
                _handler = new GapFillingDeserializeHandler();
                break;

            case QuestionType.ESSAY_QUESTION:
                _handler = new EssayQuestionDeserializeHandler();
                break;
            }

            return(_handler);
        }
예제 #2
0
 /// <summary>
 /// 初始化一个<see cref="AnswerDeserializeContext"/>对象实例
 /// </summary>
 /// <param name="questionType">需要反序列化的答案项所属题目的类型</param>
 public AnswerDeserializeContext(QuestionType questionType)
 {
     handler = CreateDeserializeHandler(questionType);
 }
예제 #3
0
        /// <summary>
        /// 初始化一个<see cref="AnswerDeserializeContext"/>对象实例
        /// </summary>
        /// <param name="questionType">需要反序列化的答案项所属题目的类型(枚举:<see cref="QuestionType"/>)</param>
        public AnswerDeserializeContext(int questionType)
        {
            QuestionType type = (QuestionType)Enum.Parse(typeof(QuestionType), questionType.ToString());

            handler = CreateDeserializeHandler(type);
        }