public void UnregisterQuestionGroup(QuestionGroupBuilder toUnregister) { QuestionBuilder[] questionGroups = toUnregister.GetQuestionBuilders(); for (int i = 0; i < questionGroups.Length; i++) { sortedQuestionBuilders.Remove(questionGroups[i]); } RefreshNumeration(); }
public QuestionGroupBuilder(QuestionGroup instance, QuestionGroupBuilder questionGroupBuilder) : this() { ParentQuestionGroupBuilder = questionGroupBuilder; if (ParentQuestionGroupBuilder == null) { throw new ArgumentNullException(nameof(questionGroupBuilder)); } Load(instance); }
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); }
public bool RemoveQuestionGroup(QuestionGroupBuilder questionGroupBuilder) { if (questionGroupBuilder == null) { throw new ArgumentNullException(nameof(questionGroupBuilder)); } bool result = questionGroupBuilders.Remove(questionGroupBuilder); if (result) { UnregisterQuestionGroup(questionGroupBuilder); } return(result); }
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); }
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); }
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); }
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(); }
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); }