enums

C# - Silverlight - CustomAttribute with Enum

I have the following class: [MetadataAttribute] [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] public class ModuleActivationButtonAttribute : ExportAttribute { public Enum TargetRegion { get; set; } public ModuleActivationButtonAttribute(Enum targetRegion) : base(typeof(IModuleActivationButton)) { ...

passing an "unknown enumeration" to a method

I'm currently trying to make a class that can register strings as identifiers and accociate them with different types of Enumerations, these enumerations are being evaluated only in so much that I am ensuring that when it's used, that the parameter passed to broadcast (messageType) is an instance of the associated Enum Type. This would ...

Enums With Default Throw Clause?

I noticed the following in the Java Language spec in the section on enumerations here: link switch(this) { case PLUS: return x + y; case MINUS: return x - y; case TIMES: return x * y; case DIVIDE: return x / y; } throw new AssertionError("Unknown op: " + this); However, looking at the switch statement definition section, I...

C++ Why am I unable to use an enum declared globally outside of the class it was declared in?

Right now, my project has two classes and a main. Since the two classes inherit from each other, they are both using forward declarations. In the first object, right underneath the #include statement, I initialize two enums, before the class definition. I can use both enums just fine inside that class. However, if I try to use those enum...

Creating DescriptionAttribute on Enumeration Field using System.Reflection.Emit

I have a list of strings which are candidates for Enumerations values. They are Don't send diffs 500 lines 1000 lines 5000 lines Send entire diff The problem is that spaces, special characters are not a part of identifiers and even cannot start with a number, so I would be sanitizing these values to only chars, numbers and _ To keep...

Should I use Enumeration or Class stereotype in UML to represent a type directory table?

Let's take 2 UML class model entities: One represents an actual Order and another represents an Orede Type. Any Order corresponds to one Type. A 2-way-naviglabe many Orders to one Type relation is meant. Order Type instances are, for example, "Request availability", "Request price", "Preorder", "Buy", "Cancel", "Request support", etc. O...

Do you use enums in your data applications and how?

My practice shows that a general enterprise application has a lot of entities which's nature corresponds to an elementary enumeration. For example We may have an Order entity which may have such fields as "OrderType", "OrderStatus", "Currency", etc. referencing corresponding Entities which are nothing more than just a textual name bound ...

" not all code paths return a value" when return enum type

I have enum list and method and i get error: " not all code paths return a value" Some idea whats wrong in my method ? I am sure I always return STANY type :/ Thanks for help :) private enum STANY { PATROL, CHAT, EAT, SEARCH, DIE }; private STANY giveState(int id, List<Ludek> gracze, List<int> plansza) { // Spraw...

Merging Bit, Enum and Set fields in MySql

I know up to eight Bit fields are merged into one byte to save space, but what if I have a couple of Bit fields and an Enum or a Set field? Are they internally merged too? I'm asking because I'm going to have a lot of rows in my table and I want to avoid overhead as much as possible. ...

Configurable Values in Enum

I often use this design in my code to maintain configurable values. Consider this code: public enum Options { REGEX_STRING("Some Regex"), REGEX_PATTERN(Pattern.compile(REGEX_STRING.getString()), false), THREAD_COUNT(2), OPTIONS_PATH("options.config", false), DEBUG(true), ALWAYS_SAVE_OPTIONS(true), THREAD_WAI...

Question about singleton property

I'm reading the java tutorial for enums located here and have a question: http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html#Card The part i'm confused about is as follows: "The Card class, above, contains a static factory that returns a deck, but there is no way to get an individual card from its rank and suit....

Use TinyInt to hide/show controls?

Hi, I have 6 buttons on my GUI. The visibility of the buttons can be configured via checkboxes. Checking the checkbox and saving means the correpsonding button should be shown. I am wondering if it is somehow possible to have one TinyInt column in the database which represents the visibility of all 6 buttons. I created an enum for the b...

How can I internationalize strings representing C# enum values?

I've seen many questions and answers about mapping strings to enums and vice-versa, but how can I map a series of localized strings to enums? Should I just create an extension method like this that returns the proper string from a resource file? Is there a way to localize attributes (like "Description") that are used in solutions like ...

Java enums, static class variables - why can't I do this?

I am getting a "cannot be resolved" error when I try to do this: class Tag{ public static final int blah = 1231; } enum Things{ COOL (Tag.blah, "blah"); //error here } the compiler complains that it cannot find the Tag class on the line above. ...

Java Enum Newbie Question

i have a situation where i need the Checker enum below used in multiple classes: package Sartre.Connect4; public enum Checker { EMPTY, RED, YELLOW } so i put the Checker in a Checker.java file and then from the classes that need it i simply do the following: example: public Cell(){ currentCell = Checker.EMPTY;...

Why are enums considered compound types?

Arrays, functions, pointers, references, classes, unions, enumerations and pointers to members are compound types. My understanding of a compound type is that is based on other type(s). For example, T[n], T* and T& are all based on T. Then what other type(s) is an enumeration based on? Or if my understanding of compound types is incorr...

Test if an object is an Enum

I would like to know if 'theObject' is an enum (of any enum type) foreach (var item in Enum.GetValues(theObject.GetType())) { //do something } ...

Enums, Constructor overloads with similar conversions.

Why does VisualC++ (2008) get confused 'C2666: 2 overloads have similar conversions' when I specify an enum as the second parameter, but not when I define a bool type? Shouldn't type matching already rule out the second constructor because it is of a 'basic_string' type? #include <string> using namespace std; enum EMyEnum { mbOne, mb...

Eclipse bug? Switching on a null with only default case

I was experimenting with enum, and I found that the following compiles and runs fine on Eclipse (Build id: 20090920-1017, not sure exact compiler version): public class SwitchingOnAnull { enum X { ,; } public static void main(String[] args) { X x = null; switch(x) { default: System.out.println("Hello ...

How to find the class object of Java generic type?

Assume I have a generic type P which is an Enum, that is <P extends Enum<P>>, and I want to get the Enum value from a string, for example: String foo = "foo"; P fooEnum = Enum.valueOf(P.class, foo); This will get a compile error because P.class is invalid. So what can I do in order to make the above code work? ...