// ReSharper disable once CognitiveComplexity public Variable AddNew() { //TODO Probably a better way to do this Variable newVar; switch (VariableTypeToCreate) { case VariableType.Independent: Type ivType = supportedIndependentTypes[DataTypeToCreate]; IndependentVariable newIv = Activator.CreateInstance(ivType) as IndependentVariable; UpdateSerializedListsWith(newIv); newVar = newIv; break; case VariableType.Dependent: Type dvType = supportedDependentTypes[DataTypeToCreate]; DependentVariable newDv = Activator.CreateInstance(dvType) as DependentVariable; UpdateSerializedListsWith(newDv); newVar = newDv; break; case VariableType.ChooseType: newVar = null; break; case VariableType.Participant: Type pvType = supportedParticipantTypes[DataTypeToCreate]; ParticipantVariable newPv = Activator.CreateInstance(pvType) as ParticipantVariable; UpdateSerializedListsWith(newPv); newVar = newPv; break; default: throw new ArgumentOutOfRangeException(nameof(VariableTypeToCreate), DataTypeToCreate, null); } DataTypeToCreate = SupportedDataType.ChooseType; VariableTypeToCreate = VariableType.ChooseType; return(newVar); }
void SortIVs(IndependentVariable independentVariable, IndependentVariables container) { switch (independentVariable.MixingType) { case VariableMixingType.Balanced: container.Balanced.Add(independentVariable); break; case VariableMixingType.Looped: container.Looped.Add(independentVariable); break; case VariableMixingType.EvenProbability: case VariableMixingType.CustomProbability: container.Probability.Add(independentVariable); break; default: throw new ArgumentOutOfRangeException(); } }