Hello there.
I would like to aks you for your help. I have here problem with WCF deserialization of Dictionary where Enum type is used as a key.
I have two data objects:
[DataContract]
public enum MyEnum : int
{
[EnumMember]
Value1 = 0,
[EnumMember]
Value2 = 1
}
and
[DataContract]
[KnownType(typeof(MyEnum))]
public cl...
Hi,
I'm trying to persist an Enum as an Embedded value (ideally using it's String representation, but even ordinal would be ok right now)
The Enum:
@Embeddable
public enum DayOfTheWeek {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY;
public int toCalendar() throws EnumConstantNotPresentException{
switch (this) {
...
I have regularly wondered why C# has not yet implemeted a Generic Enum.Parse
Lets say I have
enum MyEnum
{
Value1,
Value2
}
And from an XML file/DB entry I wish to to create an Enum.
MyEnum val = (MyEnum)Enum.Parse(typeof(MyEnum), "value1", true);
Could it not have been implemented as something like
MyEnum cal = Enum.Parse<...
I've a class and an enum value which have the same name. Inside the class I want to use the enum which gives an error. Is there any way to use the enum without renaming or moving to a different namespace?
Example:
namespace foo {
enum bar {
BAD
};
class BAD {
void worse () {
bar b = BAD; // erro...
I write a library that should rely on enums but the actual enum should be defined be the user of my library.
In the following example the authorize method requires parameters of the enum type Permission.
acl.authorize(userX, Permission.READ, Permission.WRITE)
My library should be able to handle arbitrary permissions defined by the ...
There are some related questions here and here, but they didn't really give me satisfactory answers. The problem is that enums nested in a class in C# cannot have the same name as a property of the class. My example:
public class Card
{
public enum Suit
{
Clubs,
Diamonds,
Spades,
Hearts
}
...
Until asking a question on here I never considered (enums) to be a "bad thing." For those out there that consider them not to be best practice, what are some approachs/patterns for avoiding their use in code?
Edit:
public Enum SomeStatus
Approved = 1
Denied = 2
Pending =3
end Enum
...
Hi All
I came across thas problem that I without knowing the actual enum type i need to iterate its possible values.
if (value instanceOf Enum){
Enum enumValue = (Enum)value;
}
Any ideas how to extract from enumValue its possible values ?
Thanks
...
I have a domain interface
public interface ITicket
{
...
TicketWorkflowStatus StatusId{get;set;} // Enum
}
but the linq-to-sql persistance layer on the database wants to use int, can I change it in the dbml so that the local type is TicketWorkflowStatus? What are my options?
...
I have a database table that includes a two bit fields: IsEvenSide and IsOddSide. I want this to map to the following enum:
[Flags] enum SideOfStreet { None, Even, Odd }
I have done IUserType's in the past, but I don't know how to map to multiple database fields.
How can this be done?
P.S.: I'm using Fluent NHibernate, but I'm okay ...
I would like to define a mapping (or even a TypeConverter/Resolver) for the following classes:
Destination:
public class Destination
{
public DestinationEnum EnumProperty { get; set; }
public Destination()
{
EnumProperty = DestinationEnum.undefined;
}
}
public enum Destination...
I have a class which uses an enumeration, the enum is currently in it's own file which seems wasteful.
What is the general opinion on enums being placed within the namespace of a file that they are consumed in?
Or should the enum really live in it's own cs file?
Edit
I should mention that while the class in question uses these enume...
I have an object that represents a physical structure (like a utility pole), and it touches a bunch of other objects (the wires on the pole). The other objects have a bunch of characteristics (status, size, voltage, phase, etc.) expressed as enums. I want to write a generic function that counts how many of the wires match any or all of t...
I have two Enums as follows:
enum Connector {
AND, OR, XOR;
}
enum Component {
ACTIVITY
}
Now, I have a variable named follower in a class Event. This variable (follower) can have (and should have) value from either of the above two Enums.
So, What datatype should I give to the follower variable?
...
mysql> CREATE TABLE foo ( f ENUM('a', '123') );
mysql> insert into foo(f) value(3);
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> select * from foo;
+------+
| f |
+------+
| |
+------+
How to make it produce a failure when inserting a value out of range?
...
I have a list of constants and want to check if a value passed to a method equals one of the constants. I know Enums which would be fine, but I need an int value here for performance reasons. Enum values can have a value, but I'm afraid the getting the int value is slower than using an int directly.
public static final int
a = Intege...
How are enums handled when it comes to the heap, memory, and when an enum type instance is created? If I've got an enum with fifty field constants, then do I have fifty objects on the heap representing that enum type (when accessed), and are there performance concerns?
...
I have to sort a namevaluecollection(Items usually 5 to 15) Against an enum(having items more than 60). Right now I am using this extension function, Anyone have better idea to write this code....
public static NameValueCollection Sort(this NameValueCollection queryString, Type orderByEnumType, bool excludeZeroValues)
{
...
I want to expose an enum to my client application without referencing it in my WCF Service. However the enum is not visible in the client application. Below is my code:
[DataContract]
public enum Columns
{
[EnumMember]
Column1= 0,
[EnumMember]
Column2= 1
}
[ServiceKnownType(typeof(Columns))]
public interface IService
{
...
I want to override toString() for my enum, Color. However, I can't figure out how to get the value of an instance of Color inside the Color enum. Is there a way to do this in Java?
Example:
public enum Color {
RED,
GREEN,
BLUE,
...
public String toString() {
// return "R" for RED, "G", for GREEN, etc.
}...