This is a similar question to How to bind a custom Enum description to a DataGrid, but in my case I have multiple properties.
public enum ExpectationResult
{
[Description("-")]
NoExpectation,
[Description("Passed")]
Pass,
[Description("FAILED")]
Fail
}
public class TestResult
{
public string TestDescriptio...
I am having an issue using the Moq library to mock an Enum within my project. I am trying to test a class and one of the methods accepts an ENum. Is there any way to do this?
Here is the Enum I am trying to mock:
public enum PermissionType
{
Create = 0,
Read = 1,
Update = 2,
Delete = 3,
}
Here is the code I am trying ...
For example System.Net.HttpStatusCode Enum , i would like to get the HTTP Status Codes instead of the HTTP Status Text
System.Net.HttpStatusCode.Forbidden should return 403 instead of "Forbidden"
how can i extract the value?
...
I have the following code;
public class DataReader<T> where T : class
{
public T getEntityFromReader(IDataReader reader, IDictionary<string, string> FieldMappings)
{
T entity = Activator.CreateInstance<T>();
Type entityType = entity.GetType();
PropertyInfo[] pi = entityType.Get...
Hi all,
I still have trouble with some corner cases in the java generics system.
I have this method (I'm only interested in the signature) :
interface Extractor<RETURN_TYPE> {
public <U extends Enum<U>> RETURN_TYPE extractEnum(final Class<U> enumType);
}
(think about an interface whose implementations sometimes extracts an En...
While the following subrange enumeration declaration works:
type
TReceiptCode = 'A'..'F';
This does not:
type
TReceiptCode = ' ','A'..'F', 'R';
Nor does
type
TReceiptCode = ' ','A','B','C','D','E','F','R';
How can i declare a subrange type with non-contiguous values?
...
I have a struct I'm accessing via ctypes:
struct attrl {
char *name;
char *resource;
char *value;
struct attrl *next;
enum batch_op op;
};
So far I have Python code like:
# struct attropl
class attropl(Structure):
pass
attrl._fields_ = [
("next", POINTER(attropl)),
("name", c_char_p),
...
So I may be pushing the boundaries just a bit...
Basically I have the following enum, declared in C# code:
[Flags]
public enum FlaggedEnum : int
{
Option1 = 1,
Option2 = 2,
Option3 = 4,
Option4 = 8,
...
Option16 = 32768,
None = 0
}
This enum is a member of an object which I have successfully bound to a Dat...
How do I susbtitute in matched groups from 1 regular expression into another regular expression in C#?
I need to process an ENUM DNS record where the first half of the record is a regular expression to apply to the lookup value and the second half is a regular expression that uses the matches from the first.
Example of an ENUM record f...
I have:
public enum MyEnum{
One, Two, Three
}
From controller, I put in the model:
HashMap<MyEnum, Long> map = new HashMap<MyEnum, Long>();
map.put(MyEnum.One, 1L);
mav.addObject( "map", map);
How do I in my JSTL access the object in the map for key enum MyEnum.One, in a neat way?
${map['One']} //does not seem to work...
nor ...
I've added some extension methods for strings to make working with some custom enums easier.
public static Enum ToEnum<T>(this string s)
{
return (Enum)Enum.Parse(typeof(T), s);
}
public static bool IsEnum<T>(this string s)
{
return Enum.IsDefined(typeof(T), s);
}
Note -- because of limitations of generic type constraints, I ...
How many entries can an enum in .NET have?
...
I have two arrays: Walls and Neighbors.
public boolean[] walls = new boolean[4];
public Cell[] neighbors = new Cell[4];
and I have an Enum:
enum Dir
{
North,
South,
East,
West
}
Now, I would like to be able to access walls or neighbors by their direction, so I don't have to pass around a bunch of magic indexes.
How...
I'm still working on my Cell class for my maze game I'm attempting to make. After help in a different thread it was suggested that I use an EnumMap for my Walls/Neighbors and this is working great so far.
Here is what I have thus far:
enum Dir {
NORTH, SOUTH, EAST, WEST
}
class Cell {
public Map<Dir, Cell> neighbors = Collect...
Hi,
I have an enum:
public enum baseKey : uint
{
HKEY_CLASSES_ROOT = 0x80000000,
HKEY_CURRENT_USER = 0x80000001,
HKEY_LOCAL_MACHINE = 0x80000002,
HKEY_USERS = 0x80000003,
HKEY_CURRENT_CONFIG = 0x80000005
}
How can i, given the string "HKEY_LOCAL_MACHINE", get a value 0x80000002 based on the enum ?
Thanks
Luiz C...
I want to have an enum as in:
enum FilterType
{
Rigid = "Rigid",
SoftGlow = "Soft / Glow",
Ghost = "Ghost",
}
How to achieve this? Is there a better way to do this? It's gonna be used for an instance of an object where it's gonna be serialized/deserialized. It's also gonna populate a dropdownlist.
...
I seem to have faced this problem many times and I wanted to ask the community whether I am just barking up the wrong tree. Basically my question can be distilled down to this: if I have an enum (in Java) for which the values are important, should I be using an enum at all or is there a better way, and if I do use an enum then what is th...
Reading some posts from Jimmy Boggard and wondering - how exactly is it possible to map those beasts with fluent nhibernate?
How mapping would look like for this?=>
public class EmployeeType : Enumeration
{
public static readonly EmployeeType Manager
= new EmployeeType(0, "Manager");
public static readonly EmployeeType...
I need to map the enums which didn't implement the interface beforehand to the existing database, which stores enums in the same table as the owner class using the @Enumerated(EnumType.STRING).
class A {
HasName name;
}
interface HasName {
String getName();
}
enum X implements HasName {
John, Mary;
public String getNa...
I have the following enum:
[Flags]
public enum PermissionLevel {
User = 1,
Administrator = 2,
ITStaff = 3,
Manager = 4,
SuperAdministrator = 6,
}
When I do:
PermissionLevel permission = (PermissionLevel) dr.GetInt32(i);
I get random permission values assigned to the permission object....