// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/Constants.java
// public class Constants {
//     public static final String USE_VAR = "dot_trace";
//     public static final String PATH_VAR = "dot_trace_path";
//     public static final String THRESHOLDS_VAR = "dot_trace_thresholds";
//     public static final String MEASURE_TYPE_VAR = "dot_trace_measure_type";
//     public static final String PROFILE_CHILD_PROCESSES_VAR = "dot_trace_profile_child_processes";
//     public static final String PROCESS_FILTERS_VAR = "dot_trace_process_filters";
//     public static final String SNAPSHOTS_PATH_VAR = "dot_trace_snapshots_path";
// }
// 
// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/MeasureType.java
// public enum MeasureType {
//   SAMPLING("sampling", "Sampling", "Sampling"),
//   TRACING("tracing", "Tracing", ""),
//   LINE_BY_LINE("line-by-line", "Line-by-line", "TracingInject");
// 
//   private final String myValue;
//   private final String myDescription;
//   private final String myId;
// 
//   MeasureType(@NotNull final String value, @NotNull final String description, @NotNull final String id) {
//     myValue = value;
//     myDescription = description;
//     myId = id;
//   }
// 
//   @NotNull
//   public String getValue() {
//     return myValue;
//   }
// 
//   @NotNull
//   public String getDescription() {
//     return myDescription;
//   }
// 
//   @NotNull
//   @Override
//   public String toString() {
//     return myDescription;
//   }
// 
//   @NotNull
//   public String getId() {
//     return myId;
//   }
// }


import com.intellij.openapi.util.text.StringUtil;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jetbrains.buildServer.dotNet.buildRunner.agent.*;
import jetbrains.buildServer.dotTrace.Constants;
import jetbrains.buildServer.dotTrace.MeasureType;
import org.jetbrains.annotations.NotNull;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
  private final RunnerParametersService myParametersService;

  public ProjectGenerator(
    @NotNull final TextParser<List<ProcessFilter>> processFiltersParser,
    @NotNull final XmlDocumentManager documentManager,
    @NotNull final CommandLineArgumentsService commandLineArgumentsService,
    @NotNull final FileService fileService,
    @NotNull final RunnerParametersService parametersService) {
    myProcessFiltersParser = processFiltersParser;
    myDocumentManager = documentManager;
    myCommandLineArgumentsService = commandLineArgumentsService;
    myFileService = fileService;
    myParametersService = parametersService;
  }

  @Override
  @NotNull
  public String create(@NotNull final Context ctx) {
    final Document doc = myDocumentManager.createDocument();
    final Element rootElement = doc.createElement(ROOT_ELEMENT);

    final Element hostParametersElement = doc.createElement(HOST_PARAMETERS_ELEMENT);
    hostParametersElement.setAttribute(TYPE_ATTR, TYPE_LOCAL_HOST_PARAMETERS);
    rootElement.appendChild(hostParametersElement);

    final Element argumentElement = doc.createElement(ARGUMENT_ELEMENT);
    argumentElement.setAttribute(TYPE_ATTR, TYPE_STANDALONE_ARGUMENT);
    argumentElement.appendChild(createSimpleElement(doc, ARGUMENTS_ELEMENT, myCommandLineArgumentsService.createCommandLineString(ctx.getBaseSetup().getArgs())));
    argumentElement.appendChild(createSimpleElement(doc, FILE_NAME_ELEMENT, ctx.getBaseSetup().getToolPath()));

// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/Constants.java
// public class Constants {
//     public static final String USE_VAR = "dot_trace";
//     public static final String PATH_VAR = "dot_trace_path";
//     public static final String THRESHOLDS_VAR = "dot_trace_thresholds";
//     public static final String MEASURE_TYPE_VAR = "dot_trace_measure_type";
//     public static final String PROFILE_CHILD_PROCESSES_VAR = "dot_trace_profile_child_processes";
//     public static final String PROCESS_FILTERS_VAR = "dot_trace_process_filters";
//     public static final String SNAPSHOTS_PATH_VAR = "dot_trace_snapshots_path";
// }
// 
// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/MeasureType.java
// public enum MeasureType {
//   SAMPLING("sampling", "Sampling", "Sampling"),
//   TRACING("tracing", "Tracing", ""),
//   LINE_BY_LINE("line-by-line", "Line-by-line", "TracingInject");
// 
//   private final String myValue;
//   private final String myDescription;
//   private final String myId;
// 
//   MeasureType(@NotNull final String value, @NotNull final String description, @NotNull final String id) {
//     myValue = value;
//     myDescription = description;
//     myId = id;
//   }
// 
//   @NotNull
//   public String getValue() {
//     return myValue;
//   }
// 
//   @NotNull
//   public String getDescription() {
//     return myDescription;
//   }
// 
//   @NotNull
//   @Override
//   public String toString() {
//     return myDescription;
//   }
// 
//   @NotNull
//   public String getId() {
//     return myId;
//   }
// }


// Path: dotTrace-agent/src/main/java/jetbrains/buildServer/dotTrace/agent/ProjectGenerator.java
import com.intellij.openapi.util.text.StringUtil;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jetbrains.buildServer.dotNet.buildRunner.agent.*;
import jetbrains.buildServer.dotTrace.Constants;
import jetbrains.buildServer.dotTrace.MeasureType;
import org.jetbrains.annotations.NotNull;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

  private final RunnerParametersService myParametersService;

  public ProjectGenerator(
    @NotNull final TextParser<List<ProcessFilter>> processFiltersParser,
    @NotNull final XmlDocumentManager documentManager,
    @NotNull final CommandLineArgumentsService commandLineArgumentsService,
    @NotNull final FileService fileService,
    @NotNull final RunnerParametersService parametersService) {
    myProcessFiltersParser = processFiltersParser;
    myDocumentManager = documentManager;
    myCommandLineArgumentsService = commandLineArgumentsService;
    myFileService = fileService;
    myParametersService = parametersService;
  }

  @Override
  @NotNull
  public String create(@NotNull final Context ctx) {
    final Document doc = myDocumentManager.createDocument();
    final Element rootElement = doc.createElement(ROOT_ELEMENT);

    final Element hostParametersElement = doc.createElement(HOST_PARAMETERS_ELEMENT);
    hostParametersElement.setAttribute(TYPE_ATTR, TYPE_LOCAL_HOST_PARAMETERS);
    rootElement.appendChild(hostParametersElement);

    final Element argumentElement = doc.createElement(ARGUMENT_ELEMENT);
    argumentElement.setAttribute(TYPE_ATTR, TYPE_STANDALONE_ARGUMENT);
    argumentElement.appendChild(createSimpleElement(doc, ARGUMENTS_ELEMENT, myCommandLineArgumentsService.createCommandLineString(ctx.getBaseSetup().getArgs())));
    argumentElement.appendChild(createSimpleElement(doc, FILE_NAME_ELEMENT, ctx.getBaseSetup().getToolPath()));

    final String profileChildProcessesStr = myParametersService.tryGetRunnerParameter(Constants.PROFILE_CHILD_PROCESSES_VAR);