I have a Flag based enum, and while it doesn't currently exceed the bounds of 64 value (long), it potentially will.
I'm using the enum to describe which of our customers an MEF plugin/component is meant for. This will be our main mechanism for implementing customer customisations.
I'm fairly certain my bosses won't be too pleased with the idea that we can only serve 64 customers, but I cannot implement such a flexible system without an Enum.
Ideally, I'd like to write:
[Flags]
public enum Organisations : MyBinaryFormat
{
// Customers
CustomerA = 1 << 0,
CustomerB = 1 << 1,
CustomerC = 1 << 2,
CustomerD = 1 << 3,
// Special
Any = CustomerA | CustomerB | CustomerC,
HostedCustomers = CustomerA | CustomerC,
}
This is a very convenient syntax for defining my metadata, unfortunately hacking types isn't really my forte so I've tried my best to research/experiment around the topic but haven't come to much:
This question says it's possible to use the BitArray class with an enumeration, which would be ideal However there isn't an implementation provided.
I've seen a TypeDef used in VS2008 documentation passed into an enum here. In the example it simply masks the
bool
type, and it looks as though this keyword was removed.I've searched multiple msdn "enum" pages (I'm reluctant to say 'all' but I've seen far too many for my own good). However this page says to consider using System.Int32 as the data type unless the enumeration is a flags enum, and you have more than 32 flags.
However, there is an exception I keep getting "Error1: Type byte, sbyte, short, ushort, int, uint, long, or ulong expected" whenever I try to use a custom type. I haven't seen anything (besides my exception) which expressly says you cannot use your own custom data type, but I also haven't found a single implementation of it.
I'd like to know definitively if constructing an enum on a custom type is possible