Fix interview step being passed by reference instead of by value when getting them from the definitions, breaking selectors for instance
This commit is contained in:
parent
0984f50fff
commit
91652eb8fb
1 changed files with 50 additions and 1 deletions
|
@ -52,14 +52,30 @@ public class ReferencedInterviewStep
|
||||||
[JsonProperty("after-reference-step")]
|
[JsonProperty("after-reference-step")]
|
||||||
public InterviewStep afterReferenceStep;
|
public InterviewStep afterReferenceStep;
|
||||||
|
|
||||||
|
public ReferencedInterviewStep() { }
|
||||||
|
|
||||||
|
public ReferencedInterviewStep(ReferencedInterviewStep other)
|
||||||
|
{
|
||||||
|
id = other.id;
|
||||||
|
buttonStyle = other.buttonStyle;
|
||||||
|
selectorDescription = other.selectorDescription;
|
||||||
|
|
||||||
|
if (other.afterReferenceStep != null)
|
||||||
|
{
|
||||||
|
afterReferenceStep = new InterviewStep(other.afterReferenceStep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool TryGetReferencedStep(Dictionary<string, InterviewStep> definitions, out InterviewStep step, bool ignoreReferenceParameters = false)
|
public bool TryGetReferencedStep(Dictionary<string, InterviewStep> definitions, out InterviewStep step, bool ignoreReferenceParameters = false)
|
||||||
{
|
{
|
||||||
if (!definitions.TryGetValue(id, out step))
|
if (!definitions.TryGetValue(id, out InterviewStep tempStep))
|
||||||
{
|
{
|
||||||
Logger.Error("Could not find referenced step '" + id + "' in interview.");
|
Logger.Error("Could not find referenced step '" + id + "' in interview.");
|
||||||
|
step = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
step = new InterviewStep(tempStep);
|
||||||
if (!ignoreReferenceParameters)
|
if (!ignoreReferenceParameters)
|
||||||
{
|
{
|
||||||
step.buttonStyle = buttonStyle;
|
step.buttonStyle = buttonStyle;
|
||||||
|
@ -159,6 +175,39 @@ public class InterviewStep
|
||||||
[JsonProperty("after-reference-step")]
|
[JsonProperty("after-reference-step")]
|
||||||
public InterviewStep afterReferenceStep = null;
|
public InterviewStep afterReferenceStep = null;
|
||||||
|
|
||||||
|
public InterviewStep() { }
|
||||||
|
|
||||||
|
public InterviewStep(InterviewStep other)
|
||||||
|
{
|
||||||
|
heading = other.heading;
|
||||||
|
message = other.message;
|
||||||
|
stepType = other.stepType;
|
||||||
|
color = other.color;
|
||||||
|
summaryField = other.summaryField;
|
||||||
|
buttonStyle = other.buttonStyle;
|
||||||
|
selectorPlaceholder = other.selectorPlaceholder;
|
||||||
|
selectorDescription = other.selectorDescription;
|
||||||
|
maxLength = other.maxLength;
|
||||||
|
minLength = other.minLength;
|
||||||
|
addSummary = other.addSummary;
|
||||||
|
answerDelimiter = other.answerDelimiter;
|
||||||
|
messageID = other.messageID;
|
||||||
|
answer = other.answer;
|
||||||
|
answerID = other.answerID;
|
||||||
|
relatedMessageIDs = other.relatedMessageIDs;
|
||||||
|
afterReferenceStep = other.afterReferenceStep;
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string, InterviewStep> childStep in other.steps ?? [])
|
||||||
|
{
|
||||||
|
steps.Add(childStep.Key, new InterviewStep(childStep.Value));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string, ReferencedInterviewStep> reference in other.references ?? [])
|
||||||
|
{
|
||||||
|
references.Add(reference.Key, new ReferencedInterviewStep(reference.Value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool TryGetCurrentStep(out InterviewStep currentStep)
|
public bool TryGetCurrentStep(out InterviewStep currentStep)
|
||||||
{
|
{
|
||||||
bool result = TryGetTakenSteps(out List<InterviewStep> previousSteps);
|
bool result = TryGetTakenSteps(out List<InterviewStep> previousSteps);
|
||||||
|
|
Loading…
Add table
Reference in a new issue