Esempio n. 1
0
        static string GetArgString(Definitions.ParamDefinition p, int i)
        {
            string modify    = GetModifyString(p);
            string paramName = !string.IsNullOrEmpty(p.CSharpName) ? NamedTool.VarName(p.CSharpName) : "p" + i;

            return(modify + paramName);
        }
Esempio n. 2
0
        public static void RemoveCommonPrefix(Definitions.EnumDefinition @enum)
        {
            if (@enum.Items.Count == 0)
            {
                return;
            }
            var fieldNames  = @enum.Items.Select(item => NamedTool.SplitWord(item.Name)).ToArray();
            int commonCount = 0;

            while (true)
            {
                if (commonCount >= fieldNames[0].Length)
                {
                    break;
                }
                if (fieldNames.Skip(1).Any(names => commonCount >= names.Length || names[commonCount] != fieldNames[0][commonCount]))
                {
                    break;
                }
                commonCount++;
            }
            for (int i = 0; i < @enum.Items.Count; i++)
            {
                var csharpName = NamedTool.ToCamelNamed(fieldNames[i].Skip(commonCount));
                if (char.IsDigit(csharpName[0]))
                {
                    csharpName = "_" + csharpName;
                }
                @enum.Items[i].CSharpName = csharpName;
            }
        }
Esempio n. 3
0
        static string GetParamString(Definitions.ParamDefinition p, int i)
        {
            string modify = GetModifyString(p);
            var    sb     = new StringBuilder();

            if (p.Attrs.Length > 0)
            {
                sb.Append($"[{string.Join(", ", p.Attrs)}] ");
            }
            sb.Append(modify).Append(p.Type.CSharpName).Append(' ').Append(NamedTool.VarName(p.CSharpName));
            return(sb.ToString());
        }
Esempio n. 4
0
 protected virtual void RenameStructField(Definitions.StructDefinition @struct, Definitions.StructField field)
 {
     field.CSharpName = NamedTool.ToCamelNamed(field.Name);
 }