Changeset 15900


Ignore:
Timestamp:
04/13/18 10:25:22 (19 months ago)
Author:
fbaching
Message:

#2911: remove c# 6.0 string interpolation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2911_TSQLSymbolicExpressionFormatter/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/TSQLExpressionFormatter.cs

    r15881 r15900  
    8383
    8484      //Generate comment and instructions
    85       strBuilder.Append($"-- generated. created function can be used like 'SELECT dbo.REGRESSIONMODEL(");
     85      strBuilder.Append("-- generated. created function can be used like 'SELECT dbo.REGRESSIONMODEL(");
    8686      strBuilder.Append(string.Join(", ", sortedVarcharIdentifiers));
    8787      if (varcharVarNames.Any() && floatVarNames.Any())
     
    8989      strBuilder.Append(string.Join(", ", sortedFloatIdentifiers));
    9090      strBuilder.AppendLine(")'");
    91       strBuilder.AppendLine($"-- use the expression after the RETURN statement if you want to incorporate the model in a query without creating a function.");
     91      strBuilder.AppendLine("-- use the expression after the RETURN statement if you want to incorporate the model in a query without creating a function.");
    9292
    9393      //Generate function header
    94       strBuilder.Append($"CREATE FUNCTION dbo.REGRESSIONMODEL(");
    95       strBuilder.Append(string.Join(", ", sortedVarcharIdentifiers.Select(n => $"{n} NVARCHAR(max)")));
     94      strBuilder.Append("CREATE FUNCTION dbo.REGRESSIONMODEL(");
     95      strBuilder.Append(string.Join(", ", sortedVarcharIdentifiers.Select(n => String.Format("{0} NVARCHAR(max)",n))));
    9696      if (varcharVarNames.Any() && floatVarNames.Any())
    9797        strBuilder.Append(",");
    98       strBuilder.Append(string.Join(", ", sortedFloatIdentifiers.Select(n => $"{n} FLOAT")));
     98      strBuilder.Append(string.Join(", ", sortedFloatIdentifiers.Select(n => String.Format("{0} FLOAT",n))));
    9999      strBuilder.AppendLine(")");
    100100
     
    104104
    105105      //add variable declaration for convenience
    106       strBuilder.AppendLineIndented(1, $"-- added variable declaration for convenience");
     106      strBuilder.AppendLineIndented(1, "-- added variable declaration for convenience");
    107107      foreach (var name in sortedVarcharIdentifiers)
    108         strBuilder.AppendLineIndented(1, $"-- DECLARE {name} NVARCHAR(max) = ''");
     108        strBuilder.AppendLineIndented(1, String.Format("-- DECLARE {0} NVARCHAR(max) = ''", name));
    109109      foreach (var name in sortedFloatIdentifiers)
    110         strBuilder.AppendLineIndented(1, $"-- DECLARE {name} FLOAT = 0.0");
    111       strBuilder.AppendLineIndented(1, $"-- SELECT");
     110        strBuilder.AppendLineIndented(1, String.Format("-- DECLARE {0} FLOAT = 0.0", name));
     111      strBuilder.AppendLineIndented(1, "-- SELECT");
    112112      strBuilder.AppendLine("RETURN ");
    113113    }
     
    142142          FormatOperator(level, node, "OR", strBuilder);
    143143        } else if (node.Symbol is Xor) {
    144           throw new NotSupportedException($"Symbol {node.Symbol.GetType().Name} not yet supported.");
     144          throw new NotSupportedException(String.Format("Symbol {0} not yet supported.", node.Symbol.GetType().Name));
    145145        } else if (node.Symbol is Sine) {
    146146          FormatFunction(level, node, "SIN", strBuilder);
     
    172172        } else if (node.Symbol is BinaryFactorVariable) {
    173173          var binFactorNode = node as BinaryFactorVariableTreeNode;
    174           throw new NotSupportedException($"Symbol {node.Symbol.GetType().Name} not yet supported.");
     174          throw new NotSupportedException(String.Format("Symbol {0} not yet supported.", node.Symbol.GetType().Name));
    175175        } else {
    176176          throw new NotSupportedException("Formatting of symbol: " + node.Symbol + " not supported for TSQL symbolic expression tree formatter.");
     
    199199          strBuilder.Append(" + ");
    200200      }
    201       strBuilder.Append($") / {node.Subtrees.Count()}");
     201      strBuilder.AppendFormat(") / {0}", node.Subtrees.Count());
    202202    }
    203203
    204204    private string VariableName2Identifier(string variableName) {
    205       return $"@{variableName.Replace(' ', '_')}";
     205      return "@"+variableName.Replace(' ', '_');
    206206    }
    207207
    208208    private void GenerateFooter(StringBuilder strBuilder) {
    209       strBuilder.AppendLine($"{Environment.NewLine}END");
     209      strBuilder.Append(Environment.NewLine);
     210      strBuilder.AppendLine("END");
    210211    }
    211212
     
    265266
    266267    private void FormatFactor(int level, FactorVariableTreeNode node, StringBuilder strBuilder) {
    267       strBuilder.AppendLine($"( ");
    268       strBuilder.AppendLineIndented(level + 1, $"CASE {VariableName2Identifier(node.VariableName)}");
     268      strBuilder.AppendLine("( ");
     269      strBuilder.AppendLineIndented(level + 1, String.Format("CASE {0}", VariableName2Identifier(node.VariableName)));
    269270      foreach (var name in node.Symbol.GetVariableValues(node.VariableName)) {
    270         strBuilder.AppendLineIndented(level + 2, $"WHEN '{name}' THEN {node.GetValue(name).ToString(CultureInfo.InvariantCulture)}");
     271        strBuilder.AppendLineIndented(level + 2, String.Format("WHEN '{0}' THEN {1}", name, node.GetValue(name).ToString(CultureInfo.InvariantCulture)));
    271272      }
    272273      strBuilder.AppendLineIndented(level + 1, "ELSE NULL END");
Note: See TracChangeset for help on using the changeset viewer.