enums

How to display different Enum icons using XAML only?

I want to show a different icon/image depending on an enum value. For example, if I had the following enum: public enum UploadStatus { Unknown = 0, WaitingToUpload = 10, Uploading = 20, Uploaded = 30, UploadFailed = 40 } I'd like to write XAML that looks something like this: ... <EnumImage Value="...

C++ packing a typedef enum

typedef enum BeNeLux { BELGIUM, NETHERLANDS, LUXEMBURG } _ASSOCIATIONS_ BeNeLux; When I try to compile this with C++ Compiler, I am getting errors, but it seems to work fine with a C compiler. So here's the question. Is it possible to pack an enum in C++, or can someone see why I would get the error? The error is: "semico...

How should I store an Java Enum in JavaDB?

How should I store an Java Enum in JavaDB? Should I try to map the enums to SMALLINT and keep the values in source code only? The embedded database is only used by a single application. Or should I just store the values as DECIMAL? None of these solutions feels good/robust for me. Is there any better alternatives? Here is my enum: imp...

How to query flags stored as enum in NHibernate

How to do either a HQL or a Criteria search (the latter is preferred) involving an enum that is used as flags. In other words, I have a persisted enum property that stores some kind of flags. I want to query all the records that have one of these flags set. Using Eq won't work of course because that will only be true, if that is the only...

How to use a separate class to validate credit card numbers in C#

I have set up a class to validate credit card numbers. The credit card type and number are selected on a form in a separate class. I'm trying to figure out how to get the credit card type and number that are selected in the other class (frmPayment) in to my credit card class algorithm: public enum CardType { MasterCard, Visa, Amer...

Is it possible in .NET 3.5 to specify an enum type?

I have a enumerator which map to a bunch of int example enum MyEnum { Open = 1, Closed = 2, Exit = 4 } I find though that when I want to assign this to an integer, I have to cast it first. int myEnumNumber = **(int)** MyEnum.Open; Is it possible to specify the type of an enum so that it is implicit that there is a integer assigne...

Is it possible to create an enum whose instance can't be created but can be used for readonly purpose

I created an enum where I stored some table names. I want it to be used to get the name of the table like ds.Tables[BGuestInfo.TableName.L_GUEST_TYPE.ToString()]. public class a { public enum TableName : byte { L_GUEST_TYPE = 0 ,L_AGE_GROUP = 1 ,M_COMPANY = 2 ...

Make resharper show the options of an enum in a live template?

I'm traying to create the following resharper live template: Using New Tracer($EXPR$) $END$ End Using Currently $EXPR$ is currently "Suggest variable of " What I'm trying to do is that this whould show me for example a dropdown with the options of MyEnum and then after selecting goes to $END$ Is this possible? ...

In Objective C, is there a way to call reference a typdef enum from another class?

It is my understanding that typedef enums are globally scoped, but if I created an enum outside of the @interface of RandomViewController.h, I can't figure out how to access it from OtherViewController.m. Is there a way to do this? So... "RandomViewController.h" #import <UIKit/UIKit.h> typedef enum { EnumOne, EnumTwo }EnumType; @i...

Using generics in F# to create an EnumArray type

I've created an F# class to represent an array that allocates one element for each value of a specific enum. I'm using an explicit constructor that creates a dictionary from enum values to array indices, and an Item property so that you can write expressions like: let my_array = new EnumArray<EnumType, int> my_array.[EnumType.enum_value...

Enums, DataContracts and WCF question

I am new to WCF and have a simple question... My DataContract class returns an Enum type to the consumer from one of it's exposed methods. The consumer is able to see the enum type, and instantiate variables of that typel. However, I have not provided a [DataContract] nor [EnumMember]s for the enum in the service. My question is, wh...

How can I expose a 3rd party's enum through my asmx?

Given: An asmx web service. A 3rd party dll that contains a useful enum. Question: How can I expose this enum through my web service without having to repeat myself and re-type the enum's members in my webservice's public class? ...

Objective-C / C giving enums default values

I read somewhere about giving enums default values like so: typedef enum { MarketNavigationTypeNone = 0, MarketNavigationTypeHeirachy = 1, MarketNavigationTypeMarket = 2 } MarketNavigationLevelType; .. but i can't remember the value of doing this. If i don't give them default values - and then someone later on reorders the enum - wha...

Enums,use in switch case

Hi, I have an Enum defined which contains method return type like "String",Float,List,Double etc. I will be using it in switch case statements. For example my enum is public enum MethodType { DOUBLE,LIST,STRING,ARRAYLIST,FLOAT,LONG; } In a property file, I've key value pairs as follows. Test1=String Test2=Double In my code I'm ...

enum type in C++

This works: enum TPriority { EPriorityIdle = -100, EPriorityLow = -20, EPriorityStandard = 0, EPriorityUserInput = 10, EPriorityHigh = 20 }; TPriority priority = EPriorityIdle; But this doesn't work: TPriority priority = -100; Any reason? ...

How to get global access to enum types in C#?

This is probably a stupid question, but I can't seem to do it. I want to set up some enums in one class like this: public enum Direction { north, east, south, west }; Then have that enum type accessible to all classes so that some other class could for instance have: Direction dir = north; and be able to pass the enum type between...

Java Enum List from Class

How do I go from a Class object to a list of enums generically? i.e. public static <T extends Enum> List<T> getList(Class<T> clazz) I cant find a way to get to the values() method ...

How do I access static variables in an enum class without a class instance?

I have some code that processes fixed length data records. I've defined the record structures using java enums. I've boiled it down the the simplest example possible to illustrate the hoops that I currently have to jump through to get access to a static variable inside the enum. Is there a better way to get at this variable that I'm o...

C++ pass enum as parameter

If I have a simple class like this one for a card: class Card { public: enum Suit { CLUBS, DIAMONDS, HEARTS, SPADES }; Card(Suit suit); }; and I then want to create an instance of a card in another file how do I pass the enum? #include "Card.h" using namespace std; int main () { Suit suit = Car...

Binding Enum[] to ListBox

Hello. I have next enumeration Enum rcCategory { Incoming, Internal, Outgoing } and I have property "categories" in my class which has rcCategory[] type. I would like to bind this property to the listBox. I use next code for this MyListBox.SetBinding (ListBox.ItemsSource, new Binding {Source= myClass.categories}); But this ...