Beispiel #1
0
 /// <summary>
 /// 获取动态方法体
 /// </summary>
 /// <returns></returns>
 public string GetScript(bool isStatic = true)
 {
     if (_info != null)
     {
         MethodTemplate template = new MethodTemplate(_info);
         return(template.Body(_text).Builder());
     }
     else
     {
         StringBuilder sb = new StringBuilder();
         sb.Append($"public ");
         if (isStatic)
         {
             sb.Append($"static ");
         }
         if (_return_type == null)
         {
             sb.Append("void");
         }
         else
         {
             sb.Append(_return_type.Name);
         }
         if (_method == null)
         {
             sb.Append($" {_method_name}");
         }
         else
         {
             sb.Append(" " + _method);
         }
         sb.Append("(");
         if (_parameters.Count > 0)
         {
             sb.Append($"{TypeReverser.Get(_parameters[0].Key)} {_parameters[0].Value}");
             for (int i = 1; i < _parameters.Count; i++)
             {
                 sb.Append($",{TypeReverser.Get(_parameters[i].Key)} {_parameters[i].Value}");
             }
         }
         sb.Append("){");
         sb.Append(_text);
         sb.Append("}");
         return(sb.ToString());
     }
 }
Beispiel #2
0
 public MethodBuilder()
 {
     ClassTemplate  = new ClassBuilder();
     MethodTemplate = new MethodTemplate();
 }
Beispiel #3
0
 /// <summary>
 /// 重置方法模板
 /// </summary>
 /// <param name="methodTemplate">方法模板</param>
 /// <returns></returns>
 public virtual MethodBuilder ResetBodyTemplate(MethodTemplate methodTemplate)
 {
     MethodTemplate = methodTemplate;
     return(this);
 }
Beispiel #4
0
 public MethodBuilder()
 {
     ClassTemplate  = new OopBuilder();
     MethodTemplate = new MethodTemplate();
     Complier       = new OopComplier();
 }