Exemple #1
0
        public static string MethodHeader(int depth, AccessModifier scope, MethodModifier modifier, Type returnType, string name, Dictionary <string, Type> parameters)
        {
            var header      = string.Empty;
            var keys        = parameters.Keys.ToListPooled();
            var values      = parameters.Values.ToListPooled();
            var _parameters = string.Empty;

            for (int i = 0; i < parameters.Count; i++)
            {
                _parameters += ((i > 0) ?" " : string.Empty);
                _parameters += values[i].CSharpName() + " ";
                _parameters += Patcher.LegalVariableName(keys[i], false) + ((i != parameters.Count - 1) ? "," : string.Empty);
            }

            header += "\n";
            header += CodeBuilder.Indent(depth) + Patcher.AddLowerUpperNeighboringSpaces(scope.ToString()).ToLower() +
                      " " + ((modifier == MethodModifier.None) ? string.Empty : modifier.ToString().ToLower()) +
                      ((modifier == MethodModifier.None) ? string.Empty : " ") +
                      (returnType == null || returnType == typeof(Void) ? typeof(void).CSharpName() : Ludiq.CSharpNameUtility.CSharpName(returnType)) + " " +
                      name + "(" + _parameters + ")";

            return(header);
        }
Exemple #2
0
 public static string Scope(AccessModifier modifier)
 {
     return(Patcher.AddLowerUpperNeighboringSpaces(modifier.ToString()).ToLower());
 }
Exemple #3
0
 public static string Scope(RootAccessModifier scope)
 {
     return(Patcher.AddLowerUpperNeighboringSpaces(scope.ToString().ToLower()));
 }
Exemple #4
0
        public static string Declaration(int indent, RootAccessModifier scope, ClassModifier modifier, string typeName, string inherits, List <Interface> interfaces, string attributes, string parameters, List <Variable> variables, string customVariables, string constructors, string preMethodCustomText, Methods methods, bool isLive)
        {
            var output = string.Empty;

            output += attributes + (string.IsNullOrEmpty(attributes) ? string.Empty : "\n");
            output += CodeBuilder.Indent(indent) + CodeBuilder.Scope(scope) + " " + ((modifier == ClassModifier.None) ? string.Empty : Patcher.AddLowerUpperNeighboringSpaces(modifier.ToString()).ToLower()) + " " + Patcher.ObjectTypeName(ObjectKind.Class) + " " + typeName + CodeBuilder.TryAddBaseTypeSeperator(inherits, interfaces) + inherits + CodeBuilder.Interfaces(interfaces, inherits, (interfaces.Count > 0) ? true : false);
            output += "\n";
            output += CodeBuilder.Indent(indent) + "{";
            output += "\n";
            output += CodeBuilder.Variables(variables, indent + 1);
            output += customVariables;
            output += (string.IsNullOrEmpty(customVariables) ? string.Empty : "\n");
            output += constructors;
            output += preMethodCustomText;
            output += string.IsNullOrEmpty(preMethodCustomText) ? string.Empty : "\n\n";
            output += MethodBuilder.Methods(indent + 1, methods, isLive);
            output += CodeBuilder.Indent(indent) + "}";
            return(output);
        }