Beispiel #1
0
        /// <summary>
        /// Доопределяем метод проверки эквивалентности.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            if (obj == null || !(obj is ExerciseTypeDate) || !base.Equals(obj))
            {
                return(false);
            }

            ExerciseTypeDate target = (ExerciseTypeDate)obj;

            return(target.testType == this.testType);
        }
        /// <summary>
        /// Создание экзепляра типа по XmlNode.
        /// </summary>
        /// <param name="xmlNode"></param>
        /// <returns></returns>
        public static ExerciseType CreateFromXml(XmlNode xmlNode)
        {
            ExerciseType result = new ExerciseType();
            XmlAttribute attr;

            attr = xmlNode.Attributes[xmlFieldTrainType];

            if (attr != null && !string.IsNullOrEmpty(attr.Value))
            {
                TrainType baseType = (TrainType)Enum.Parse(typeof(TrainType), attr.Value);

                switch (baseType)
                {
                case TrainType.Date:
                    result = new ExerciseTypeDate();
                    break;

                case TrainType.NumericAlphabet:
                    result = new ExerciseTypeNumericAlphaget();
                    break;

                case TrainType.Impression:
                    result = new ExerciseTypeImpression();
                    break;

                case TrainType.Calculate:
                    result = new ExerciseTypeCalculate();
                    break;

                case TrainType.RecentMemory:
                    result = new ExerciseTypeStepanovAndRecentMemory(TrainType.RecentMemory);
                    break;

                case TrainType.Stepanov:
                    result = new ExerciseTypeStepanovAndRecentMemory(TrainType.Stepanov);
                    break;

                case TrainType.NumberGenerator:
                    result = new ExerciseTypeNumberGenerator();
                    break;

                case TrainType.SecondArrowAttention:
                    result = new ExerciseTypeSecondArrowAttention();
                    break;

                case TrainType.Strup:
                    result = new ExerciseTypeStrup();
                    break;

                case TrainType.NetTrain:
                    result = new ExerciseTypeNetTrain();
                    break;

                case TrainType.InterruptionReading:
                    result = new ExerciseTypeInterruptionReading();
                    break;

                default:
                    result = new ExerciseType(baseType);
                    break;
                }

                result.LoadTypeAttributes(xmlNode);
            }

            return(result);
        }