public static OperationViewModel GetOperation(OperationInfoViewModel info) { var input = info.Input.Select(i => new ConnectorViewModel { Title = i }); switch (info.Type) { case OperationType.Expression: return(new ExpressionOperationViewModel { Title = info.Title, Output = new ConnectorViewModel(), Operation = info.Operation, Expression = "1 + sin {a} + cos {b}" }); case OperationType.Calculator: return(new CalculatorOperationViewModel { Title = info.Title, Operation = info.Operation, }); case OperationType.Expando: { var o = new ExpandoOperationViewModel { MaxInput = info.MaxInput, MinInput = info.MinInput, Title = info.Title, Output = new ConnectorViewModel(), Operation = info.Operation }; o.Input.AddRange(input); return(o); } default: { var op = new OperationViewModel { Title = info.Title, Output = new ConnectorViewModel(), Operation = info.Operation }; op.Input.AddRange(input); return(op); } } }
public static OperationViewModel GetOperation(OperationInfoViewModel info) { // ConnectorViewModel 의 정체를 확인하자 // ConnectorViewModel 로 변환하는 구문 OperationInfoViewModel info -> ConnectorViewModel input var input = info.Input.Select(i => new ConnectorViewModel { Title = i }); if (info.Type == OperationType.Expression) // method 타입이 custom 이면 Expression { return(new ExpressionOperationViewModel { Title = info.Title, Output = new ConnectorViewModel(), Operation = info.Operation, Expression = "1 + sin {a} + cos {b}" }); } else if (info.Type == OperationType.Expando) { var o = new ExpandoOperationViewModel { MaxInput = info.MaxInput, MinInput = info.MinInput, Title = info.Title, Output = new ConnectorViewModel(), Operation = info.Operation }; o.Input.AddRange(input); return(o); } var op = new OperationViewModel { Title = info.Title, Output = new ConnectorViewModel(), Operation = info.Operation }; op.Input.AddRange(input); return(op); }