Пример #1
0
        private EnumType AddEnumIf(Type enumType)
        {
            var res = _result.EnumTypes.FirstOrDefault(t => t.TypeFullName == enumType.FullName);
            if (res == null)
            {
                res = new EnumType();

                res.Name = enumType.Name;
                res.TypeFullName = enumType.FullName;

                var names = Enum.GetNames(enumType);
                foreach (var name in names)
                {
                    res.Items.Add(new EnumItem
                    {
                        Name = name
                    });
                }

                _result.EnumTypes.Add(res);
            }

            return res;
        }
Пример #2
0
        protected override void VisitEnum(CodeEnum codeEnum)
        {
            _currentEnum = new EnumType();
            _currentEnum.CodeElement = codeEnum;
            _currentEnum.Name = codeEnum.Name;
            _currentEnum.TypeFullName = codeEnum.FullName;

            base.VisitEnum(codeEnum);

            _enumTypes.Add(_currentEnum);
            _currentEnum = null;
        }