Exemplo n.º 1
0
        private void setUiByTypeMode(TypeMode typeMode)
        {
            #region set mode into ui display
            switch (typeMode.JavaName)
            {
            case "Integer":
                txtInt.Text = typeMode.CSharpName;
                break;

            case "BigDecimal":
                txtBIgDecimal.Text = typeMode.CSharpName;
                break;

            case "Short":
                txtShort.Text = typeMode.CSharpName;
                break;

            case "String":
                txtString.Text = typeMode.CSharpName;
                break;

            case "Long":
                txtLong.Text = typeMode.CSharpName;
                break;

            case "Date":
                txtDate.Text = typeMode.CSharpName;
                break;

            case "List":
                txtList.Text = typeMode.CSharpName;
                break;

            case "Map":
                txtMap.Text = typeMode.CSharpName;
                break;

            case "Float":
                txtFloat.Text = typeMode.CSharpName;
                break;

            case "Double":
                txtDouble.Text = typeMode.CSharpName;
                break;

            case "Character":
                txtCharacter.Text = typeMode.CSharpName;
                break;

            case "Byte":
                txtCharacter.Text = typeMode.CSharpName;
                break;

            default:
                break;
            }
            #endregion
        }
Exemplo n.º 2
0
        private string handleGetSetAndNoted(string content, TypeMode typeMode, SettingMode mode)
        {
            string result = content;

            //添加引用空间
            if (!result.Contains(typeMode.UsingSpace))
            {
                result = typeMode.UsingSpace + "\r\n" + result;
            }
            //类型替换
            result = Regex.Replace(result, @" " + typeMode.JavaName + " ", " " + typeMode.CSharpName + " ");

            //get set  注释处理
            string partten = @"(\s*)private " + typeMode.CSharpName + " ([a-zA-Z0-9]+)";

            if (typeMode.CSharpName.EndsWith("?") && typeMode.CSharpName.Length > 1)
            {
                int index = typeMode.CSharpName.LastIndexOf("?");
                partten = @"(\s*)private " + typeMode.CSharpName.Substring(0, index) + "\\" + typeMode.CSharpName.Substring(index) + " ([a-zA-Z0-9]+)";
            }
            Regex           r1 = new Regex(partten);
            MatchCollection matchCollection = r1.Matches(result);

            foreach (Match m in matchCollection)
            {
                var matchValue = m.Value;//private Int32 gnameId
                if (matchValue.Contains("?") && matchValue.Length > 1)
                {
                    int index = matchValue.LastIndexOf("?");
                    matchValue = matchValue.Substring(0, index) + "\\" + matchValue.Substring(index);
                }
                var spaceKey        = m.Result("$1");
                var javaFieldName   = m.Result("$2");
                var cSharpFieldName = javaFieldName.Substring(0, 1);
                if (mode.isFirstUpper)
                {
                    cSharpFieldName = cSharpFieldName.ToUpper();
                }
                if (javaFieldName.Length > 1)
                {
                    cSharpFieldName = cSharpFieldName + javaFieldName.Substring(1);
                }
                var replaceValue = spaceKey + "public " + typeMode.CSharpName + " " + cSharpFieldName + " { get; set; }";
                if (!string.IsNullOrEmpty(mode.StrPropNote))
                {
                    replaceValue = "\r\n\t    " + Regex.Replace(mode.StrPropNote, "\"fieldName\"", "\"" + javaFieldName + "\"") + replaceValue;
                }
                result = Regex.Replace(result, @"" + matchValue, replaceValue);
            }


            return(result);
        }
Exemplo n.º 3
0
        private SettingMode collectSettingMode()
        {
            SettingMode mode = new SettingMode();

            mode.StrOutPutDir   = txtDesPath.Text;
            mode.StrSpaceName   = txtSpace.Text;
            mode.StrPropNote    = txtPropertyNote.Text;
            mode.isFirstUpper   = chxFirstUpper.Checked;
            mode.isAutoTransfor = chxAutoTransfor.Checked;
            mode.isDelClassNote = chxDelClass.Checked;
            mode.isDelPropNote  = chxDelProp.Checked;

            mode.TypeModes = new List <TypeMode>();

            TypeMode intMode = new TypeMode();

            intMode.JavaName   = "Integer";
            intMode.CSharpName = txtInt.Text;
            intMode.UsingSpace = "using System;";
            mode.TypeModes.Add(intMode);


            TypeMode decimalMode = new TypeMode();

            decimalMode.JavaName   = "BigDecimal";
            decimalMode.CSharpName = txtBIgDecimal.Text;
            decimalMode.UsingSpace = "using System;";
            mode.TypeModes.Add(decimalMode);


            TypeMode shortMode = new TypeMode();

            shortMode.JavaName   = "Short";
            shortMode.CSharpName = txtShort.Text;
            shortMode.UsingSpace = "using System;";
            mode.TypeModes.Add(shortMode);


            TypeMode stringMode = new TypeMode();

            stringMode.JavaName   = "String";
            stringMode.CSharpName = txtString.Text;
            stringMode.UsingSpace = "using System;";
            mode.TypeModes.Add(stringMode);

            TypeMode longMode = new TypeMode();

            longMode.JavaName   = "Long";
            longMode.CSharpName = txtLong.Text;
            longMode.UsingSpace = "using System;";
            mode.TypeModes.Add(longMode);

            TypeMode dateMode = new TypeMode();

            dateMode.JavaName   = "Date";
            dateMode.CSharpName = txtDate.Text;
            dateMode.UsingSpace = "using System;";
            mode.TypeModes.Add(dateMode);

            TypeMode listMode = new TypeMode();

            listMode.JavaName   = "List";
            listMode.CSharpName = txtList.Text;
            listMode.UsingSpace = "using System.Collections.Generic;";
            mode.TypeModes.Add(listMode);

            TypeMode mapMode = new TypeMode();

            mapMode.JavaName   = "Map";
            mapMode.CSharpName = txtMap.Text;
            mapMode.UsingSpace = "using System;";
            mode.TypeModes.Add(mapMode);

            TypeMode floatMode = new TypeMode();

            floatMode.JavaName   = "Float";
            floatMode.CSharpName = txtFloat.Text;
            floatMode.UsingSpace = "using System;";
            mode.TypeModes.Add(floatMode);


            TypeMode doubleMode = new TypeMode();

            doubleMode.JavaName   = "Double";
            doubleMode.CSharpName = txtDouble.Text;
            doubleMode.UsingSpace = "using System;";
            mode.TypeModes.Add(doubleMode);


            TypeMode charMode = new TypeMode();

            charMode.JavaName   = "Character";
            charMode.CSharpName = txtCharacter.Text;
            charMode.UsingSpace = "using System;";
            mode.TypeModes.Add(charMode);


            TypeMode byteMode = new TypeMode();

            byteMode.JavaName   = "Byte";
            byteMode.CSharpName = txtCharacter.Text;
            byteMode.UsingSpace = "using System;";
            mode.TypeModes.Add(byteMode);
            return(mode);
        }