private void processEnum(Schema schema, CodeNamespace ns)
{
EnumSchema enumschema = schema as EnumSchema;
//TODO: This looks wrong. Double check is an enum schema a named schema? If so use the namespace if no namespace is provided.
if(null==enumschema) throw new NotSupportedException();
CodeTypeReference refEnum = new CodeTypeReference(enumschema.name.full);
CodeTypeDeclaration typeEnum = createCodeTypeDeclaration(refEnum.BaseType);
typeEnum.BaseTypes.Add(typeof(int));
typeEnum.IsEnum = true;
typeEnum.Attributes = MemberAttributes.Public;
int index = 0;
foreach (string symbol in enumschema.symbols)
{
CodeMemberField field = new CodeMemberField(typeof(int), symbol);
field.InitExpression = new CodePrimitiveExpression(index++);
typeEnum.Members.Add(field);
}
_SchemaToCodeTypeReferenceLookup.Add(schema, refEnum);
CodeNamespace addtoNs = null;
if (null != enumschema.name && !string.IsNullOrEmpty(enumschema.name.space))
{
addtoNs = addNamespace(enumschema.name.space);
}
else
{
addtoNs = ns;
}
addtoNs.Types.Add(typeEnum);
}