示例#1
0
        private static NameRule GetEnumRule(NameSemantic semantic)
        {
            int enumMode = -1;

            if (semantic.Entity is IField && semantic.Entity.DeclaringType.Kind == TypeKind.Enum)
            {
                enumMode          = Helpers.EnumEmitMode(semantic.Entity.DeclaringType);
                semantic.EnumMode = enumMode;
            }

            switch (enumMode)
            {
            case 1:
                if (semantic.Entity.Name.Length > 1 &&
                    semantic.Entity.Name.ToUpperInvariant() == semantic.Entity.Name)
                {
                    return(NameConvertor.DefaultCaseRule);
                }
                return(NameConvertor.LowerCamelCaseRule);

            case 3:
                return(NameConvertor.LowerCamelCaseRule);

            case 2:
            case 4:
            case 7:
                return(NameConvertor.DefaultCaseRule);

            case 5:
            case 8:
                return(NameConvertor.LowerCaseRule);

            case 6:
            case 9:
                return(NameConvertor.UpperCaseRule);
            }

            return(null);
        }