예제 #1
0
        public static string GetFinalPath(LudiqScriptableObject asset, string @namespace, string assetName)
        {
            string fileName = string.Empty;

            var filePath = GetFilePath(asset);

            if (((ObjectMacro)asset) != null)
            {
                if (!string.IsNullOrEmpty(((ObjectMacro)asset).name))
                {
                    fileName = ((ObjectMacro)asset).name;
                }
                else
                {
                    fileName = asset.name;
                }
            }
            else
            {
                throw new NullReferenceException();
            }

            if (!string.IsNullOrEmpty(((ObjectMacro)asset).name))
            {
                return(filePath + Patcher.LegalVariableName(CodeBuilder.GetExtensionlessFileName(fileName), false) + ".cs");
            }

            return(filePath + Patcher.LegalVariableName(assetName, false) + ".cs");
        }
예제 #2
0
        public static string Parameter(Variable data, bool isLast)
        {
            var output = string.Empty;

            output += Patcher.AsActualName(data.type.type) + " " + Patcher.LegalVariableName(data.name, true) + (isLast ? "" : ", ");
            return(output);
        }
예제 #3
0
        public static string AssignReadOnly <TVariableData>(TVariableData data) where TVariableData : Variable
        {
            var output = string.Empty;

            output += "this." + Patcher.LegalVariableName(data.name, true) + " = " + Patcher.LegalVariableName(data.name, true) + ";";
            return(output);
        }
예제 #4
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);
        }
예제 #5
0
        public static string Variables(List <Variable> variables, int indent)
        {
            var output = string.Empty;
            var count  = 0;

            foreach (Variable variable in variables)
            {
                count++;

                var asReadOnly = string.Empty;

                var type = variable.type.type;

                output += Indent(indent) + Scope(variable.scope) + VariableModifier(variable) + " " + Patcher.AsActualName(type) + " " + Patcher.LegalVariableName(variable.name, true);

                output += VariableScope(variable, indent);

                if (count < variables.Count)
                {
                    output += "\n";
                }
            }

            return(output);
        }
예제 #6
0
 public static string TypeName(ObjectMacro asset)
 {
     return(Patcher.LegalVariableName((string.IsNullOrEmpty(asset.name) ? CodeBuilder.GetExtensionlessFileName(CodeBuilder.GetFileName(asset)).Replace(" ", string.Empty) : asset.name).Replace(" ", string.Empty), false));
 }