public override int CompareTo(QuestionContentPart other)
        {
            if (this == other)
            {
                return(0);
            }

            if (!(other is QuestionContentPart))
            {
                return(-1);
            }

            QuestionFractionPart otherPart = other as QuestionFractionPart;
            int retDenominator             = this.denominator.CompareTo(otherPart.Denominator);
            int retNumertor = this.numerator.CompareTo(otherPart.Numerator);

            if (retDenominator == 0 && retNumertor == 0)
            {
                if (this.withPart != null &&
                    otherPart.WithPart != null)
                {
                    int retWithPart = this.withPart.CompareTo(otherPart.WithPart);
                    return(retWithPart);
                }
                else if (this.withPart != null ||
                         otherPart.WithPart != null)
                {
                    return(-1);
                }
                return(0);
            }

            return(-1);
        }
        public override object Clone()
        {
            QuestionFractionPart newPart = new QuestionFractionPart();

            newPart.Id          = this.Id;
            newPart.Numerator   = this.Numerator.Clone() as QuestionContent;
            newPart.WithPart    = this.WithPart.Clone() as QuestionContent;
            newPart.Denominator = this.Denominator.Clone() as QuestionContent;

            return(newPart);
        }
Esempio n. 3
0
        internal static IEnumerable <QuestionOption> CreateFractionOption(QuestionContent numerator, QuestionContent denominator)
        {
            QuestionOption       option       = new QuestionOption();
            QuestionFractionPart fractionPart = new QuestionFractionPart();

            fractionPart.Denominator     = denominator;
            fractionPart.Numerator       = numerator;
            option.OptionContent.Content = fractionPart.PlaceHolder;
            option.OptionContent.QuestionPartCollection.Add(fractionPart);

            yield return(option);
        }