コード例 #1
0
 public void UnregisterQuestionGroup(QuestionGroupBuilder toUnregister)
 {
     QuestionBuilder[] questionGroups = toUnregister.GetQuestionBuilders();
     for (int i = 0; i < questionGroups.Length; i++)
     {
         sortedQuestionBuilders.Remove(questionGroups[i]);
     }
     RefreshNumeration();
 }
コード例 #2
0
 public QuestionGroupBuilder(QuestionGroup instance, QuestionGroupBuilder questionGroupBuilder) : this()
 {
     ParentQuestionGroupBuilder = questionGroupBuilder;
     if (ParentQuestionGroupBuilder == null)
     {
         throw new ArgumentNullException(nameof(questionGroupBuilder));
     }
     Load(instance);
 }
コード例 #3
0
        public QuestionGroupBuilder AddQuestionGroup(QuestionGroup questionGroup)
        {
            if (questionGroup == null)
            {
                throw new ArgumentNullException(nameof(questionGroup));
            }
            QuestionGroupBuilder result = new QuestionGroupBuilder((QuestionGroup)questionGroup.Clone(), this);

            questionGroupBuilders.Add(result);
            RegisterQuestionGroup(result);
            return(result);
        }
コード例 #4
0
        public bool RemoveQuestionGroup(QuestionGroupBuilder questionGroupBuilder)
        {
            if (questionGroupBuilder == null)
            {
                throw new ArgumentNullException(nameof(questionGroupBuilder));
            }
            bool result = questionGroupBuilders.Remove(questionGroupBuilder);

            if (result)
            {
                UnregisterQuestionGroup(questionGroupBuilder);
            }
            return(result);
        }
コード例 #5
0
        public QuestionGroupBuilder AddQuestionGroup(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            QuestionGroup questionGroup = new QuestionGroup()
            {
                QuestionGroupName = name
            };
            QuestionGroupBuilder result = new QuestionGroupBuilder(questionGroup, this);

            questionGroupBuilders.Add(result);
            return(result);
        }
コード例 #6
0
 public QuestionGroupBuilder AddQuestionGroup(QuestionGroupBuilder questionGroupBuilder)
 {
     if (questionGroupBuilder == null)
     {
         throw new ArgumentNullException(nameof(questionGroupBuilder));
     }
     if (GetQuestionGroupBuilders().Contains(questionGroupBuilder))
     {
         throw new Exception("This builder was already assigned to the parent builder.");
     }
     questionGroupBuilders.Add(questionGroupBuilder);
     RegisterQuestionGroup(questionGroupBuilder);
     questionGroupBuilder.GetType().GetProperty("ParentTicketBuilder").SetValue(questionGroupBuilder, this);
     questionGroupBuilder.GetType().GetProperty("ParentQuestionGroupBuilder").SetValue(questionGroupBuilder, null);
     return(questionGroupBuilder);
 }
コード例 #7
0
 public QuestionGroupBuilder AddQuestionGroup(QuestionGroupBuilder questionGroupBuilder)
 {
     if (questionGroupBuilder == null)
     {
         throw new ArgumentNullException(nameof(questionGroupBuilder));
     }
     if (GetParentTicketBuilder().GetQuestionGroupBuilders().Contains(questionGroupBuilder))
     {
         throw new Exception("This builder was already assigned to the parent builder.");
     }
     questionGroupBuilders.Add(questionGroupBuilder);
     GetParentTicketBuilder().RegisterQuestionGroup(questionGroupBuilder);
     questionGroupBuilder.ParentQuestionGroupBuilder = this;
     questionGroupBuilder.ParentTicketBuilder        = null;
     return(questionGroupBuilder);
 }
コード例 #8
0
 public void RegisterQuestionGroup(QuestionGroupBuilder toRegister)
 {
     if (!GetQuestionGroupBuilders().Contains(toRegister))
     {
         throw new ArgumentException();
     }
     if (toRegister == null)
     {
         throw new ArgumentNullException(nameof(toRegister));
     }
     QuestionBuilder[] questionBuilders = toRegister.GetQuestionBuilders();
     for (int i = 0; i < questionBuilders.Length; i++)
     {
         if (!sortedQuestionBuilders.Contains(questionBuilders[i]))
         {
             sortedQuestionBuilders.Add(questionBuilders[i]);
         }
     }
     RefreshNumeration();
 }
コード例 #9
0
        public void SetParent(QuestionGroupBuilder questionGroupBuilder)
        {
            if (questionGroupBuilder == null)
            {
                throw new ArgumentNullException(nameof(questionGroupBuilder));
            }
            TicketBuilder ticketBuilder = GetParentTicketBuilder();

            if (questionGroupBuilder.GetParentTicketBuilder() != ticketBuilder)
            {
                throw new ArgumentException();
            }
            if (ReferenceEquals(ParentQuestionGroupBuilder, questionGroupBuilder))
            {
                return;
            }
            QuestionBuilder[] questionBuilders = ticketBuilder.SortedQuestionBuilders.ToArray();
            ParentQuestionGroupBuilder?.questionGroupBuilders.Remove(this);
            ParentTicketBuilder?.RemoveQuestionGroup(this);
            questionGroupBuilder.AddQuestionGroup(this);
            ticketBuilder.SetNumeration(questionBuilders);
        }