/// <summary> /// Returns an instance of GetAlgorithmModelView representing the instance of Algorithm. /// </summary> /// <param name="restrictionAlgorithm">RestrictionAlgorithm that matches the corresponding Algorithm.</param> /// <returns>GetAlgorithmModelView representing the instance of Algorithm.</returns> public GetAlgorithmModelView getAlgorithm(RestrictionAlgorithm restrictionAlgorithm) { //this throws ArgumentOutOfRangeException if the element is not recognized by the factory Algorithm algorithm = new AlgorithmFactory().createAlgorithm(restrictionAlgorithm); return(AlgorithmModelViewService.fromEntity(algorithm)); }
/// <summary> /// Returns an instance of GetAllInputsModelView representing the Algorithm's required inputs. /// </summary> /// <param name="restrictionAlgorithm">RestrictionAlgorithm that matches the corresponding Algorithm.</param> /// <returns>GetAllInputsModelView representing the Algorithm's required inputs. </returns> /// <exception cref="ResourceNotFoundException">Thrown when the Algorithm has no required inputs.</exception> public GetAllInputsModelView getAlgorithmRequiredInputs(RestrictionAlgorithm restrictionAlgorithm) { Algorithm algorithm = new AlgorithmFactory().createAlgorithm(restrictionAlgorithm); List <Input> requiredInputs = algorithm.getRequiredInputs(); if (!requiredInputs.Any()) { throw new ResourceNotFoundException(NO_REQUIRED_INPUTS); } return(InputModelViewService.fromCollection(requiredInputs)); }
/// <summary> /// Creates an Algorithm using the data received by parameter /// </summary> /// <param name="reAlg">Type of algorithm to create</param> /// <returns>instance of Algorithm</returns> public Algorithm createAlgorithm(RestrictionAlgorithm reAlg) { Algorithm algorithm; switch (reAlg) { case RestrictionAlgorithm.WIDTH_PERCENTAGE_ALGORITHM: algorithm = new WidthPercentageAlgorithm(); break; case RestrictionAlgorithm.SAME_MATERIAL_AND_FINISH_ALGORITHM: algorithm = new SameMaterialAndFinishAlgorithm(); break; default: throw new ArgumentOutOfRangeException(ALGORITHM_DOES_NOT_EXIST_MESSAGE); } return(algorithm); }