public void UpdateBitOptions(IMatrixTemplate matrixTemplate) { List <IBitOption> resultBitOptions = new List <IBitOption>(); foreach (IVariableColumnSignature variableOptionSignature in matrixTemplate.VariableColumnSignatures) { if (matrixTemplate.MatrixVariableOptionTemplate is ListMatrixVariableOptionTemplate) { foreach (IOptionPossibleValue optionPossibleValue in (matrixTemplate.MatrixVariableOptionTemplate as ListMatrixVariableOptionTemplate) .OptionPossibleValues) { IBitOption bitOption = _container.Resolve <IBitOption>(MatrixKeys.LIST_MATRIX_BIT_OPTION); ((ListMatrixBitOption)bitOption).OptionPossibleValue = optionPossibleValue; bitOption.VariableColumnSignature = variableOptionSignature; IBitOption existing = matrixTemplate.ResultBitOptions.FirstOrDefault((option => option.IsBitOptionEqual(bitOption))); resultBitOptions.Add(existing ?? bitOption); } } else if (matrixTemplate.MatrixVariableOptionTemplate is BoolMatrixVariableOptionTemplate) { IBitOption bitOption = _container.Resolve <IBitOption>(MatrixKeys.BOOL_MATRIX_BIT_OPTION); bitOption.VariableColumnSignature = variableOptionSignature; IBitOption existing = matrixTemplate.ResultBitOptions.FirstOrDefault((option => option.IsBitOptionEqual(bitOption))); resultBitOptions.Add(existing ?? bitOption); } } matrixTemplate.ResultBitOptions = resultBitOptions; }
public bool IsBitOptionEqual(IBitOption comparingBitOption) { if (!(comparingBitOption is ListMatrixBitOption)) { return(false); } return((comparingBitOption.VariableColumnSignature == VariableColumnSignature) && (((ListMatrixBitOption)comparingBitOption).OptionPossibleValue == OptionPossibleValue) && (comparingBitOption.StrongName == StrongName)); }
public bool IsBitOptionEqual(IBitOption comparingBitOption) { return(comparingBitOption.VariableColumnSignature == VariableColumnSignature && (comparingBitOption.StrongName == StrongName)); }