All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.reprezen.genflow.rapidml.csharp.helpers.SnippetHelper Maven / Gradle / Ivy

There is a newer version: 1.4.2
Show newest version
package com.reprezen.genflow.rapidml.csharp.helpers;

import com.reprezen.genflow.rapidml.csharp.Config;
import org.eclipse.xtend2.lib.StringConcatenation;

@SuppressWarnings("all")
public class SnippetHelper {
  private final Config.Framework framework;
  
  public SnippetHelper(final Config config) {
    Config.Framework _framework = config.getFramework();
    this.framework = _framework;
  }
  
  public String routePrefix() {
    String _switchResult = null;
    final Config.Framework framework = this.framework;
    if (framework != null) {
      switch (framework) {
        case ASP_DOTNET_CORE_2_0_MVC:
          _switchResult = "Route";
          break;
        case ASP_DOTNET_WEBAPI_2:
          _switchResult = "RoutePrefix";
          break;
        default:
          break;
      }
    }
    return _switchResult;
  }
  
  public String apiController() {
    String _switchResult = null;
    final Config.Framework framework = this.framework;
    if (framework != null) {
      switch (framework) {
        case ASP_DOTNET_CORE_2_0_MVC:
          _switchResult = "Controller";
          break;
        case ASP_DOTNET_WEBAPI_2:
          _switchResult = "ApiController";
          break;
        default:
          break;
      }
    }
    return _switchResult;
  }
  
  public String delegateVar() {
    String _switchResult = null;
    final Config.Framework framework = this.framework;
    if (framework != null) {
      switch (framework) {
        case ASP_DOTNET_CORE_2_0_MVC:
          _switchResult = "responder";
          break;
        case ASP_DOTNET_WEBAPI_2:
          _switchResult = "responsePayload";
          break;
        default:
          break;
      }
    }
    return _switchResult;
  }
  
  public CharSequence delegateVarDecl(final String valueType) {
    CharSequence _switchResult = null;
    final Config.Framework framework = this.framework;
    if (framework != null) {
      switch (framework) {
        case ASP_DOTNET_CORE_2_0_MVC:
          CharSequence _xblockexpression = null;
          {
            String _xifexpression = null;
            if ((valueType != null)) {
              StringConcatenation _builder = new StringConcatenation();
              _builder.append("Responder<");
              _builder.append(valueType, "");
              _builder.append(">");
              _xifexpression = _builder.toString();
            } else {
              _xifexpression = "VoidResponder";
            }
            final String responderType = _xifexpression;
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append(responderType, "");
            _builder_1.append(" responder;");
            _xblockexpression = _builder_1;
          }
          _switchResult = _xblockexpression;
          break;
        case ASP_DOTNET_WEBAPI_2:
          CharSequence _xifexpression = null;
          if ((valueType != null)) {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append(valueType, "");
            _builder.append(" responsePayload;");
            _xifexpression = _builder;
          }
          _switchResult = _xifexpression;
          break;
        default:
          break;
      }
    }
    return _switchResult;
  }
  
  public String postProcessExtraCond() {
    String _switchResult = null;
    final Config.Framework framework = this.framework;
    if (framework != null) {
      switch (framework) {
        case ASP_DOTNET_CORE_2_0_MVC:
          _switchResult = " && responder.IsNormal()";
          break;
        case ASP_DOTNET_WEBAPI_2:
          _switchResult = "";
          break;
        default:
          break;
      }
    }
    return _switchResult;
  }
  
  public String delegateReturn(final boolean notVoid) {
    String _xifexpression = null;
    if (notVoid) {
      String _switchResult = null;
      final Config.Framework framework = this.framework;
      if (framework != null) {
        switch (framework) {
          case ASP_DOTNET_CORE_2_0_MVC:
            _switchResult = "return responder.GetResult();";
            break;
          case ASP_DOTNET_WEBAPI_2:
            _switchResult = "return responsePayload;";
            break;
          default:
            break;
        }
      }
      _xifexpression = _switchResult;
    } else {
      String _switchResult_1 = null;
      final Config.Framework framework_1 = this.framework;
      if (framework_1 != null) {
        switch (framework_1) {
          case ASP_DOTNET_CORE_2_0_MVC:
            _switchResult_1 = "return responder.getResult();";
            break;
          case ASP_DOTNET_WEBAPI_2:
            _switchResult_1 = "";
            break;
          default:
            break;
        }
      }
      _xifexpression = _switchResult_1;
    }
    return _xifexpression;
  }
  
  public CharSequence methodResponseType(final String valueType) {
    CharSequence _switchResult = null;
    final Config.Framework framework = this.framework;
    if (framework != null) {
      switch (framework) {
        case ASP_DOTNET_CORE_2_0_MVC:
          StringConcatenation _builder = new StringConcatenation();
          _builder.append("Result<");
          _builder.append(valueType, "");
          _builder.append(">");
          _switchResult = _builder;
          break;
        case ASP_DOTNET_WEBAPI_2:
          _switchResult = valueType;
          break;
        default:
          break;
      }
    }
    return _switchResult;
  }
  
  public CharSequence delegateType(final String valueType) {
    CharSequence _switchResult = null;
    final Config.Framework framework = this.framework;
    if (framework != null) {
      switch (framework) {
        case ASP_DOTNET_CORE_2_0_MVC:
          StringConcatenation _builder = new StringConcatenation();
          _builder.append("Responder<");
          _builder.append(valueType, "");
          _builder.append(">");
          _switchResult = _builder;
          break;
        case ASP_DOTNET_WEBAPI_2:
          _switchResult = valueType;
          break;
        default:
          break;
      }
    }
    return _switchResult;
  }
  
  public String voidMethodResponseType() {
    String _switchResult = null;
    final Config.Framework framework = this.framework;
    if (framework != null) {
      switch (framework) {
        case ASP_DOTNET_CORE_2_0_MVC:
          _switchResult = "VoidResult";
          break;
        case ASP_DOTNET_WEBAPI_2:
          _switchResult = "void";
          break;
        default:
          break;
      }
    }
    return _switchResult;
  }
  
  public String voidDelegateType() {
    String _switchResult = null;
    final Config.Framework framework = this.framework;
    if (framework != null) {
      switch (framework) {
        case ASP_DOTNET_CORE_2_0_MVC:
          _switchResult = "VoidResponder";
          break;
        case ASP_DOTNET_WEBAPI_2:
          _switchResult = "void";
          break;
        default:
          break;
      }
    }
    return _switchResult;
  }
  
  public String responseValue() {
    String _switchResult = null;
    final Config.Framework framework = this.framework;
    if (framework != null) {
      switch (framework) {
        case ASP_DOTNET_CORE_2_0_MVC:
          _switchResult = "responder.GetResult().GetValue()";
          break;
        case ASP_DOTNET_WEBAPI_2:
          _switchResult = "responsePayload";
          break;
        default:
          break;
      }
    }
    return _switchResult;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy