Beispiel #1
0
        private Type DefineEnumType(ModuleBuilder module, DynamicEnumType enumTypeInfo)
        {
            var enumBuilder =
                module.DefineEnum(
                    enumTypeInfo.Name,
                    GetTypeAccess(enumTypeInfo.TypeAccess),
                    enumTypeInfo.UnderlyingType);

            foreach (var a in enumTypeInfo.Attributes)
            {
                enumBuilder.SetCustomAttribute(AnnotationAttributeBuilder.Create(a));
            }

            foreach (var enumMember in enumTypeInfo.Members)
            {
                enumBuilder.DefineLiteral(
                    enumMember.Key,
                    Convert.ChangeType(enumMember.Value, enumTypeInfo.UnderlyingType));
            }

            return(enumBuilder.CreateType());
        }
Beispiel #2
0
 public Tuple <DynamicEnumType, bool> HasEnumType(DynamicEnumType enumType, bool nullable)
 {
     EnumType = new Tuple <DynamicEnumType, bool>(enumType, nullable);
     return(EnumType);
 }