/// <summary> /// Try to import the given type as an enum. /// Returns true if an enum was imported, otherwise false. /// </summary> private bool ImportEnum(Type type) { object[] customAttributes = type.GetCustomAttributes(typeof(LinkableEnumAttribute), inherit: false); if (customAttributes.Length == 0) { return(false); } LinkableEnumAttribute attribute = (LinkableEnumAttribute)customAttributes[0]; ImportEnum(type, attribute); return(true); }
public void ImportEnum(Type type, LinkableEnumAttribute attribute) { throw new NotSupportedException("Need to support enum value expressions in MonC first."); // string[] names = Enum.GetNames(type); // List<KeyValuePair<string, int>> enumerations = new List<KeyValuePair<string, int>>(); // // string prefix = attribute.Prefix ?? ""; // // foreach (string name in names) { // enumerations.Add(new KeyValuePair<string, int>(prefix + name, (int)Enum.Parse(type, name))); // } // // // TODO: New attribute value for enum name, or use type name. // EnumNode enumNode = new EnumNode(type.Name, enumerations, isExported: true); // _enums.Add(enumNode); // // Symbol symbol = new Symbol(); // symbol.Node = enumNode; // symbol.SourceFile = type.Module.FullyQualifiedName; // _tokenMap[enumNode] = symbol; }